associate_repository

associate_repository(**kwargs)

Use to associate an Amazon Web Services CodeCommit repository or a repository managed by Amazon Web Services 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 or S3 repository, it must be in the same Amazon Web Services Region and Amazon Web Services account where its CodeGuru Reviewer code reviews are configured.

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

Note

You cannot use the CodeGuru Reviewer SDK or the Amazon Web Services CLI to associate a GitHub repository with Amazon CodeGuru Reviewer. To associate a GitHub repository, use the console. For more information, see Getting started with CodeGuru Reviewer in the CodeGuru Reviewer User Guide.

See also: AWS API Documentation

Request Syntax

response = client.associate_repository(
    Repository={
        'CodeCommit': {
            'Name': 'string'
        },
        'Bitbucket': {
            'Name': 'string',
            'ConnectionArn': 'string',
            'Owner': 'string'
        },
        'GitHubEnterpriseServer': {
            'Name': 'string',
            'ConnectionArn': 'string',
            'Owner': 'string'
        },
        'S3Bucket': {
            'Name': 'string',
            'BucketName': 'string'
        }
    },
    ClientRequestToken='string',
    Tags={
        'string': 'string'
    },
    KMSKeyDetails={
        'KMSKeyId': 'string',
        'EncryptionOption': 'AWS_OWNED_CMK'|'CUSTOMER_MANAGED_CMK'
    }
)
Parameters
  • Repository (dict) --

    [REQUIRED]

    The repository to associate.

    • CodeCommit (dict) --

      Information about an Amazon Web Services CodeCommit repository.

      • Name (string) -- [REQUIRED]

        The name of the Amazon Web Services CodeCommit repository. For more information, see repositoryName in the Amazon Web Services CodeCommit API Reference .

    • Bitbucket (dict) --

      Information about a Bitbucket repository.

      • Name (string) -- [REQUIRED]

        The name of the third party source repository.

      • ConnectionArn (string) -- [REQUIRED]

        The Amazon Resource Name (ARN) of an Amazon Web Services CodeStar Connections connection. Its format is arn:aws:codestar-connections:region-id:aws-account_id:connection/connection-id . For more information, see Connection in the Amazon Web Services CodeStar Connections API Reference .

      • Owner (string) -- [REQUIRED]

        The owner of the repository. For a GitHub, GitHub Enterprise, or Bitbucket repository, this is the username for the account that owns the repository. For an S3 repository, this can be the username or Amazon Web Services account ID

    • GitHubEnterpriseServer (dict) --

      Information about a GitHub Enterprise Server repository.

      • Name (string) -- [REQUIRED]

        The name of the third party source repository.

      • ConnectionArn (string) -- [REQUIRED]

        The Amazon Resource Name (ARN) of an Amazon Web Services CodeStar Connections connection. Its format is arn:aws:codestar-connections:region-id:aws-account_id:connection/connection-id . For more information, see Connection in the Amazon Web Services CodeStar Connections API Reference .

      • Owner (string) -- [REQUIRED]

        The owner of the repository. For a GitHub, GitHub Enterprise, or Bitbucket repository, this is the username for the account that owns the repository. For an S3 repository, this can be the username or Amazon Web Services account ID

    • S3Bucket (dict) --

      Information about a repository in an S3 bucket.

      • Name (string) -- [REQUIRED]

        The name of the repository in the S3 bucket.

      • BucketName (string) -- [REQUIRED]

        The name of the S3 bucket used for associating a new S3 repository. It must begin with codeguru-reviewer- .

  • ClientRequestToken (string) --

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

    This field is autopopulated if not provided.

  • Tags (dict) --

    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.
    • (string) --
      • (string) --
  • KMSKeyDetails (dict) --

    A KMSKeyDetails object that contains:

    • The encryption option for this repository association. It is either owned by Amazon Web Services Key Management Service (KMS) ( AWS_OWNED_CMK ) or customer managed ( CUSTOMER_MANAGED_CMK ).
    • The ID of the Amazon Web Services KMS key that is associated with this repository association.
    • KMSKeyId (string) --

      The ID of the Amazon Web Services KMS key that is associated with a repository association.

    • EncryptionOption (string) --

      The encryption option for a repository association. It is either owned by Amazon Web Services Key Management Service (KMS) ( AWS_OWNED_CMK ) or customer managed ( CUSTOMER_MANAGED_CMK ).

Return type

dict

Returns

Response Syntax

{
    'RepositoryAssociation': {
        'AssociationId': 'string',
        'AssociationArn': 'string',
        'ConnectionArn': 'string',
        'Name': 'string',
        'Owner': 'string',
        'ProviderType': 'CodeCommit'|'GitHub'|'Bitbucket'|'GitHubEnterpriseServer'|'S3Bucket',
        'State': 'Associated'|'Associating'|'Failed'|'Disassociating'|'Disassociated',
        'StateReason': 'string',
        'LastUpdatedTimeStamp': datetime(2015, 1, 1),
        'CreatedTimeStamp': datetime(2015, 1, 1),
        'KMSKeyDetails': {
            'KMSKeyId': 'string',
            'EncryptionOption': 'AWS_OWNED_CMK'|'CUSTOMER_MANAGED_CMK'
        },
        'S3RepositoryDetails': {
            'BucketName': 'string',
            'CodeArtifacts': {
                'SourceCodeArtifactsObjectKey': 'string',
                'BuildArtifactsObjectKey': 'string'
            }
        }
    },
    'Tags': {
        'string': 'string'
    }
}

Response Structure

  • (dict) --

    • RepositoryAssociation (dict) --

      Information about the repository association.

      • AssociationId (string) --

        The ID of the repository association.

      • AssociationArn (string) --

        The Amazon Resource Name (ARN) identifying the repository association.

      • ConnectionArn (string) --

        The Amazon Resource Name (ARN) of an Amazon Web Services CodeStar Connections connection. Its format is arn:aws:codestar-connections:region-id:aws-account_id:connection/connection-id . For more information, see Connection in the Amazon Web Services CodeStar Connections API Reference .

      • Name (string) --

        The name of the repository.

      • Owner (string) --

        The owner of the repository. For an Amazon Web Services CodeCommit repository, this is the Amazon Web Services account ID of the account that owns the repository. For a GitHub, GitHub Enterprise Server, or Bitbucket repository, this is the username for the account that owns the repository. For an S3 repository, it can be the username or Amazon Web Services account ID.

      • ProviderType (string) --

        The provider type of the repository association.

      • State (string) --

        The state of the repository association.

        The valid repository association states are:

        • Associated : The repository association is complete.

        • Associating : CodeGuru Reviewer is:

          • Setting up pull request notifications. This is required for pull requests to trigger a CodeGuru Reviewer review.

          Note

          If your repository ProviderType is GitHub , GitHub Enterprise Server , or Bitbucket , CodeGuru Reviewer creates webhooks in your repository to trigger CodeGuru Reviewer reviews. If you delete these webhooks, reviews of code in your repository cannot be triggered.

          • Setting up source code access. This is required for CodeGuru Reviewer to securely clone code in your repository.
        • Failed : The repository failed to associate or disassociate.

        • Disassociating : CodeGuru Reviewer is removing the repository's pull request notifications and source code access.

        • Disassociated : CodeGuru Reviewer successfully disassociated the repository. You can create a new association with this repository if you want to review source code in it later. You can control access to code reviews created in anassociated repository with tags after it has been disassociated. For more information, see Using tags to control access to associated repositories in the Amazon CodeGuru Reviewer User Guide .

      • StateReason (string) --

        A description of why the repository association is in the current state.

      • LastUpdatedTimeStamp (datetime) --

        The time, in milliseconds since the epoch, when the repository association was last updated.

      • CreatedTimeStamp (datetime) --

        The time, in milliseconds since the epoch, when the repository association was created.

      • KMSKeyDetails (dict) --

        A KMSKeyDetails object that contains:

        • The encryption option for this repository association. It is either owned by Amazon Web Services Key Management Service (KMS) ( AWS_OWNED_CMK ) or customer managed ( CUSTOMER_MANAGED_CMK ).
        • The ID of the Amazon Web Services KMS key that is associated with this repository association.
        • KMSKeyId (string) --

          The ID of the Amazon Web Services KMS key that is associated with a repository association.

        • EncryptionOption (string) --

          The encryption option for a repository association. It is either owned by Amazon Web Services Key Management Service (KMS) ( AWS_OWNED_CMK ) or customer managed ( CUSTOMER_MANAGED_CMK ).

      • S3RepositoryDetails (dict) --

        Specifies the name of an S3 bucket and a CodeArtifacts object that contains the S3 object keys for a source code .zip file and for a build artifacts .zip file that contains .jar or .class files.

        • BucketName (string) --

          The name of the S3 bucket used for associating a new S3 repository. It must begin with codeguru-reviewer- .

        • CodeArtifacts (dict) --

          A CodeArtifacts object. The CodeArtifacts object includes the S3 object key for a source code .zip file and for a build artifacts .zip file that contains .jar or .class files.

          • SourceCodeArtifactsObjectKey (string) --

            The S3 object key for a source code .zip file. This is required for all code reviews.

          • BuildArtifactsObjectKey (string) --

            The S3 object key for a build artifacts .zip file that contains .jar or .class files. This is required for a code review with security analysis. For more information, see Create code reviews with GitHub Actions in the Amazon CodeGuru Reviewer User Guide .

    • Tags (dict) --

      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.
      • (string) --
        • (string) --

Exceptions

  • CodeGuruReviewer.Client.exceptions.InternalServerException
  • CodeGuruReviewer.Client.exceptions.ValidationException
  • CodeGuruReviewer.Client.exceptions.AccessDeniedException
  • CodeGuruReviewer.Client.exceptions.ConflictException
  • CodeGuruReviewer.Client.exceptions.ThrottlingException