associateRepository method

Future<AssociateRepositoryResponse> associateRepository({
  1. required Repository repository,
  2. String? clientRequestToken,
  3. Map<String, String>? tags,
})

Use to associate an AWS CodeCommit repository or a repostory managed by AWS CodeStar Connections with Amazon CodeGuru Reviewer. When you associate a repository, CodeGuru Reviewer reviews source code changes in the repository's pull requests and provides automatic recommendations. You can view recommendations using the CodeGuru Reviewer console. For more information, see Recommendations in Amazon CodeGuru Reviewer in the Amazon CodeGuru Reviewer User Guide.

If you associate a CodeCommit repository, it must be in the same AWS Region and AWS account where its CodeGuru Reviewer code reviews are configured.

Bitbucket and GitHub Enterprise Server repositories are managed by AWS CodeStar Connections to connect to CodeGuru Reviewer. For more information, see Connect to a repository source provider in the Amazon CodeGuru Reviewer User Guide.

May throw InternalServerException. May throw ValidationException. May throw AccessDeniedException. May throw ConflictException. May throw ThrottlingException.

Parameter repository : The repository to associate.

Parameter clientRequestToken : Amazon CodeGuru Reviewer uses this value to prevent the accidental creation of duplicate repository associations if there are failures and retries.

Parameter tags : An array of key-value pairs used to tag an associated repository. A tag is a custom attribute label with two parts:

  • A tag key (for example, CostCenter, Environment, Project, or Secret). Tag keys are case sensitive.
  • An optional field known as a tag value (for example, 111122223333, Production, or a team name). Omitting the tag value is the same as using an empty string. Like tag keys, tag values are case sensitive.

Implementation

Future<AssociateRepositoryResponse> associateRepository({
  required Repository repository,
  String? clientRequestToken,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(repository, 'repository');
  _s.validateStringLength(
    'clientRequestToken',
    clientRequestToken,
    1,
    64,
  );
  final $payload = <String, dynamic>{
    'Repository': repository,
    'ClientRequestToken': clientRequestToken ?? _s.generateIdempotencyToken(),
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/associations',
    exceptionFnMap: _exceptionFns,
  );
  return AssociateRepositoryResponse.fromJson(response);
}