// DeleteLifeCycleHook
        private static void DeleteLifecycleHook(AsClient asClient)
        {
            var deleteLifecycleHookRequest = new DeleteLifecycleHookRequest
            {
                ScalingGroupId    = "2a8a1a58-077e-462e-ad50-d2283ebe607f",
                LifecycleHookName = "test_hook"
            };

            try
            {
                var deleteLifecycleHookResponse = asClient.DeleteLifecycleHook(deleteLifecycleHookRequest);
                Console.WriteLine(deleteLifecycleHookResponse.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);
            }
        }
Пример #2
0
        /// <summary>
        /// 删除生命周期挂钩
        /// </summary>
        public DeleteLifecycleHookResponse DeleteLifecycleHook(DeleteLifecycleHookRequest deleteLifecycleHookRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("scaling_group_id", deleteLifecycleHookRequest.ScalingGroupId.ToString());
            urlParam.Add("lifecycle_hook_name", deleteLifecycleHookRequest.LifecycleHookName.ToString());
            string      urlPath  = HttpUtils.AddUrlPath("/autoscaling-api/v1/{project_id}/scaling_lifecycle_hook/{scaling_group_id}/{lifecycle_hook_name}", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, deleteLifecycleHookRequest);
            SdkResponse response = DoHttpRequest("DELETE", request);

            return(JsonUtils.DeSerializeNull <DeleteLifecycleHookResponse>(response));
        }
        /// <summary>
        /// 本接口(DeleteLifecycleHook)用于删除生命周期挂钩。
        /// </summary>
        /// <param name="req">参考<see cref="DeleteLifecycleHookRequest"/></param>
        /// <returns>参考<see cref="DeleteLifecycleHookResponse"/>实例</returns>
        public async Task <DeleteLifecycleHookResponse> DeleteLifecycleHook(DeleteLifecycleHookRequest req)
        {
            JsonResponseModel <DeleteLifecycleHookResponse> rsp = null;

            try
            {
                var strResp = await this.InternalRequest(req, "DeleteLifecycleHook");

                rsp = JsonConvert.DeserializeObject <JsonResponseModel <DeleteLifecycleHookResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }