Ejemplo n.º 1
0
        /// <summary>
        /// Updates a Transfer Job that corresponds with customer&#39;s logical dataset e.g. a DB or a filesystem.
        /// </summary>
        /// <param name="request">The request object containing the details to send. Required.</param>
        /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param>
        /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param>
        /// <returns>A response object containing details about the completed operation</returns>
        /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/dts/UpdateTransferJob.cs.html">here</a> to see an example of how to use UpdateTransferJob API.</example>
        public async Task <UpdateTransferJobResponse> UpdateTransferJob(UpdateTransferJobRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called updateTransferJob");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/transferJobs/{id}".Trim('/')));
            HttpMethod         method         = new HttpMethod("PUT");
            HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request);

            requestMessage.Headers.Add("Accept", "application/json");
            GenericRetrier      retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration);
            HttpResponseMessage responseMessage;

            try
            {
                if (retryingClient != null)
                {
                    responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false);
                }
                this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage);

                return(Converter.FromHttpResponseMessage <UpdateTransferJobResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"UpdateTransferJob failed with error: {e.Message}");
                throw;
            }
        }
        public void UpdateTransferJobRequestObject()
        {
            moq::Mock <StorageTransferService.StorageTransferServiceClient> mockGrpcClient = new moq::Mock <StorageTransferService.StorageTransferServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            UpdateTransferJobRequest request = new UpdateTransferJobRequest
            {
                JobName     = "job_namedc176648",
                ProjectId   = "project_id43ad98b0",
                TransferJob = new TransferJob(),
                UpdateTransferJobFieldMask = new wkt::FieldMask(),
            };
            TransferJob expectedResponse = new TransferJob
            {
                Name                 = "name1c9368b0",
                Description          = "description2cf9da67",
                ProjectId            = "project_id43ad98b0",
                TransferSpec         = new TransferSpec(),
                Schedule             = new Schedule(),
                Status               = TransferJob.Types.Status.Disabled,
                CreationTime         = new wkt::Timestamp(),
                LastModificationTime = new wkt::Timestamp(),
                DeletionTime         = new wkt::Timestamp(),
                NotificationConfig   = new NotificationConfig(),
                LatestOperationName  = "latest_operation_namef5a455e9",
            };

            mockGrpcClient.Setup(x => x.UpdateTransferJob(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            StorageTransferServiceClient client = new StorageTransferServiceClientImpl(mockGrpcClient.Object, null);
            TransferJob response = client.UpdateTransferJob(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for UpdateTransferJob</summary>
 public void UpdateTransferJobRequestObject()
 {
     // Snippet: UpdateTransferJob(UpdateTransferJobRequest, CallSettings)
     // Create client
     StorageTransferServiceClient storageTransferServiceClient = StorageTransferServiceClient.Create();
     // Initialize request argument(s)
     UpdateTransferJobRequest request = new UpdateTransferJobRequest
     {
         JobName     = "",
         ProjectId   = "",
         TransferJob = new TransferJob(),
         UpdateTransferJobFieldMask = new FieldMask(),
     };
     // Make the request
     TransferJob response = storageTransferServiceClient.UpdateTransferJob(request);
     // End snippet
 }
        /// <summary>Snippet for UpdateTransferJobAsync</summary>
        public async Task UpdateTransferJobRequestObjectAsync()
        {
            // Snippet: UpdateTransferJobAsync(UpdateTransferJobRequest, CallSettings)
            // Additional: UpdateTransferJobAsync(UpdateTransferJobRequest, CancellationToken)
            // Create client
            StorageTransferServiceClient storageTransferServiceClient = await StorageTransferServiceClient.CreateAsync();

            // Initialize request argument(s)
            UpdateTransferJobRequest request = new UpdateTransferJobRequest
            {
                JobName     = "",
                ProjectId   = "",
                TransferJob = new TransferJob(),
                UpdateTransferJobFieldMask = new FieldMask(),
            };
            // Make the request
            TransferJob response = await storageTransferServiceClient.UpdateTransferJobAsync(request);

            // End snippet
        }
Ejemplo n.º 5
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateTransferJobRequest request;

            try
            {
                request = new UpdateTransferJobRequest
                {
                    Id = Id,
                    UpdateTransferJobDetails = UpdateTransferJobDetails,
                    IfMatch      = IfMatch,
                    OpcRequestId = OpcRequestId
                };

                response = client.UpdateTransferJob(request).GetAwaiter().GetResult();
                WriteOutput(response, response.TransferJob);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        /// <summary>
        /// Updates a transfer job. Updating a job's transfer spec does not affecttransfer operations that are running already. Updating the schedulingof a job is not allowed.
        /// Documentation https://developers.google.com/storagetransfer/v1/reference/transferJobs/patch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Storagetransfer service.</param>
        /// <param name="jobName">The name of job to update.Required.</param>
        /// <param name="body">A valid Storagetransfer v1 body.</param>
        /// <returns>TransferJobResponse</returns>
        public static TransferJob Patch(StoragetransferService service, string jobName, UpdateTransferJobRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (jobName == null)
                {
                    throw new ArgumentNullException(jobName);
                }

                // Make the request.
                return(service.TransferJobs.Patch(body, jobName).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request TransferJobs.Patch failed.", ex);
            }
        }