Exemplo n.º 1
0
        private static void ListPorts(VpcClient client)
        {
            ListPortsRequest req = new ListPortsRequest
            {
                Limit = 1,
            };

            try
            {
                ListPortsResponse resp = client.ListPorts(req);
                foreach (var port in resp.Ports)
                {
                    Console.WriteLine(port.Id);
                    Console.WriteLine(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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查询端口列表
        /// </summary>
        public async Task <ListPortsResponse> ListPortsAsync(ListPortsRequest listPortsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string              urlPath          = HttpUtils.AddUrlPath("/v1/{project_id}/ports", urlParam);
            SdkRequest          request          = HttpUtils.InitSdkRequest(urlPath, listPortsRequest);
            HttpResponseMessage response         = await DoHttpRequestAsync("GET", request);

            return(JsonUtils.DeSerialize <ListPortsResponse>(response));
        }
        /// <summary>
        /// 查询端口列表
        /// </summary>
        public ListPortsResponse ListPorts(ListPortsRequest listPortsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string      urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/ports", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, listPortsRequest);
            SdkResponse response = DoHttpRequest("GET", request);

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