private static void ShowPort(VpcClient client) { ShowPortRequest req = new ShowPortRequest { PortId = "58117ec1-4581-4d26-b6db-a4f4e7b50de5" }; try { var resp = client.ShowPort(req); Console.WriteLine(resp.Port.Id); Console.WriteLine(resp.Port.Name); } 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 async Task <ShowPortResponse> ShowPortAsync(ShowPortRequest showPortRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("port_id", showPortRequest.PortId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v1/{project_id}/ports/{port_id}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, showPortRequest); HttpResponseMessage response = await DoHttpRequestAsync("GET", request); return(JsonUtils.DeSerialize <ShowPortResponse>(response)); }