Esempio n. 1
0
        /// <summary>
        /// Creates an application migration in the specified compartment.
        /// Specify the compartment using the compartment ID.
        ///
        /// </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>
        public async Task <CreateMigrationResponse> CreateMigration(CreateMigrationRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called createMigration");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/migrations".Trim('/')));
            HttpMethod         method         = new HttpMethod("Post");
            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);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage);
                }

                return(Converter.FromHttpResponseMessage <CreateMigrationResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"CreateMigration failed with error: {e.Message}");
                throw;
            }
        }
        /// <summary>
        /// 本接口(CreateMigration)作用是创建一个迁移任务
        /// </summary>
        /// <param name="req">参考<see cref="CreateMigrationRequest"/></param>
        /// <returns>参考<see cref="CreateMigrationResponse"/>实例</returns>
        public async Task <CreateMigrationResponse> CreateMigration(CreateMigrationRequest req)
        {
            JsonResponseModel <CreateMigrationResponse> rsp = null;

            try
            {
                var strResp = await this.InternalRequest(req, "CreateMigration");

                rsp = JsonConvert.DeserializeObject <JsonResponseModel <CreateMigrationResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            CreateMigrationRequest request;

            try
            {
                request = new CreateMigrationRequest
                {
                    CreateMigrationDetails = CreateMigrationDetails,
                    OpcRequestId           = OpcRequestId,
                    OpcRetryToken          = OpcRetryToken
                };

                response = client.CreateMigration(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Migration);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }