/// <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));
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
        internal virtual SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest request)
        {
            var marshaller   = SetAlarmStateRequestMarshaller.Instance;
            var unmarshaller = SetAlarmStateResponseUnmarshaller.Instance;

            return(Invoke <SetAlarmStateRequest, SetAlarmStateResponse>(request, marshaller, unmarshaller));
        }
Ejemplo n.º 4
0
        /// <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));
        }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
        /// <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));
        }
Ejemplo n.º 8
0
        internal virtual SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = SetAlarmStateRequestMarshaller.Instance;
            options.ResponseUnmarshaller = SetAlarmStateResponseUnmarshaller.Instance;

            return(Invoke <SetAlarmStateResponse>(request, options));
        }
Ejemplo n.º 9
0
        internal SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest request)
        {
            var task = SetAlarmStateAsync(request);

            try
            {
                return(task.Result);
            }
            catch (AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return(null);
            }
        }
Ejemplo n.º 10
0
        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
        }
Ejemplo n.º 11
0
 /// <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));
 }
Ejemplo n.º 12
0
        /// <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));
        }
Ejemplo n.º 13
0
        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);
        }