public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.CloudWatch.Model.SetAlarmStateRequest(); if (cmdletContext.AlarmName != null) { request.AlarmName = cmdletContext.AlarmName; } if (cmdletContext.StateReason != null) { request.StateReason = cmdletContext.StateReason; } if (cmdletContext.StateReasonData != null) { request.StateReasonData = cmdletContext.StateReasonData; } if (cmdletContext.StateValue != null) { request.StateValue = cmdletContext.StateValue; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }
/// <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 on AmazonCloudWatchClient.</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> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndSetAlarmState /// operation.</returns> public IAsyncResult BeginSetAlarmState(SetAlarmStateRequest request, AsyncCallback callback, object state) { var marshaller = new SetAlarmStateRequestMarshaller(); var unmarshaller = SetAlarmStateResponseUnmarshaller.Instance; return BeginInvoke<SetAlarmStateRequest>(request, marshaller, unmarshaller, callback, state); }
/// <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 SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest request) { var task = SetAlarmStateAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <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 async Task<SetAlarmStateResponse> SetAlarmStateAsync(SetAlarmStateRequest setAlarmStateRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new SetAlarmStateRequestMarshaller(); var unmarshaller = SetAlarmStateResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, SetAlarmStateRequest, SetAlarmStateResponse>(setAlarmStateRequest, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
private Amazon.CloudWatch.Model.SetAlarmStateResponse CallAWSServiceOperation(IAmazonCloudWatch client, Amazon.CloudWatch.Model.SetAlarmStateRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudWatch", "SetAlarmState"); try { #if DESKTOP return(client.SetAlarmState(request)); #elif CORECLR return(client.SetAlarmStateAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
IAsyncResult asyncResult = invokeDeleteAlarms(deleteAlarmsRequest, null, null, true); return EndDeleteAlarms(asyncResult); } /// <summary> /// Initiates the asynchronous execution of the DeleteAlarms operation.
/// /// <param name="asyncResult">The IAsyncResult returned by the call to BeginDescribeAlarmHistory.</param> /// /// <returns>Returns a DescribeAlarmHistoryResult from AmazonCloudWatch.</returns> public DescribeAlarmHistoryResponse EndDescribeAlarmHistory(IAsyncResult asyncResult) { return endOperation<DescribeAlarmHistoryResponse>(asyncResult); } IAsyncResult invokeDescribeAlarmHistory(DescribeAlarmHistoryRequest describeAlarmHistoryRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new DescribeAlarmHistoryRequestMarshaller().Marshall(describeAlarmHistoryRequest); var unmarshaller = DescribeAlarmHistoryResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result;
/// <seealso cref="Amazon.CloudWatch.AmazonCloudWatch.ListMetrics"/> /// </summary> /// /// <param name="asyncResult">The IAsyncResult returned by the call to BeginListMetrics.</param> /// /// <returns>Returns a ListMetricsResult from AmazonCloudWatch.</returns> public ListMetricsResponse EndListMetrics(IAsyncResult asyncResult) { return endOperation<ListMetricsResponse>(asyncResult); } IAsyncResult invokeListMetrics(ListMetricsRequest listMetricsRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new ListMetricsRequestMarshaller().Marshall(listMetricsRequest);
internal SetAlarmStateResponse SetAlarmState(SetAlarmStateRequest request) { var task = SetAlarmStateAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <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); }
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 }