removeTargets method

Future<RemoveTargetsResponse> removeTargets({
  1. required List<String> ids,
  2. required String rule,
  3. String? eventBusName,
  4. bool? force,
})

Removes the specified targets from the specified rule. When the rule is triggered, those targets are no longer be invoked.

When you remove a target, when the associated rule triggers, removed targets might continue to be invoked. Allow a short period of time for changes to take effect.

This action can partially fail if too many requests are made at the same time. If that happens, FailedEntryCount is non-zero in the response and each entry in FailedEntries provides the ID of the failed target and the error code.

May throw ResourceNotFoundException. May throw ConcurrentModificationException. May throw ManagedRuleException. May throw InternalException.

Parameter ids : The IDs of the targets to remove from the rule.

Parameter rule : The name of the rule.

Parameter eventBusName : The name or ARN of the event bus associated with the rule. If you omit this, the default event bus is used.

Parameter force : If this is a managed rule, created by an AWS service on your behalf, you must specify Force as True to remove targets. This parameter is ignored for rules that are not managed rules. You can check whether a rule is a managed rule by using DescribeRule or ListRules and checking the ManagedBy field of the response.

Implementation

Future<RemoveTargetsResponse> removeTargets({
  required List<String> ids,
  required String rule,
  String? eventBusName,
  bool? force,
}) async {
  ArgumentError.checkNotNull(ids, 'ids');
  ArgumentError.checkNotNull(rule, 'rule');
  _s.validateStringLength(
    'rule',
    rule,
    1,
    64,
    isRequired: true,
  );
  _s.validateStringLength(
    'eventBusName',
    eventBusName,
    1,
    1600,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSEvents.RemoveTargets'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Ids': ids,
      'Rule': rule,
      if (eventBusName != null) 'EventBusName': eventBusName,
      if (force != null) 'Force': force,
    },
  );

  return RemoveTargetsResponse.fromJson(jsonResponse.body);
}