private static void ShowServer(EcsClient client) { var req = new ShowServerRequest { ServerId = "ed5e2af6-c539-42ee-b3dd-3048f140499c" }; try { var resp = client.ShowServer(req); var respStatusCode = resp.HttpStatusCode; var server = resp.Server; Console.WriteLine(respStatusCode); 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 ShowServerResponse ShowServer(ShowServerRequest showServerRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("server_id", showServerRequest.ServerId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/{server_id}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, showServerRequest); SdkResponse response = DoHttpRequest("GET", request); return(JsonUtils.DeSerialize <ShowServerResponse>(response)); }
/// <summary> /// 查询云服务器详情 /// </summary> public async Task <ShowServerResponse> ShowServerAsync(ShowServerRequest showServerRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("server_id", showServerRequest.ServerId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/{server_id}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", showServerRequest); HttpResponseMessage response = await DoHttpRequestAsync("GET", request); return(JsonUtils.DeSerialize <ShowServerResponse>(response)); }