/// <summary>
        /// 删除云服务器
        /// </summary>
        public DeleteServersResponse DeleteServers(DeleteServersRequest deleteServersRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string      urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/delete", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", deleteServersRequest);
            SdkResponse response = DoHttpRequest("POST", request);

            return(JsonUtils.DeSerialize <DeleteServersResponse>(response));
        }
Exemplo n.º 2
0
        private static void DeleteServers(EcsClient client)
        {
            var req = new DeleteServersRequest
            {
                Body = new DeleteServersRequestBody
                {
                    Servers = new List <ServerId>
                    {
                        new ServerId
                        {
                            Id = "ed5e2af6-c539-42ee-b3dd-3048f140499c"
                        }
                    }
                }
            };

            try
            {
                var resp           = client.DeleteServers(req);
                var respStatusCode = resp.HttpStatusCode;
                var jobId          = resp.JobId;
                Console.WriteLine(respStatusCode);
                Console.WriteLine(jobId);
            }
            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);
            }
        }