private static void ListServerInterfaces(EcsClient client)
        {
            var req = new ListServerInterfacesRequest
            {
                ServerId = "5d78e6e5-1d8f-444c-a9e4-81d3b78e80f5"
            };

            try
            {
                var resp           = client.ListServerInterfaces(req);
                var respStatusCode = resp.HttpStatusCode;
                var attachments    = resp.InterfaceAttachments;
                Console.WriteLine(respStatusCode);
                foreach (var attachment in attachments)
                {
                    Console.WriteLine(attachment.PortId);
                }
            }
            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 ListServerInterfacesResponse ListServerInterfaces(ListServerInterfacesRequest listServerInterfacesRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("server_id", listServerInterfacesRequest.ServerId.ToString());
            string      urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/{server_id}/os-interface", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, listServerInterfacesRequest);
            SdkResponse response = DoHttpRequest("GET", request);

            return(JsonUtils.DeSerialize <ListServerInterfacesResponse>(response));
        }
Beispiel #3
0
        /// <summary>
        /// 查询云服务器网卡信息
        /// </summary>
        public async Task <ListServerInterfacesResponse> ListServerInterfacesAsync(ListServerInterfacesRequest listServerInterfacesRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("server_id", listServerInterfacesRequest.ServerId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/{server_id}/os-interface", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json", listServerInterfacesRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("GET", request);

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