importSourceCredentials method

Future<ImportSourceCredentialsOutput> importSourceCredentials({
  1. required AuthType authType,
  2. required ServerType serverType,
  3. required String token,
  4. bool? shouldOverwrite,
  5. String? username,
})

Imports the source repository credentials for an AWS CodeBuild project that has its source code stored in a GitHub, GitHub Enterprise, or Bitbucket repository.

May throw InvalidInputException. May throw AccountLimitExceededException. May throw ResourceAlreadyExistsException.

Parameter authType : The type of authentication used to connect to a GitHub, GitHub Enterprise, or Bitbucket repository. An OAUTH connection is not supported by the API and must be created using the AWS CodeBuild console.

Parameter serverType : The source provider used for this project.

Parameter token : For GitHub or GitHub Enterprise, this is the personal access token. For Bitbucket, this is the app password.

Parameter shouldOverwrite : Set to false to prevent overwriting the repository source credentials. Set to true to overwrite the repository source credentials. The default value is true.

Parameter username : The Bitbucket username when the authType is BASIC_AUTH. This parameter is not valid for other types of source providers or connections.

Implementation

Future<ImportSourceCredentialsOutput> importSourceCredentials({
  required AuthType authType,
  required ServerType serverType,
  required String token,
  bool? shouldOverwrite,
  String? username,
}) async {
  ArgumentError.checkNotNull(authType, 'authType');
  ArgumentError.checkNotNull(serverType, 'serverType');
  ArgumentError.checkNotNull(token, 'token');
  _s.validateStringLength(
    'token',
    token,
    1,
    1152921504606846976,
    isRequired: true,
  );
  _s.validateStringLength(
    'username',
    username,
    1,
    1152921504606846976,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeBuild_20161006.ImportSourceCredentials'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'authType': authType.toValue(),
      'serverType': serverType.toValue(),
      'token': token,
      if (shouldOverwrite != null) 'shouldOverwrite': shouldOverwrite,
      if (username != null) 'username': username,
    },
  );

  return ImportSourceCredentialsOutput.fromJson(jsonResponse.body);
}