private static void ListPrivateips(VpcClient client) { ListPrivateipsRequest req = new ListPrivateipsRequest { SubnetId = "0fae9377-f51c-430e-ba16-9bdd619b1d97", Limit = 1, }; try { var resp = client.ListPrivateips(req); foreach (var privateIp in resp.Privateips) { Console.WriteLine(privateIp.Id); Console.WriteLine(privateIp.IpAddress); } } 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> /// 查询私有IP列表 /// </summary> public async Task <ListPrivateipsResponse> ListPrivateipsAsync(ListPrivateipsRequest listPrivateipsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("subnet_id", listPrivateipsRequest.SubnetId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v1/{project_id}/subnets/{subnet_id}/privateips", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, listPrivateipsRequest); HttpResponseMessage response = await DoHttpRequestAsync("GET", request); return(JsonUtils.DeSerialize <ListPrivateipsResponse>(response)); }