createConnection method

Future<CreateConnectionOutput> createConnection({
  1. required String connectionName,
  2. String? hostArn,
  3. ProviderType? providerType,
  4. List<Tag>? tags,
})

Creates a connection that can then be given to other AWS services like CodePipeline so that it can access third-party code repositories. The connection is in pending status until the third-party connection handshake is completed from the console.

May throw LimitExceededException. May throw ResourceNotFoundException. May throw ResourceUnavailableException.

Parameter connectionName : The name of the connection to be created. The name must be unique in the calling AWS account.

Parameter hostArn : The Amazon Resource Name (ARN) of the host associated with the connection to be created.

Parameter providerType : The name of the external provider where your third-party code repository is configured.

Parameter tags : The key-value pair to use when tagging the resource.

Implementation

Future<CreateConnectionOutput> createConnection({
  required String connectionName,
  String? hostArn,
  ProviderType? providerType,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(connectionName, 'connectionName');
  _s.validateStringLength(
    'connectionName',
    connectionName,
    1,
    32,
    isRequired: true,
  );
  _s.validateStringLength(
    'hostArn',
    hostArn,
    0,
    256,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target':
        'com.amazonaws.codestar.connections.CodeStar_connections_20191201.CreateConnection'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ConnectionName': connectionName,
      if (hostArn != null) 'HostArn': hostArn,
      if (providerType != null) 'ProviderType': providerType.toValue(),
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateConnectionOutput.fromJson(jsonResponse.body);
}