code_reviews
Creates, updates, deletes, gets or lists a code_reviews resource.
Overview
| Name | code_reviews |
| Type | Resource |
| Id | aws.codeguru_reviewer.code_reviews |
Fields
The following fields are returned by SELECT queries:
- list_code_reviews
- describe_code_review
| Name | Datatype | Description |
|---|---|---|
code_review_summaries | array | A list of code reviews that meet the criteria of the request. |
next_token | string | Pagination token. |
| Name | Datatype | Description |
|---|---|---|
analysis_types | array | The types of analysis performed during a repository analysis or a pull request review. You can specify either Security, CodeQuality, or both. |
association_arn | string | The Amazon Resource Name (ARN) of the RepositoryAssociation that contains the reviewed source code. You can retrieve associated repository ARNs by calling ListRepositoryAssociations. (pattern: <code>^arn:aws[^:\s]*:codeguru-reviewer:[^:\s]+:[\d]{12}:association:[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$</code>) |
code_review_arn | string | The Amazon Resource Name (ARN) of the CodeReview object. (pattern: <code>^arn:aws[^:\s]*:codeguru-reviewer:[^:\s]+:[\d]{12}:[a-z-]+:[\w-]+$</code>) |
config_file_state | string | The state of the aws-codeguru-reviewer.yml configuration file that allows the configuration of the CodeGuru Reviewer analysis. The file either exists, doesn't exist, or exists with errors at the root directory of your repository. (Present, Absent, PresentWithErrors) |
created_time_stamp | string (date-time) | The time, in milliseconds since the epoch, when the code review was created. |
last_updated_time_stamp | string (date-time) | The time, in milliseconds since the epoch, when the code review was last updated. |
metrics | object | The statistics from the code review. |
name | string | The name of the code review. (pattern: <code>^\S[\w.-]*$</code>) |
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. (pattern: <code>^\S(.*\S)?$</code>) |
provider_type | string | The type of repository that contains the reviewed code (for example, GitHub or Bitbucket). (CodeCommit, GitHub, Bitbucket, GitHubEnterpriseServer, S3Bucket) |
pull_request_id | string | The pull request ID for the code review. |
repository_name | string | The name of the repository. (pattern: <code>^\S[\w.-]*$</code>) |
source_code_type | object | Specifies the source code that is analyzed in a code review. |
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. (Completed, Pending, Failed, Deleting) |
state_reason | string | The reason for the state of the code review. |
type | string | The type of code review. (PullRequest, RepositoryAnalysis) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list_code_reviews | select | Type, region | ProviderTypes, States, RepositoryNames, MaxResults, NextToken | Lists all the code reviews that the customer has created in the past 90 days. |
describe_code_review | select | code_review_arn, region | Returns the metadata associated with the code review along with its status. | |
create_code_review | insert | region, Name, RepositoryAssociationArn, Type | Use to create a code review with a CodeReviewType of RepositoryAnalysis. This type of code review analyzes all code under a specified branch in an associated repository. PullRequest code reviews are automatically triggered by a pull request. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
Type | string | The type of code reviews to list in the response. |
code_review_arn | string | The Amazon Resource Name (ARN) of the CodeReview object. |
region | string | AWS region (default: us-east-1) |
MaxResults | integer | The maximum number of results that are returned per call. The default is 100. |
NextToken | string | 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. |
ProviderTypes | array | List of provider types for filtering that needs to be applied before displaying the result. For example, providerTypes=[GitHub] lists code reviews from GitHub. |
RepositoryNames | array | List of repository names for filtering that needs to be applied before displaying the result. |
States | array | 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. |
SELECT examples
- list_code_reviews
- describe_code_review
Lists all the code reviews that the customer has created in the past 90 days.
SELECT
code_review_summaries,
next_token
FROM aws.codeguru_reviewer.code_reviews
WHERE Type = '{{ Type }}' -- required
AND region = '{{ region }}' -- required
AND ProviderTypes = '{{ ProviderTypes }}'
AND States = '{{ States }}'
AND RepositoryNames = '{{ RepositoryNames }}'
AND MaxResults = '{{ MaxResults }}'
AND NextToken = '{{ NextToken }}'
;
Returns the metadata associated with the code review along with its status.
SELECT
analysis_types,
association_arn,
code_review_arn,
config_file_state,
created_time_stamp,
last_updated_time_stamp,
metrics,
name,
owner,
provider_type,
pull_request_id,
repository_name,
source_code_type,
state,
state_reason,
type
FROM aws.codeguru_reviewer.code_reviews
WHERE code_review_arn = '{{ code_review_arn }}' -- required
AND region = '{{ region }}' -- required
;
INSERT examples
- create_code_review
- Manifest
Use to create a code review with a CodeReviewType of RepositoryAnalysis. This type of code review analyzes all code under a specified branch in an associated repository. PullRequest code reviews are automatically triggered by a pull request.
INSERT INTO aws.codeguru_reviewer.code_reviews (
Name,
RepositoryAssociationArn,
Type,
ClientRequestToken,
region
)
SELECT
'{{ Name }}' /* required */,
'{{ RepositoryAssociationArn }}' /* required */,
'{{ Type }}' /* required */,
'{{ ClientRequestToken }}',
'{{ region }}'
RETURNING
code_review
;
# Description fields are for documentation purposes
- name: code_reviews
props:
- name: region
value: "{{ region }}"
description: Required parameter for the code_reviews resource.
- name: Name
value: "{{ Name }}"
- name: RepositoryAssociationArn
value: "{{ RepositoryAssociationArn }}"
- name: Type
description: |
The type of a code review. There are two code review types: PullRequest - A code review that is automatically triggered by a pull request on an associated repository. RepositoryAnalysis - A code review that analyzes all code under a specified branch in an associated repository. The associated repository is specified using its ARN in CreateCodeReview.
value:
RepositoryAnalysis:
RepositoryHead:
BranchName: "{{ BranchName }}"
SourceCodeType:
CommitDiff:
SourceCommit: "{{ SourceCommit }}"
DestinationCommit: "{{ DestinationCommit }}"
MergeBaseCommit: "{{ MergeBaseCommit }}"
RepositoryHead:
BranchName: "{{ BranchName }}"
BranchDiff:
SourceBranchName: "{{ SourceBranchName }}"
DestinationBranchName: "{{ DestinationBranchName }}"
S3BucketRepository:
Name: "{{ Name }}"
Details:
BucketName: "{{ BucketName }}"
CodeArtifacts: "{{ CodeArtifacts }}"
RequestMetadata:
RequestId: "{{ RequestId }}"
Requester: "{{ Requester }}"
EventInfo:
Name: "{{ Name }}"
State: "{{ State }}"
VendorName: "{{ VendorName }}"
AnalysisTypes:
- "{{ AnalysisTypes }}"
- name: ClientRequestToken
value: "{{ ClientRequestToken }}"