Esempio n. 1
0
        private static void NovaListServersDetails(EcsClient client)
        {
            var req = new NovaListServersDetailsRequest
            {
                OpenStackAPIVersion = "compute 2.26"
            };

            try
            {
                var resp = client.NovaListServersDetails(req);
                Console.WriteLine(resp.HttpStatusCode);
                var respServers = resp.Servers;
                foreach (var server in respServers)
                {
                    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 NovaListServersDetailsResponse NovaListServersDetails(NovaListServersDetailsRequest novaListServersDetailsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string      urlPath  = HttpUtils.AddUrlPath("/v2.1/{project_id}/servers/detail", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, novaListServersDetailsRequest);
            SdkResponse response = DoHttpRequest("GET", request);

            return(JsonUtils.DeSerialize <NovaListServersDetailsResponse>(response));
        }
Esempio n. 3
0
        /// <summary>
        /// 查询云服务器详情列表
        /// </summary>
        public async Task <NovaListServersDetailsResponse> NovaListServersDetailsAsync(NovaListServersDetailsRequest novaListServersDetailsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string              urlPath          = HttpUtils.AddUrlPath("/v2.1/{project_id}/servers/detail", urlParam);
            SdkRequest          request          = HttpUtils.InitSdkRequest(urlPath, "application/json", novaListServersDetailsRequest);
            HttpResponseMessage response         = await DoHttpRequestAsync("GET", request);

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