createConnection method

Future<CreateConnectionResponse> createConnection({
  1. required CreateConnectionAuthRequestParameters authParameters,
  2. required ConnectionAuthorizationType authorizationType,
  3. required String name,
  4. String? description,
  5. ConnectivityResourceParameters? invocationConnectivityParameters,
  6. String? kmsKeyIdentifier,
})

Creates a connection. A connection defines the authorization type and credentials to use for authorization with an API destination HTTP endpoint.

For more information, see Connections for endpoint targets in the Amazon EventBridge User Guide.

May throw AccessDeniedException. May throw InternalException. May throw LimitExceededException. May throw ResourceAlreadyExistsException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter authParameters : The authorization parameters to use to authorize with the endpoint.

You must include only authorization parameters for the AuthorizationType you specify.

Parameter authorizationType : The type of authorization to use for the connection.

Parameter name : The name for the connection to create.

Parameter description : A description for the connection to create.

Parameter invocationConnectivityParameters : For connections to private APIs, the parameters to use for invoking the API.

For more information, see Connecting to private APIs in the Amazon EventBridge User Guide .

Parameter kmsKeyIdentifier : The identifier of the KMS customer managed key for EventBridge to use, if you choose to use a customer managed key to encrypt this connection. The identifier can be the key Amazon Resource Name (ARN), KeyId, key alias, or key alias ARN.

If you do not specify a customer managed key identifier, EventBridge uses an Amazon Web Services owned key to encrypt the connection.

For more information, see Identify and view keys in the Key Management Service Developer Guide.

Implementation

Future<CreateConnectionResponse> createConnection({
  required CreateConnectionAuthRequestParameters authParameters,
  required ConnectionAuthorizationType authorizationType,
  required String name,
  String? description,
  ConnectivityResourceParameters? invocationConnectivityParameters,
  String? kmsKeyIdentifier,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSEvents.CreateConnection'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'AuthParameters': authParameters,
      'AuthorizationType': authorizationType.value,
      'Name': name,
      if (description != null) 'Description': description,
      if (invocationConnectivityParameters != null)
        'InvocationConnectivityParameters': invocationConnectivityParameters,
      if (kmsKeyIdentifier != null) 'KmsKeyIdentifier': kmsKeyIdentifier,
    },
  );

  return CreateConnectionResponse.fromJson(jsonResponse.body);
}