Exemplo n.º 1
0
        private static void ListServersDetails(EcsClient client)
        {
            var req = new ListServersDetailsRequest
            {
                Offset = 1
            };

            try
            {
                var resp           = client.ListServersDetails(req);
                var respStatusCode = resp.HttpStatusCode;
                var servers        = resp.Servers;
                Console.WriteLine(respStatusCode);
                foreach (var server in servers)
                {
                    Console.WriteLine(server.Id);
                }
            }
            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);
            }
        }
        /// <summary>
        /// 查询云服务器详情列表
        /// </summary>
        public ListServersDetailsResponse ListServersDetails(ListServersDetailsRequest listServersDetailsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string      urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/detail", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, listServersDetailsRequest);
            SdkResponse response = DoHttpRequest("GET", request);

            return(JsonUtils.DeSerialize <ListServersDetailsResponse>(response));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查询云服务器详情列表
        /// </summary>
        public async Task <ListServersDetailsResponse> ListServersDetailsAsync(ListServersDetailsRequest listServersDetailsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string              urlPath          = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/detail", urlParam);
            SdkRequest          request          = HttpUtils.InitSdkRequest(urlPath, "application/json", listServersDetailsRequest);
            HttpResponseMessage response         = await DoHttpRequestAsync("GET", request);

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