Esempio n. 1
0
        /// <summary>
        /// 批量删除指定实例的标签
        /// </summary>
        public BatchDeleteInstanceTagsResponse BatchDeleteInstanceTags(BatchDeleteInstanceTagsRequest batchDeleteInstanceTagsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("instance_id", batchDeleteInstanceTagsRequest.InstanceId.ToString());
            string      urlPath  = HttpUtils.AddUrlPath("/v3/{project_id}/instances/{instance_id}/tags/action", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, "application/json", batchDeleteInstanceTagsRequest);
            SdkResponse response = DoHttpRequest("POST", request);

            return(JsonUtils.DeSerializeNull <BatchDeleteInstanceTagsResponse>(response));
        }
        /// <summary>
        /// 批量删除资源标签
        /// </summary>
        public static void BatchDeleteInstanceTags(DdsClient client)
        {
            var req = new BatchDeleteInstanceTagsRequest()
            {
                InstanceId = "fd1cac0eee0f4ad5a139a4dd6e994ea7in02",
                Body       = new BatchDeleteInstanceTagsRequestBody()
                {
                    Action = BatchDeleteInstanceTagsRequestBody.ActionEnum.DELETE,
                    Tags   = new List <BatchDeleteInstanceTagsOption>
                    {
                        new BatchDeleteInstanceTagsOption()
                        {
                            Key   = "key1",
                            Value = "value1"
                        }
                    }
                }
            };

            try
            {
                var resp = client.BatchDeleteInstanceTags(req);
                Console.WriteLine(resp.HttpStatusCode);
                Console.WriteLine("Batch Resource Instance Success!");
            }
            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);
            }
        }