/// <summary> /// 批量添加或删除资源标签 /// </summary> public BatchTagActionResponse BatchTagAction(BatchTagActionRequest batchTagActionRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("instance_id", batchTagActionRequest.InstanceId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v3/{project_id}/instances/{instance_id}/tags/action", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", batchTagActionRequest); HttpResponseMessage response = DoHttpRequestSync("POST", request); return(JsonUtils.DeSerializeNull <BatchTagActionResponse>(response)); }
/// <summary> /// 批量删除资源标签 /// </summary> public static void BatchDeleteInstanceTags(DdsClient client) { var req = new BatchTagActionRequest() { InstanceId = "fd1cac0eee0f4ad5a139a4dd6e994ea7in02", Body = new BatchOperateInstanceTagRequestBody() { Action = BatchOperateInstanceTagRequestBody.ActionEnum.DELETE, Tags = new List <TagItem> { new TagItem() { Key = "key1", Value = "value1" } } } }; try { var resp = client.BatchTagAction(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); } }