Beispiel #1
0
        /// <summary>
        /// 创建标签
        /// </summary>
        public CreateScalingTagsResponse CreateScalingTags(CreateScalingTagsRequest createScalingTagsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("resource_type", createScalingTagsRequest.ResourceType.ToString());
            urlParam.Add("resource_id", createScalingTagsRequest.ResourceId.ToString());
            string      urlPath  = HttpUtils.AddUrlPath("/autoscaling-api/v1/{project_id}/{resource_type}/{resource_id}/tags/action", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", createScalingTagsRequest);
            SdkResponse response = DoHttpRequest("POST", request);

            return(JsonUtils.DeSerializeNull <CreateScalingTagsResponse>(response));
        }
Beispiel #2
0
        // operateTags
        private static void OperateScalingTagInfo(AsClient asClient)
        {
            var operateScalingTagInfoRequest = new CreateScalingTagsRequest
            {
                ResourceType = CreateScalingTagsRequest.ResourceTypeEnum.SCALING_GROUP_TAG,
                ResourceId   = "2a8a1a58-077e-462e-ad50-d2283ebe607f",
                Body         = new CreateScalingTagsRequestBody
                {
                    Action = CreateScalingTagsRequestBody.ActionEnum.CREATE,
                    Tags   = new List <TagsSingleValue>
                    {
                        new TagsSingleValue
                        {
                            Key   = "key",
                            Value = "value"
                        }
                    }
                }
            };

            try
            {
                var operateScalingTagInfoResponse = asClient.CreateScalingTags(operateScalingTagInfoRequest);
                Console.WriteLine(operateScalingTagInfoResponse.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);
            }
        }