private static void ShowSecurityGroup(VpcClient client)
        {
            ShowSecurityGroupRequest req = new ShowSecurityGroupRequest
            {
                SecurityGroupId = "58117ec1-4581-4d26-b6db-a4f4e7b50de5"
            };

            try
            {
                var resp = client.ShowSecurityGroup(req);
                Console.WriteLine(resp.SecurityGroup.Id);
                Console.WriteLine(resp.SecurityGroup.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);
            }
        }
Exemple #2
0
        /// <summary>
        /// 查询安全组
        /// </summary>
        public async Task <ShowSecurityGroupResponse> ShowSecurityGroupAsync(ShowSecurityGroupRequest showSecurityGroupRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("security_group_id", showSecurityGroupRequest.SecurityGroupId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/security-groups/{security_group_id}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, showSecurityGroupRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("GET", request);

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