コード例 #1
0
        /// <summary>
        /// 配置伸缩组通知
        /// </summary>
        public CreateScalingNotificationResponse CreateScalingNotification(CreateScalingNotificationRequest createScalingNotificationRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("scaling_group_id", createScalingNotificationRequest.ScalingGroupId.ToString());
            string      urlPath  = HttpUtils.AddUrlPath("/autoscaling-api/v1/{project_id}/scaling_notification/{scaling_group_id}", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", createScalingNotificationRequest);
            SdkResponse response = DoHttpRequest("PUT", request);

            return(JsonUtils.DeSerialize <CreateScalingNotificationResponse>(response));
        }
コード例 #2
0
        // scalingNotification
        // createScalingNotification
        private static void CreateScalingNotification(AsClient asClient)
        {
            var createScalingNotificationRequest = new CreateScalingNotificationRequest
            {
                ScalingGroupId = "2a8a1a58-077e-462e-ad50-d2283ebe607f",
                Body           = new CreateNotificationRequestBody
                {
                    TopicUrn   = "urn:smn:br-iaas-odin1:0605767fb000d5762ffcc00b78d8b511:DONOTDEL-AS-TOPIC01",
                    TopicScene = new List <string>
                    {
                        "SCALING_UP"
                    }
                }
            };

            try
            {
                var createScalingNotificationResponse =
                    asClient.CreateScalingNotification(createScalingNotificationRequest);
                Console.WriteLine(createScalingNotificationResponse.GetHttpBody());
            }
            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);
            }
        }