コード例 #1
0
        /**
         * Creates an export and waits for it to become available. This export enables us to access the file system
         * via the mount target. We recommend using a retry token on these requests
         * so that if you receive a timeout or server error and need to retry the request you won't run the risk of
         * creating multiple resources.
         *
         * There are rules around export paths and file system associations which you should review here:
         * https://docs.cloud.oracle.com/api/#/en/filestorage/20171215/Export/
         *
         * @param fsClient the service client to use to create the export
         * @param fileSystemId the OCID of the file system to associate with the export
         * @param exportSetId the OCID of the MountTarget's export set
         *
         * @return the created export
         */
        private static async Task <Export> CreateExport(FileStorageClient fsClient, string fileSystemId, string exportSetId)
        {
            logger.Info("Creating export.....");

            CreateExportDetails createExportDetails = new CreateExportDetails
            {
                ExportSetId  = exportSetId,
                FileSystemId = fileSystemId,
                Path         = ExportPath
            };
            CreateExportRequest createExportRequest = new CreateExportRequest
            {
                CreateExportDetails = createExportDetails
            };
            CreateExportResponse createResponse = await fsClient.CreateExport(createExportRequest,
                                                                              new RetryConfiguration
            {
                MaxAttempts = 5
            });

            logger.Info($"Created Export");

            logger.Info($"Waiting for export to become available");
            GetExportRequest getRequest = new GetExportRequest
            {
                ExportId = createResponse.Export.Id
            };
            GetExportResponse getExportResponse = fsClient.Waiters.ForExport(getRequest, Export.LifecycleStateEnum.Active).Execute();

            logger.Info($"Export path state: {getExportResponse.Export.LifecycleState}");

            return(getExportResponse.Export);
        }
コード例 #2
0
        public async Task GivenAFhirMediator_WhenGettingAnExistingExportJobWithCompletedStatus_ThenHttpResponseCodeShouldBeOk()
        {
            GetExportResponse result = await SetupAndExecuteGetExportJobByIdAsync(OperationStatus.Completed);

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
            Assert.NotNull(result.JobResult);

            // Check whether required fields are present.
            Assert.NotNull(result.JobResult.Output);
            Assert.NotEqual(default, result.JobResult.TransactionTime);
コード例 #3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetExportResponse response = new GetExportResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("exportStatus", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ExportStatus = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("exportType", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ExportType = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("failureReason", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.FailureReason = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("name", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Name = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("resourceType", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ResourceType = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("url", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Url = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("version", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Version = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
コード例 #4
0
        public static async Task <GetExportResponse> GetExportStatusAsync(this IMediator mediator, Uri requestUri, string jobId, CancellationToken cancellationToken = default)
        {
            EnsureArg.IsNotNull(mediator, nameof(mediator));
            EnsureArg.IsNotNull(requestUri, nameof(requestUri));
            EnsureArg.IsNotNullOrWhiteSpace(jobId, nameof(jobId));

            var request = new GetExportRequest(requestUri, jobId);

            GetExportResponse response = await mediator.Send(request, cancellationToken);

            return(response);
        }
コード例 #5
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetExportResponse response = new GetExportResponse();

            var ms = new MemoryStream();

            Amazon.Util.AWSSDKUtils.CopyStream(context.Stream, ms);
            ms.Seek(0, SeekOrigin.Begin);
            response.Body = ms;
            if (context.ResponseData.IsHeaderPresent("Content-Disposition"))
            {
                response.ContentDisposition = context.ResponseData.GetHeaderValue("Content-Disposition");
            }
            if (context.ResponseData.IsHeaderPresent("Content-Type"))
            {
                response.ContentType = context.ResponseData.GetHeaderValue("Content-Type");
            }

            return(response);
        }