Container for the parameters to the PutTargets operation. Adds target(s) to a rule. Targets are the resources that can be invoked when a rule is triggered. For example, AWS Lambda functions, Amazon Kinesis streams, and built-in targets. Updates the target(s) if they are already associated with the role. In other words, if there is already a target with the given target ID, then the target associated with that ID is updated.

In order to be able to make API calls against the resources you own, Amazon CloudWatch Events needs the appropriate permissions. For AWS Lambda and Amazon SNS resources, CloudWatch Events relies on resource-based policies. For Amazon Kinesis streams, CloudWatch Events relies on IAM roles. For more information, see Permissions for Sending Events to Targets in the Amazon CloudWatch Developer Guide.

Input and InputPath are mutually-exclusive and optional parameters of a target. When a rule is triggered due to a matched event, if for a target:

  • Neither Input nor InputPath is specified, then the entire event is passed to the target in JSON form.
  • InputPath is specified in the form of JSONPath (e.g. $.detail), then only the part of the event specified in the path is passed to the target (e.g. only the detail part of the event is passed).
  • Input is specified in the form of a valid JSON, then the matched event is overridden with this constant.

Note: When you add targets to a rule, when the associated rule triggers, new or updated targets might not be immediately invoked. Please allow a short period of time for changes to take effect.

Наследование: AmazonCloudWatchEventsRequest
Пример #1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.CloudWatchEvents.Model.PutTargetsRequest();

            if (cmdletContext.EventBusName != null)
            {
                request.EventBusName = cmdletContext.EventBusName;
            }
            if (cmdletContext.Rule != null)
            {
                request.Rule = cmdletContext.Rule;
            }
            if (cmdletContext.Target != null)
            {
                request.Targets = cmdletContext.Target;
            }

            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);
        }
Пример #2
0
 private Amazon.CloudWatchEvents.Model.PutTargetsResponse CallAWSServiceOperation(IAmazonCloudWatchEvents client, Amazon.CloudWatchEvents.Model.PutTargetsRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudWatch Events", "PutTargets");
     try
     {
         #if DESKTOP
         return(client.PutTargets(request));
         #elif CORECLR
         return(client.PutTargetsAsync(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;
     }
 }
        /// <summary>
        /// Adds target(s) to a rule. Targets are the resources that can be invoked when a rule
        /// is triggered. For example, AWS Lambda functions, Amazon Kinesis streams, and built-in
        /// targets. Updates the target(s) if they are already associated with the role. In other
        /// words, if there is already a target with the given target ID, then the target associated
        /// with that ID is updated.
        /// 
        ///  
        /// <para>
        /// In order to be able to make API calls against the resources you own, Amazon CloudWatch
        /// Events needs the appropriate permissions. For AWS Lambda and Amazon SNS resources,
        /// CloudWatch Events relies on resource-based policies. For Amazon Kinesis streams, CloudWatch
        /// Events relies on IAM roles. For more information, see <a href="http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/EventsTargetPermissions.html">Permissions
        /// for Sending Events to Targets</a> in the <b><i>Amazon CloudWatch Developer Guide</i></b>.
        /// </para>
        ///  
        /// <para>
        /// <b>Input</b> and <b>InputPath</b> are mutually-exclusive and optional parameters of
        /// a target. When a rule is triggered due to a matched event, if for a target:
        /// </para>
        ///  <ul> <li>Neither <b>Input</b> nor <b>InputPath</b> is specified, then the entire
        /// event is passed to the target in JSON form.</li> <li><b>InputPath</b> is specified
        /// in the form of JSONPath (e.g. <b>$.detail</b>), then only the part of the event specified
        /// in the path is passed to the target (e.g. only the detail part of the event is passed).
        /// </li> <li><b>Input</b> is specified in the form of a valid JSON, then the matched
        /// event is overridden with this constant.</li> </ul> 
        /// <para>
        ///  <b>Note:</b> When you add targets to a rule, when the associated rule triggers, new
        /// or updated targets might not be immediately invoked. Please allow a short period of
        /// time for changes to take effect. 
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the PutTargets service method.</param>
        /// 
        /// <returns>The response from the PutTargets service method, as returned by CloudWatchEvents.</returns>
        /// <exception cref="Amazon.CloudWatchEvents.Model.ConcurrentModificationException">
        /// This exception occurs if there is concurrent modification on rule or target.
        /// </exception>
        /// <exception cref="Amazon.CloudWatchEvents.Model.InternalException">
        /// This exception occurs due to unexpected causes.
        /// </exception>
        /// <exception cref="Amazon.CloudWatchEvents.Model.LimitExceededException">
        /// This exception occurs if you try to create more rules or add more targets to a rule
        /// than allowed by default.
        /// </exception>
        /// <exception cref="Amazon.CloudWatchEvents.Model.ResourceNotFoundException">
        /// The rule does not exist.
        /// </exception>
        public PutTargetsResponse PutTargets(PutTargetsRequest request)
        {
            var marshaller = new PutTargetsRequestMarshaller();
            var unmarshaller = PutTargetsResponseUnmarshaller.Instance;

            return Invoke<PutTargetsRequest,PutTargetsResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the PutTargets operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutTargets operation on AmazonCloudWatchEventsClient.</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 EndPutTargets
        ///         operation.</returns>
        public IAsyncResult BeginPutTargets(PutTargetsRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new PutTargetsRequestMarshaller();
            var unmarshaller = PutTargetsResponseUnmarshaller.Instance;

            return BeginInvoke<PutTargetsRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the PutTargets operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutTargets 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<PutTargetsResponse> PutTargetsAsync(PutTargetsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PutTargetsRequestMarshaller();
            var unmarshaller = PutTargetsResponseUnmarshaller.Instance;

            return InvokeAsync<PutTargetsRequest,PutTargetsResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }