Example #1
0
        private static void BatchDeleteTags(KmsClient kmsClient)
        {
            var tagItems = new List <TagItem>();
            var tagItem1 = new TagItem();

            tagItem1.Key   = "key1";
            tagItem1.Value = "value1";
            var tagItem2 = new TagItem();

            tagItem2.Key   = "key2";
            tagItem2.Value = "value2";
            tagItems.Add(tagItem1);
            tagItems.Add(tagItem2);
            try
            {
                var req = new BatchCreateKmsTagsRequest
                {
                    VersionId = "v1.0",
                    KeyId     = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2"),
                    Body      = new BatchCreateKmsTagsRequestBody
                    {
                        Action = "delete",
                        Tags   = tagItems
                    }
                };
                var resp = kmsClient.BatchCreateKmsTags(req);
                Console.WriteLine(resp.HttpStatusCode);
            }
            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);
            }
        }