/// <summary> /// Temporarily sets the state of an alarm. When the updated <code>StateValue</code> /// differs from the previous value, the action configured for the appropriate state is /// invoked. This is not a permanent change. The next periodic alarm check (in about a /// minute) will set the alarm to its actual state. /// </summary> /// <param name="request">Container for the necessary parameters to execute the SetAlarmState service method.</param> /// /// <returns>The response from the SetAlarmState service method, as returned by CloudWatch.</returns> /// <exception cref="Amazon.CloudWatch.Model.InvalidFormatException"> /// Data was not syntactically valid JSON. /// </exception> /// <exception cref="Amazon.CloudWatch.Model.ResourceNotFoundException"> /// The named resource does not exist. /// </exception> public SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest request) { var marshaller = new SetAlarmStateRequestMarshaller(); var unmarshaller = SetAlarmStateResponseUnmarshaller.Instance; return(Invoke <SetAlarmStateRequest, SetAlarmStateResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// <para> Temporarily sets the state of an alarm. When the updated <c>StateValue</c> differs from the previous value, the action configured for /// the appropriate state is invoked. This is not a permanent change. The next periodic alarm check (in about a minute) will set the alarm to /// its actual state. </para> /// </summary> /// /// <param name="setAlarmStateRequest">Container for the necessary parameters to execute the SetAlarmState service method on /// AmazonCloudWatch.</param> /// /// <exception cref="T:Amazon.CloudWatch.Model.ResourceNotFoundException" /> /// <exception cref="T:Amazon.CloudWatch.Model.InvalidFormatException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task <SetAlarmStateResponse> SetAlarmStateAsync(SetAlarmStateRequest setAlarmStateRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new SetAlarmStateRequestMarshaller(); var unmarshaller = SetAlarmStateResponseUnmarshaller.GetInstance(); return(Invoke <IRequest, SetAlarmStateRequest, SetAlarmStateResponse>(setAlarmStateRequest, marshaller, unmarshaller, signer, cancellationToken)); }
internal virtual SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest request) { var marshaller = SetAlarmStateRequestMarshaller.Instance; var unmarshaller = SetAlarmStateResponseUnmarshaller.Instance; return(Invoke <SetAlarmStateRequest, SetAlarmStateResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// <para> Temporarily sets the state of an alarm. When the updated /// <c>StateValue</c> differs from the previous value, the action /// configured for the appropriate state is invoked. This is not a /// permanent change. The next periodic alarm check (in about a minute) /// will set the alarm to its actual state. </para> /// </summary> /// /// <param name="setAlarmStateRequest">Container for the necessary /// parameters to execute the SetAlarmState service method on /// AmazonCloudWatch.</param> /// /// <exception cref="ResourceNotFoundException"/> /// <exception cref="InvalidFormatException"/> public SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest setAlarmStateRequest) { IRequest <SetAlarmStateRequest> request = new SetAlarmStateRequestMarshaller().Marshall(setAlarmStateRequest); SetAlarmStateResponse response = Invoke <SetAlarmStateRequest, SetAlarmStateResponse> (request, this.signer, SetAlarmStateResponseUnmarshaller.GetInstance()); return(response); }
/// <summary> /// Initiates the asynchronous execution of the SetAlarmState operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the SetAlarmState operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <SetAlarmStateResponse> SetAlarmStateAsync(SetAlarmStateRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new SetAlarmStateRequestMarshaller(); var unmarshaller = SetAlarmStateResponseUnmarshaller.Instance; return(InvokeAsync <SetAlarmStateRequest, SetAlarmStateResponse>(request, marshaller, unmarshaller, cancellationToken)); }
IAsyncResult invokeSetAlarmState(SetAlarmStateRequest setAlarmStateRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new SetAlarmStateRequestMarshaller().Marshall(setAlarmStateRequest); var unmarshaller = SetAlarmStateResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the SetAlarmState operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the SetAlarmState operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/monitoring-2010-08-01/SetAlarmState">REST API Reference for SetAlarmState Operation</seealso> public virtual Task <SetAlarmStateResponse> SetAlarmStateAsync(SetAlarmStateRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = SetAlarmStateRequestMarshaller.Instance; options.ResponseUnmarshaller = SetAlarmStateResponseUnmarshaller.Instance; return(InvokeAsync <SetAlarmStateResponse>(request, options, cancellationToken)); }
internal virtual SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = SetAlarmStateRequestMarshaller.Instance; options.ResponseUnmarshaller = SetAlarmStateResponseUnmarshaller.Instance; return(Invoke <SetAlarmStateResponse>(request, options)); }
internal SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest request) { var task = SetAlarmStateAsync(request); try { return(task.Result); } catch (AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return(null); } }
public static void CWSetAlarmState() { #region CWSetAlarmState var client = new AmazonCloudWatchClient(); var request = new SetAlarmStateRequest { AlarmName = "Offline Instances", StateReason = "Too many instances are offline.", StateValue = StateValue.ALARM }; client.SetAlarmState(request); #endregion }
/// <summary> /// Initiates the asynchronous execution of the SetAlarmState operation. /// <seealso cref="Amazon.CloudWatch.AmazonCloudWatch.SetAlarmState"/> /// </summary> /// /// <param name="setAlarmStateRequest">Container for the necessary parameters to execute the SetAlarmState operation on /// AmazonCloudWatch.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> public IAsyncResult BeginSetAlarmState(SetAlarmStateRequest setAlarmStateRequest, AsyncCallback callback, object state) { return(invokeSetAlarmState(setAlarmStateRequest, callback, state, false)); }
/// <summary> /// <para> Temporarily sets the state of an alarm. When the updated <c>StateValue</c> differs from the previous value, the action configured for /// the appropriate state is invoked. This is not a permanent change. The next periodic alarm check (in about a minute) will set the alarm to /// its actual state. </para> /// </summary> /// /// <param name="setAlarmStateRequest">Container for the necessary parameters to execute the SetAlarmState service method on /// AmazonCloudWatch.</param> /// /// <exception cref="ResourceNotFoundException"/> /// <exception cref="InvalidFormatException"/> public SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest setAlarmStateRequest) { IAsyncResult asyncResult = invokeSetAlarmState(setAlarmStateRequest, null, null, true); return(EndSetAlarmState(asyncResult)); }
public void TestSetAlarmStateAndHistory() { String metricName = this.GetType().Name + DateTime.Now.Ticks; PutMetricAlarmRequest[] rqs = CreateTwoNewAlarms(metricName); PutMetricAlarmRequest rq1 = rqs[0]; PutMetricAlarmRequest rq2 = rqs[1]; /* * Set the state */ SetAlarmStateRequest setAlarmStateRequest = new SetAlarmStateRequest() { AlarmName = rq1.AlarmName, StateValue = "ALARM", StateReason = "manual" }; Client.SetAlarmState(setAlarmStateRequest); setAlarmStateRequest = new SetAlarmStateRequest() { AlarmName = rq2.AlarmName, StateValue = "ALARM", StateReason = "manual" }; Client.SetAlarmState(setAlarmStateRequest); DescribeAlarmsForMetricResult describeResult = Client .DescribeAlarmsForMetric( new DescribeAlarmsForMetricRequest() { Dimensions = rq1.Dimensions, MetricName = metricName, Namespace = rq1.Namespace }); Assert.AreEqual(2, describeResult.MetricAlarms.Count); foreach (MetricAlarm alarm in describeResult.MetricAlarms) { Assert.IsTrue(rq1.AlarmName.Equals(alarm.AlarmName) || rq2.AlarmName.Equals(alarm.AlarmName)); Assert.IsTrue("ALARM".Equals(alarm.StateValue) || "INSUFFICIENT_DATA".Equals(alarm.StateValue)); if ("ALARM".Equals(alarm.StateValue)) { Assert.AreEqual(setAlarmStateRequest.StateReason, alarm.StateReason); } } /* * Get the history */ DescribeAlarmHistoryRequest alarmHistoryRequest = new DescribeAlarmHistoryRequest() { AlarmName = rq1.AlarmName, HistoryItemType = "StateUpdate" }; DescribeAlarmHistoryResult historyResult = Client.DescribeAlarmHistory(alarmHistoryRequest); Assert.IsTrue(historyResult.AlarmHistoryItems.Count > 0); }