createEventDestination method

Future<CreateEventDestinationResult> createEventDestination({
  1. required String configurationSetName,
  2. required String eventDestinationName,
  3. required List<EventType> matchingEventTypes,
  4. String? clientToken,
  5. CloudWatchLogsDestination? cloudWatchLogsDestination,
  6. KinesisFirehoseDestination? kinesisFirehoseDestination,
  7. SnsDestination? snsDestination,
})

Creates a new event destination in a configuration set.

An event destination is a location where you send message events. The event options are Amazon CloudWatch, Amazon Data Firehose, or Amazon SNS. For example, when a message is delivered successfully, you can send information about that event to an event destination, or send notifications to endpoints that are subscribed to an Amazon SNS topic.

You can only create one event destination at a time. You must provide a value for a single event destination using either CloudWatchLogsDestination, KinesisFirehoseDestination or SnsDestination. If an event destination isn't provided then an exception is returned.

Each configuration set can contain between 0 and 5 event destinations. Each event destination can contain a reference to a single destination, such as a CloudWatch or Firehose destination.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter configurationSetName : Either the name of the configuration set or the configuration set ARN to apply event logging to. The ConfigurateSetName and ConfigurationSetArn can be found using the DescribeConfigurationSets action.

Parameter eventDestinationName : The name that identifies the event destination.

Parameter matchingEventTypes : An array of event types that determine which events to log. If "ALL" is used, then End User Messaging SMS logs every event type.

Parameter clientToken : Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you don't specify a client token, a randomly generated token is used for the request to ensure idempotency.

Parameter cloudWatchLogsDestination : An object that contains information about an event destination for logging to Amazon CloudWatch Logs.

Parameter kinesisFirehoseDestination : An object that contains information about an event destination for logging to Amazon Data Firehose.

Parameter snsDestination : An object that contains information about an event destination for logging to Amazon SNS.

Implementation

Future<CreateEventDestinationResult> createEventDestination({
  required String configurationSetName,
  required String eventDestinationName,
  required List<EventType> matchingEventTypes,
  String? clientToken,
  CloudWatchLogsDestination? cloudWatchLogsDestination,
  KinesisFirehoseDestination? kinesisFirehoseDestination,
  SnsDestination? snsDestination,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'PinpointSMSVoiceV2.CreateEventDestination'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ConfigurationSetName': configurationSetName,
      'EventDestinationName': eventDestinationName,
      'MatchingEventTypes': matchingEventTypes.map((e) => e.value).toList(),
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (cloudWatchLogsDestination != null)
        'CloudWatchLogsDestination': cloudWatchLogsDestination,
      if (kinesisFirehoseDestination != null)
        'KinesisFirehoseDestination': kinesisFirehoseDestination,
      if (snsDestination != null) 'SnsDestination': snsDestination,
    },
  );

  return CreateEventDestinationResult.fromJson(jsonResponse.body);
}