public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new AnnotateApi(configuration);

            try
            {
                // Set request.
                var request = new GetExportRequest()
                {
                    filePath        = "Annotationdocs\\ten-pages.pdf",
                    password        = null,
                    annotatedPages  = true,
                    annotationTypes = null,
                    firstPage       = 1,
                    lastPage        = 2
                };

                Stream response = apiInstance.GetExport(request);
                Console.WriteLine("Expected response type is Stream: Document Length: " + response.Length.ToString());
                using (var fileStream = File.Create("D:\\Results-ten-pages.pdf"))
                {
                    response.Seek(0, SeekOrigin.Begin);
                    response.CopyTo(fileStream);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling Annotation AnnotateApi: " + e.Message);
            }
        }
コード例 #2
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);
        }
コード例 #3
0
        /// <summary>
        /// Creates a waiter using the provided configuration.
        /// </summary>
        /// <param name="request">Request to send.</param>
        /// <param name="config">Wait Configuration</param>
        /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
        /// <returns>a new Oci.common.Waiter instance</returns>
        public Waiter <GetExportRequest, GetExportResponse> ForExport(GetExportRequest request, WaiterConfiguration config, params Export.LifecycleStateEnum[] targetStates)
        {
            var agent = new WaiterAgent <GetExportRequest, GetExportResponse>(
                request,
                request => client.GetExport(request),
                response => targetStates.Contains(response.Export.LifecycleState.Value),
                targetStates.Contains(Export.LifecycleStateEnum.Deleted)
                );

            return(new Waiter <GetExportRequest, GetExportResponse>(config, agent));
        }
コード例 #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
        /**
         * Deletes an export and waits for it to be deleted.
         *
         * @param fsClient the service client used to communicate with the File Storage service
         * @param export the export to delete
         */
        private static async Task DeleteExport(FileStorageClient fsClient, Export export)
        {
            logger.Info("Deleting export");

            DeleteExportRequest deleteExportRequest = new DeleteExportRequest
            {
                ExportId = export.Id
            };
            await fsClient.DeleteExport(deleteExportRequest);

            GetExportRequest getExportRequest = new GetExportRequest
            {
                ExportId = export.Id
            };

            fsClient.Waiters.ForExport(getExportRequest, Export.LifecycleStateEnum.Deleted).Execute();
        }
コード例 #6
0
        private void HandleOutput(GetExportRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

            switch (ParameterSetName)
            {
            case LifecycleStateParamSet:
                response = client.Waiters.ForExport(request, waiterConfig, WaitForLifecycleState).Execute();
                break;

            case Default:
                response = client.GetExport(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Export);
        }
コード例 #7
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetExportRequest request;

            try
            {
                request = new GetExportRequest
                {
                    ExportId     = ExportId,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
コード例 #8
0
 /// <summary>
 /// Creates a waiter using default wait configuration.
 /// </summary>
 /// <param name="request">Request to send.</param>
 /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
 /// <returns>a new Oci.common.Waiter instance</returns>
 public Waiter <GetExportRequest, GetExportResponse> ForExport(GetExportRequest request, params Export.LifecycleStateEnum[] targetStates)
 {
     return(this.ForExport(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }