Example #1
0
        private static void stopMigrationTask(DcsClient dcsClient)
        {
            var stopMigrationTaskRequest = new StopMigrationTaskRequest()
            {
                TaskId = "ff808081729848e501729e2cb7d803cc"
            };

            try
            {
                var response = dcsClient.StopMigrationTask(stopMigrationTaskRequest);
                Console.WriteLine(response.GetHttpBody());
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }
Example #2
0
        /// <summary>
        /// 停止数据迁移任务
        /// </summary>
        public async Task <StopMigrationTaskResponse> StopMigrationTaskAsync(StopMigrationTaskRequest stopMigrationTaskRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("task_id", stopMigrationTaskRequest.TaskId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v2/{project_id}/migration-task/{task_id}/stop", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, stopMigrationTaskRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("POST", request);

            return(JsonUtils.DeSerialize <StopMigrationTaskResponse>(response));
        }