コード例 #1
0
        /// <summary>
        /// 批量启动云服务器
        /// </summary>
        public BatchStartServersResponse BatchStartServers(BatchStartServersRequest batchStartServersRequest)
        {
            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", batchStartServersRequest);
            SdkResponse response = DoHttpRequest("POST", request);

            return(JsonUtils.DeSerialize <BatchStartServersResponse>(response));
        }
コード例 #2
0
        private static void BatchStartServers(EcsClient client)
        {
            var req = new BatchStartServersRequest
            {
                Body = new BatchStartServersRequestBody
                {
                    OsStart = new BatchStartServersOption
                    {
                        Servers = new List <ServerId>
                        {
                            new ServerId
                            {
                                Id = "f0a34dd7-a103-400b-a448-9baad3077af2"
                            }
                        }
                    }
                }
            };

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