createConnection method

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

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

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

Parameter authParameters : A CreateConnectionAuthRequestParameters object that contains the authorization parameters to use to authorize with the endpoint.

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.

Implementation

Future<CreateConnectionResponse> createConnection({
  required CreateConnectionAuthRequestParameters authParameters,
  required ConnectionAuthorizationType authorizationType,
  required String name,
  String? description,
}) 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,
    },
  );

  return CreateConnectionResponse.fromJson(jsonResponse.body);
}