/// <summary>
        /// 启动或停止一条告警规则。
        /// </summary>
        /// <param name="cesV1Client"></param>
        private static void UpdateAlarmAction(CesClient cesClient)
        {
            UpdateAlarmActionRequest updateAlarmActionRequest = new UpdateAlarmActionRequest()
            {
                AlarmId = "al1587007900469Eylrzy8GW",
                Body    = new ModifyAlarmActionReq()
                {
                    AlarmEnabled = false
                }
            };

            try
            {
                UpdateAlarmActionResponse updateAlarmActionResponse =
                    cesClient.UpdateAlarmAction(updateAlarmActionRequest);
                Console.WriteLine(updateAlarmActionResponse.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);
            }
        }
Exemple #2
0
        /// <summary>
        /// 启停告警规则
        /// </summary>
        public async Task <UpdateAlarmActionResponse> UpdateAlarmActionAsync(UpdateAlarmActionRequest updateAlarmActionRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("alarm_id", updateAlarmActionRequest.AlarmId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/V1.0/{project_id}/alarms/{alarm_id}/action", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", updateAlarmActionRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("PUT", request);

            return(JsonUtils.DeSerializeNull <UpdateAlarmActionResponse>(response));
        }