Example #1
0
        private static void UpdateVpc(VpcClient client)
        {
            UpdateVpcRequest req = new UpdateVpcRequest
            {
                VpcId = "c11800b4-9ae2-40fb-b8c6-51242fbb300c",
                Body  = new UpdateVpcRequestBody
                {
                    Vpc = new UpdateVpcOption
                    {
                        Description = "Updated test vpc"
                    }
                }
            };

            try
            {
                var resp = client.UpdateVpc(req);
                Console.WriteLine(resp.Vpc.Description);
            }
            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);
            }
        }
Example #2
0
        /// <summary>
        /// 更新VPC
        /// </summary>
        public async Task <UpdateVpcResponse> UpdateVpcAsync(UpdateVpcRequest updateVpcRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("vpc_id", updateVpcRequest.VpcId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/vpcs/{vpc_id}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", updateVpcRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("PUT", request);

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