/// <summary>
        /// 批量重启云服务器
        /// </summary>
        public BatchRebootServersResponse BatchRebootServers(BatchRebootServersRequest batchRebootServersRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string      urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/action", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", batchRebootServersRequest);
            SdkResponse response = DoHttpRequest("POST", request);

            return(JsonUtils.DeSerialize <BatchRebootServersResponse>(response));
        }
示例#2
0
        private static void BatchRebootServers(EcsClient client)
        {
            var req = new BatchRebootServersRequest
            {
                Body = new BatchRebootServersRequestBody
                {
                    Reboot = new BatchRebootSeversOption
                    {
                        Type    = BatchRebootSeversOption.TypeEnum.SOFT,
                        Servers = new List <ServerId>
                        {
                            new ServerId
                            {
                                Id = "f0a34dd7-a103-400b-a448-9baad3077af2"
                            }
                        }
                    }
                }
            };

            try
            {
                var resp           = client.BatchRebootServers(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);
            }
        }