/// <summary> /// 批量添加删除密钥标签 /// </summary> public async Task <BatchCreateKmsTagsResponse> BatchCreateKmsTagsAsync(BatchCreateKmsTagsRequest batchCreateKmsTagsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("key_id", batchCreateKmsTagsRequest.KeyId.ToString()); urlParam.Add("version_id", batchCreateKmsTagsRequest.VersionId.ToString()); string urlPath = HttpUtils.AddUrlPath("/{version_id}/{project_id}/kms/{key_id}/tags/action", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", batchCreateKmsTagsRequest); HttpResponseMessage response = await DoHttpRequestAsync("POST", request); return(JsonUtils.DeSerializeNull <BatchCreateKmsTagsResponse>(response)); }
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); } }