/// <summary>
        /// 批量添加云服务器标签
        /// </summary>
        public BatchCreateServerTagsResponse BatchCreateServerTags(BatchCreateServerTagsRequest batchCreateServerTagsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("server_id", batchCreateServerTagsRequest.ServerId.ToString());
            string      urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/{server_id}/tags/action", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", batchCreateServerTagsRequest);
            SdkResponse response = DoHttpRequest("POST", request);

            return(JsonUtils.DeSerializeNull <BatchCreateServerTagsResponse>(response));
        }
Exemple #2
0
        private static void BatchCreateServerTags(EcsClient client)
        {
            var req = new BatchCreateServerTagsRequest()
            {
                ServerId = "f0a34dd7-a103-400b-a448-9baad3077af2",
                Body     = new BatchCreateServerTagsRequestBody
                {
                    Action = BatchCreateServerTagsRequestBody.ActionEnum.CREATE,
                    Tags   = new List <ServerTag>
                    {
                        new ServerTag
                        {
                            Key   = "key-5",
                            Value = "value-5"
                        }
                    }
                }
            };

            try
            {
                var resp           = client.BatchCreateServerTags(req);
                var respStatusCode = resp.HttpStatusCode;
                Console.WriteLine(respStatusCode);
            }
            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);
            }
        }