createEventBus method

Future<CreateEventBusResponse> createEventBus({
  1. required String name,
  2. String? eventSourceName,
  3. List<Tag>? tags,
})

Creates a new event bus within your account. This can be a custom event bus which you can use to receive events from your custom applications and services, or it can be a partner event bus which can be matched to a partner event source.

May throw ResourceAlreadyExistsException. May throw ResourceNotFoundException. May throw InvalidStateException. May throw InternalException. May throw ConcurrentModificationException. May throw LimitExceededException. May throw OperationDisabledException.

Parameter name : The name of the new event bus.

Event bus names cannot contain the / character. You can't use the name default for a custom event bus, as this name is already used for your account's default event bus.

If this is a partner event bus, the name must exactly match the name of the partner event source that this event bus is matched to.

Parameter eventSourceName : If you are creating a partner event bus, this specifies the partner event source that the new event bus will be matched with.

Parameter tags : Tags to associate with the event bus.

Implementation

Future<CreateEventBusResponse> createEventBus({
  required String name,
  String? eventSourceName,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    256,
    isRequired: true,
  );
  _s.validateStringLength(
    'eventSourceName',
    eventSourceName,
    1,
    256,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSEvents.CreateEventBus'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      if (eventSourceName != null) 'EventSourceName': eventSourceName,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateEventBusResponse.fromJson(jsonResponse.body);
}