createEndpoint method

Future<CreateEndpointResponse> createEndpoint({
  1. required List<EndpointEventBus> eventBuses,
  2. required String name,
  3. required RoutingConfig routingConfig,
  4. String? description,
  5. ReplicationConfig? replicationConfig,
  6. String? roleArn,
})

Creates a global endpoint. Global endpoints improve your application's availability by making it regional-fault tolerant. To do this, you define a primary and secondary Region with event buses in each Region. You also create a Amazon Route 53 health check that will tell EventBridge to route events to the secondary Region when an "unhealthy" state is encountered and events will be routed back to the primary Region when the health check reports a "healthy" state.

May throw InternalException. May throw LimitExceededException. May throw ResourceAlreadyExistsException.

Parameter eventBuses : Define the event buses used.

Parameter name : The name of the global endpoint. For example, "Name":"us-east-2-custom_bus_A-endpoint".

Parameter routingConfig : Configure the routing policy, including the health check and secondary Region..

Parameter description : A description of the global endpoint.

Parameter replicationConfig : Enable or disable event replication. The default state is ENABLED which means you must supply a RoleArn. If you don't have a RoleArn or you don't want event replication enabled, set the state to DISABLED.

Parameter roleArn : The ARN of the role used for replication.

Implementation

Future<CreateEndpointResponse> createEndpoint({
  required List<EndpointEventBus> eventBuses,
  required String name,
  required RoutingConfig routingConfig,
  String? description,
  ReplicationConfig? replicationConfig,
  String? roleArn,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSEvents.CreateEndpoint'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'EventBuses': eventBuses,
      'Name': name,
      'RoutingConfig': routingConfig,
      if (description != null) 'Description': description,
      if (replicationConfig != null) 'ReplicationConfig': replicationConfig,
      if (roleArn != null) 'RoleArn': roleArn,
    },
  );

  return CreateEndpointResponse.fromJson(jsonResponse.body);
}