Amazon CodeGuru Reviewer

2020/09/01 - Amazon CodeGuru Reviewer - 1 new 2 updated api methods

Changes  Add support for repository analysis based code reviews

CreateCodeReview (new) Link ¶

Use to create a code review for a repository analysis.

See also: AWS API Documentation

Request Syntax

client.create_code_review(
    Name='string',
    RepositoryAssociationArn='string',
    Type={
        'RepositoryAnalysis': {
            'RepositoryHead': {
                'BranchName': 'string'
            }
        }
    },
    ClientRequestToken='string'
)
type Name

string

param Name

[REQUIRED]

The name of the code review. Each code review of the same code review type must have a unique name in your AWS account.

type RepositoryAssociationArn

string

param RepositoryAssociationArn

[REQUIRED]

The Amazon Resource Name (ARN) of the RepositoryAssociation object. You can retrieve this ARN by calling ListRepositories .

A code review can only be created on an associated repository. This is the ARN of the associated repository.

type Type

dict

param Type

[REQUIRED]

The type of code review to create. This is specified using a CodeReviewType object.

  • RepositoryAnalysis (dict) -- [REQUIRED]

    A code review that analyzes all code under a specified branch in an associated respository. The assocated repository is specified using its ARN in CreateCodeReview

    • RepositoryHead (dict) -- [REQUIRED]

      A SourceCodeType that specifies the tip of a branch in an associated repository.

      • BranchName (string) -- [REQUIRED]

        The name of the branch in an associated repository. The RepositoryHeadSourceCodeType specifies the tip of this branch.

type ClientRequestToken

string

param ClientRequestToken

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

This field is autopopulated if not provided.

rtype

dict

returns

Response Syntax

{
    'CodeReview': {
        'Name': 'string',
        'CodeReviewArn': 'string',
        'RepositoryName': 'string',
        'Owner': 'string',
        'ProviderType': 'CodeCommit'|'GitHub'|'Bitbucket'|'GitHubEnterpriseServer',
        'State': 'Completed'|'Pending'|'Failed'|'Deleting',
        'StateReason': 'string',
        'CreatedTimeStamp': datetime(2015, 1, 1),
        'LastUpdatedTimeStamp': datetime(2015, 1, 1),
        'Type': 'PullRequest'|'RepositoryAnalysis',
        'PullRequestId': 'string',
        'SourceCodeType': {
            'CommitDiff': {
                'SourceCommit': 'string',
                'DestinationCommit': 'string'
            },
            'RepositoryHead': {
                'BranchName': 'string'
            }
        },
        'Metrics': {
            'MeteredLinesOfCodeCount': 123,
            'FindingsCount': 123
        }
    }
}

Response Structure

  • (dict) --

    • CodeReview (dict) --

      Information about a code review.

      • Name (string) --

        The name of the code review.

      • CodeReviewArn (string) --

        The Amazon Resource Name (ARN) of the CodeReview object.

      • RepositoryName (string) --

        The name of the repository.

      • Owner (string) --

        The owner of the repository. For an AWS CodeCommit repository, this is the AWS 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.

      • ProviderType (string) --

        The type of repository that contains the reviewed code (for example, GitHub or Bitbucket).

      • State (string) --

        The valid code review states are:

        • Completed : The code review is complete.

        • Pending : The code review started and has not completed or failed.

        • Failed : The code review failed.

        • Deleting : The code review is being deleted.

      • StateReason (string) --

        The reason for the state of the code review.

      • CreatedTimeStamp (datetime) --

        The time, in milliseconds since the epoch, when the code review was created.

      • LastUpdatedTimeStamp (datetime) --

        The time, in milliseconds since the epoch, when the code review was last updated.

      • Type (string) --

        The type of code review.

      • PullRequestId (string) --

        The pull request ID for the code review.

      • SourceCodeType (dict) --

        The type of the source code for the code review.

        • CommitDiff (dict) --

          A SourceCodeType that specifies a commit diff created by a pull request on an associated repository.

          • SourceCommit (string) --

            The SHA of the source commit used to generate a commit diff.

          • DestinationCommit (string) --

            The SHA of the destination commit used to generate a commit diff.

        • RepositoryHead (dict) --

          A SourceCodeType that specifies the tip of a branch in an associated repository.

          • BranchName (string) --

            The name of the branch in an associated repository. The RepositoryHeadSourceCodeType specifies the tip of this branch.

      • Metrics (dict) --

        The statistics from the code review.

        • MeteredLinesOfCodeCount (integer) --

          Lines of code metered in the code review. For the initial code review pull request and all subsequent revisions, this includes all lines of code in the files added to the pull request. In subsequent revisions, for files that already existed in the pull request, this includes only the changed lines of code. In both cases, this does not include non-code lines such as comments and import statements. For example, if you submit a pull request containing 5 files, each with 500 lines of code, and in a subsequent revision you added a new file with 200 lines of code, and also modified a total of 25 lines across the initial 5 files, MeteredLinesOfCodeCount includes the first 5 files (5 * 500 = 2,500 lines), the new file (200 lines) and the 25 changed lines of code for a total of 2,725 lines of code.

        • FindingsCount (integer) --

          Total number of recommendations found in the code review.

DescribeCodeReview (updated) Link ¶
Changes (response)
{'CodeReview': {'SourceCodeType': {'RepositoryHead': {'BranchName': 'string'}},
                'Type': {'RepositoryAnalysis'}}}

Returns the metadata associated with the code review along with its status.

See also: AWS API Documentation

Request Syntax

client.describe_code_review(
    CodeReviewArn='string'
)
type CodeReviewArn

string

param CodeReviewArn

[REQUIRED]

The Amazon Resource Name (ARN) of the CodeReview object.

rtype

dict

returns

Response Syntax

{
    'CodeReview': {
        'Name': 'string',
        'CodeReviewArn': 'string',
        'RepositoryName': 'string',
        'Owner': 'string',
        'ProviderType': 'CodeCommit'|'GitHub'|'Bitbucket'|'GitHubEnterpriseServer',
        'State': 'Completed'|'Pending'|'Failed'|'Deleting',
        'StateReason': 'string',
        'CreatedTimeStamp': datetime(2015, 1, 1),
        'LastUpdatedTimeStamp': datetime(2015, 1, 1),
        'Type': 'PullRequest'|'RepositoryAnalysis',
        'PullRequestId': 'string',
        'SourceCodeType': {
            'CommitDiff': {
                'SourceCommit': 'string',
                'DestinationCommit': 'string'
            },
            'RepositoryHead': {
                'BranchName': 'string'
            }
        },
        'Metrics': {
            'MeteredLinesOfCodeCount': 123,
            'FindingsCount': 123
        }
    }
}

Response Structure

  • (dict) --

    • CodeReview (dict) --

      Information about the code review.

      • Name (string) --

        The name of the code review.

      • CodeReviewArn (string) --

        The Amazon Resource Name (ARN) of the CodeReview object.

      • RepositoryName (string) --

        The name of the repository.

      • Owner (string) --

        The owner of the repository. For an AWS CodeCommit repository, this is the AWS 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.

      • ProviderType (string) --

        The type of repository that contains the reviewed code (for example, GitHub or Bitbucket).

      • State (string) --

        The valid code review states are:

        • Completed : The code review is complete.

        • Pending : The code review started and has not completed or failed.

        • Failed : The code review failed.

        • Deleting : The code review is being deleted.

      • StateReason (string) --

        The reason for the state of the code review.

      • CreatedTimeStamp (datetime) --

        The time, in milliseconds since the epoch, when the code review was created.

      • LastUpdatedTimeStamp (datetime) --

        The time, in milliseconds since the epoch, when the code review was last updated.

      • Type (string) --

        The type of code review.

      • PullRequestId (string) --

        The pull request ID for the code review.

      • SourceCodeType (dict) --

        The type of the source code for the code review.

        • CommitDiff (dict) --

          A SourceCodeType that specifies a commit diff created by a pull request on an associated repository.

          • SourceCommit (string) --

            The SHA of the source commit used to generate a commit diff.

          • DestinationCommit (string) --

            The SHA of the destination commit used to generate a commit diff.

        • RepositoryHead (dict) --

          A SourceCodeType that specifies the tip of a branch in an associated repository.

          • BranchName (string) --

            The name of the branch in an associated repository. The RepositoryHeadSourceCodeType specifies the tip of this branch.

      • Metrics (dict) --

        The statistics from the code review.

        • MeteredLinesOfCodeCount (integer) --

          Lines of code metered in the code review. For the initial code review pull request and all subsequent revisions, this includes all lines of code in the files added to the pull request. In subsequent revisions, for files that already existed in the pull request, this includes only the changed lines of code. In both cases, this does not include non-code lines such as comments and import statements. For example, if you submit a pull request containing 5 files, each with 500 lines of code, and in a subsequent revision you added a new file with 200 lines of code, and also modified a total of 25 lines across the initial 5 files, MeteredLinesOfCodeCount includes the first 5 files (5 * 500 = 2,500 lines), the new file (200 lines) and the 25 changed lines of code for a total of 2,725 lines of code.

        • FindingsCount (integer) --

          Total number of recommendations found in the code review.

ListCodeReviews (updated) Link ¶
Changes (request, response)
Request
{'Type': {'RepositoryAnalysis'}}
Response
{'CodeReviewSummaries': {'Type': {'RepositoryAnalysis'}}}

Lists all the code reviews that the customer has created in the past 90 days.

See also: AWS API Documentation

Request Syntax

client.list_code_reviews(
    ProviderTypes=[
        'CodeCommit'|'GitHub'|'Bitbucket'|'GitHubEnterpriseServer',
    ],
    States=[
        'Completed'|'Pending'|'Failed'|'Deleting',
    ],
    RepositoryNames=[
        'string',
    ],
    Type='PullRequest'|'RepositoryAnalysis',
    MaxResults=123,
    NextToken='string'
)
type ProviderTypes

list

param ProviderTypes

List of provider types for filtering that needs to be applied before displaying the result. For example, providerTypes=[GitHub] lists code reviews from GitHub.

  • (string) --

type States

list

param States

List of states for filtering that needs to be applied before displaying the result. For example, states=[Pending] lists code reviews in the Pending state.

The valid code review states are:

  • Completed : The code review is complete.

  • Pending : The code review started and has not completed or failed.

  • Failed : The code review failed.

  • Deleting : The code review is being deleted.

  • (string) --

type RepositoryNames

list

param RepositoryNames

List of repository names for filtering that needs to be applied before displaying the result.

  • (string) --

type Type

string

param Type

[REQUIRED]

The type of code reviews to list in the response.

type MaxResults

integer

param MaxResults

The maximum number of results that are returned per call. The default is 100.

type NextToken

string

param NextToken

If nextToken is returned, there are more results available. The value of nextToken is a unique pagination token for each page. Make the call again using the returned token to retrieve the next page. Keep all other arguments unchanged.

rtype

dict

returns

Response Syntax

{
    'CodeReviewSummaries': [
        {
            'Name': 'string',
            'CodeReviewArn': 'string',
            'RepositoryName': 'string',
            'Owner': 'string',
            'ProviderType': 'CodeCommit'|'GitHub'|'Bitbucket'|'GitHubEnterpriseServer',
            'State': 'Completed'|'Pending'|'Failed'|'Deleting',
            'CreatedTimeStamp': datetime(2015, 1, 1),
            'LastUpdatedTimeStamp': datetime(2015, 1, 1),
            'Type': 'PullRequest'|'RepositoryAnalysis',
            'PullRequestId': 'string',
            'MetricsSummary': {
                'MeteredLinesOfCodeCount': 123,
                'FindingsCount': 123
            }
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • CodeReviewSummaries (list) --

      A list of code reviews that meet the criteria of the request.

      • (dict) --

        Information about the summary of the code review.

        • Name (string) --

          The name of the code review.

        • CodeReviewArn (string) --

          The Amazon Resource Name (ARN) of the CodeReview object.

        • RepositoryName (string) --

          The name of the repository.

        • Owner (string) --

          The owner of the repository. For an AWS CodeCommit repository, this is the AWS 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.

        • ProviderType (string) --

          The provider type of the repository association.

        • State (string) --

          The state of the code review.

          The valid code review states are:

          • Completed : The code review is complete.

          • Pending : The code review started and has not completed or failed.

          • Failed : The code review failed.

          • Deleting : The code review is being deleted.

        • CreatedTimeStamp (datetime) --

          The time, in milliseconds since the epoch, when the code review was created.

        • LastUpdatedTimeStamp (datetime) --

          The time, in milliseconds since the epoch, when the code review was last updated.

        • Type (string) --

          The type of the code review.

        • PullRequestId (string) --

          The pull request ID for the code review.

        • MetricsSummary (dict) --

          The statistics from the code review.

          • MeteredLinesOfCodeCount (integer) --

            Lines of code metered in the code review. For the initial code review pull request and all subsequent revisions, this includes all lines of code in the files added to the pull request. In subsequent revisions, for files that already existed in the pull request, this includes only the changed lines of code. In both cases, this does not include non-code lines such as comments and import statements. For example, if you submit a pull request containing 5 files, each with 500 lines of code, and in a subsequent revision you added a new file with 200 lines of code, and also modified a total of 25 lines across the initial 5 files, MeteredLinesOfCodeCount includes the first 5 files (5 * 500 = 2,500 lines), the new file (200 lines) and the 25 changed lines of code for a total of 2,725 lines of code.

          • FindingsCount (integer) --

            Total number of recommendations found in the code review.

    • NextToken (string) --

      Pagination token.