

# 使用 AWS CLI 的 CodeGuru Reviewer 示例
<a name="cli_codeguru-reviewer_code_examples"></a>

以下代码示例演示如何通过将 AWS Command Line Interface与 CodeGuru Reviewer 结合使用，来执行操作和实现常见场景。

*操作是大型程序的代码摘录*，必须在上下文中运行。您可以通过操作了解如何调用单个服务函数，还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接，您可以从中找到有关如何在上下文中设置和运行代码的说明。

**Topics**
+ [操作](#actions)

## 操作
<a name="actions"></a>

### `associate-repository`
<a name="codeguru-reviewer_AssociateRepository_cli_topic"></a>

以下代码示例演示了如何使用 `associate-repository`。

**AWS CLI**  
**示例 1：创建 Bitbucket 存储库关联**  
以下 `associate-repository` 示例使用现有 Bitbucket 存储库创建存储库关联。  

```
aws codeguru-reviewer associate-repository \
    --repository 'Bitbucket={Owner=sample-owner, Name=mySampleRepo, ConnectionArn=arn:aws:codestar-connections:us-west-2:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 }'
```
输出：  

```
{
    "RepositoryAssociation": {
        "ProviderType": "Bitbucket",
        "Name": "mySampleRepo",
        "LastUpdatedTimeStamp": 1596216896.979,
        "AssociationId": "association:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "CreatedTimeStamp": 1596216896.979,
        "ConnectionArn": "arn:aws:codestar-connections:us-west-2:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "State": "Associating",
        "StateReason": "Pending Repository Association",
        "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "Owner": "sample-owner"
    }
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[在 Amazon CodeGuru Reviewer 中创建 Bitbucket 存储库关联](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/create-bitbucket-association.html)。  
**示例 2：创建 GitHub Enterprise 存储库关联**  
以下 `associate-repository` 示例使用现有 GitHub Enterprise 存储库创建存储库关联。  

```
aws codeguru-reviewer associate-repository \
    --repository 'GitHubEnterpriseServer={Owner=sample-owner, Name=mySampleRepo, ConnectionArn=arn:aws:codestar-connections:us-west-2:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 }'
```
输出：  

```
{
    "RepositoryAssociation": {
        "ProviderType": "GitHubEnterpriseServer",
        "Name": "mySampleRepo",
        "LastUpdatedTimeStamp": 1596216896.979,
        "AssociationId": "association:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "CreatedTimeStamp": 1596216896.979,
        "ConnectionArn": "arn:aws:codestar-connections:us-west-2:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "State": "Associating",
        "StateReason": "Pending Repository Association",
        "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "Owner": "sample-owner"
    }
}
```
有关更多信息，请参阅《Amazon Codeguru Reviewer 用户指南》**中的[在 Amazon CodeGuru Reviewer 中创建 GitHub Enterprise Server 存储库关联](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/create-github-enterprise-association.html)。  
**示例 3：创建 AWS CodeCommit 存储库关联**  
以下 `associate-repository` 示例使用现有 AWS CodeCommit 存储库创建存储库关联。  

```
aws codeguru-reviewer associate-repository \
    --repository CodeCommit={Name=mySampleRepo}
```
输出：  

```
{
    "RepositoryAssociation": {
        "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "Name": "My-ecs-beta-repo",
        "LastUpdatedTimeStamp": 1595634764.029,
        "ProviderType": "CodeCommit",
        "CreatedTimeStamp": 1595634764.029,
        "Owner": "544120495673",
        "State": "Associating",
        "StateReason": "Pending Repository Association",
        "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:544120495673:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
    }
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[在 Amazon CodeGuru Reviewer 中创建 AWS CodeCommit 存储库关联](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/create-codecommit-association.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [AssociateRepository](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/associate-repository.html)。

### `create-code-review`
<a name="codeguru-reviewer_CreateCodeReview_cli_topic"></a>

以下代码示例演示了如何使用 `create-code-review`。

**AWS CLI**  
**创建代码审查。**  
以下 `create-code-review` 创建对名为 `my-repository-name` 的 AWS CodeCommit 存储库 `mainline` 分支中代码的审查。  

```
aws codeguru-reviewer create-code-review \
    --name my-code-review \
    --repository-association-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --type '{"RepositoryAnalysis": {"RepositoryHead": {"BranchName": "mainline"}}}'
```
输出：  

```
{
    "CodeReview": {
        "Name": "my-code-review",
        "CodeReviewArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222:code-review:RepositoryAnalysis-my-code-review",
        "RepositoryName": "my-repository-name",
        "Owner": "123456789012",
        "ProviderType": "CodeCommit",
        "State": "Pending",
        "StateReason": "CodeGuru Reviewer has received the request, and a code review is scheduled.",
        "CreatedTimeStamp": 1618873489.195,
        "LastUpdatedTimeStamp": 1618873489.195,
        "Type": "RepositoryAnalysis",
        "SourceCodeType": {
            "RepositoryHead": {
                "BranchName": "mainline"
            }
        },
        "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
    }
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[在 Amazon CodeGuru Reviewer 中创建代码审查](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/create-code-reviews.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateCodeReview](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/create-code-review.html)。

### `describe-code-review`
<a name="codeguru-reviewer_DescribeCodeReview_cli_topic"></a>

以下代码示例演示了如何使用 `describe-code-review`。

**AWS CLI**  
**列出有关代码审查的详细信息。**  
以下 `describe-code-review` 列出 AWS CodeCommit 存储库中名为“my-repo-name”的“mainline”分支中代码的审查信息。  

```
aws codeguru-reviewer put-recommendation-feedback \
    --code-review-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111:code-review:RepositoryAnalysis-my-repository-name-branch-abcdefgh12345678 \
    --recommendation-id 3be1b2e5d7ef6e298a06499379ee290c9c596cf688fdcadb08285ddb0dd390eb \
    --reactions ThumbsUp
```
Output  

```
{
        "CodeReview": {
            "Name": "My-ecs-beta-repo-master-xs6di4kfd4j269dz",
            "CodeReviewArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222:code-review:RepositoryAnalysis-my-repo-name",
            "RepositoryName": "My-ecs-beta-repo",
            "Owner": "123456789012",
            "ProviderType": "CodeCommit",
            "State": "Pending",
            "StateReason": "CodeGuru Reviewer is reviewing the source code.",
            "CreatedTimeStamp": 1618874226.226,
            "LastUpdatedTimeStamp": 1618874233.689,
            "Type": "RepositoryAnalysis",
            "SourceCodeType": {
                "RepositoryHead": {
                    "BranchName": "mainline"
                }
            },
            "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
        }
    }
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[查看代码审查的详细信息](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/view-code-review-details.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DescribeCodeReview](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/describe-code-review.html)。

### `describe-recommendation-feedback`
<a name="codeguru-reviewer_DescribeRecommendationFeedback_cli_topic"></a>

以下代码示例演示了如何使用 `describe-recommendation-feedback`。

**AWS CLI**  
**查看有关推荐反馈的信息**  
以下 `describe-recommendation-feedback` 显示有关推荐反馈的信息。该推荐有一个 `ThumbsUp` 回应。  

```
aws codeguru-reviewer describe-recommendation-feedback \
    --code-review-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111:code-review:RepositoryAnalysis-my-repository-name-branch-abcdefgh12345678 \
    --recommendation-id 3be1b2e5d7ef6e298a06499379ee290c9c596cf688fdcadb08285ddb0dd390eb
```
输出：  

```
{
    "RecommendationFeedback": {
        "CodeReviewArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111:code-review:RepositoryAnalysis-my-repository-name-branch-abcdefgh12345678",
        "RecommendationId": "3be1b2e5d7ef6e298a06499379ee290c9c596cf688fdcadb08285ddb0dd390eb",
        "Reactions": [
            "ThumbsUp"
        ],
        "UserId": "aws-user-id",
        "CreatedTimeStamp": 1618877070.313,
        "LastUpdatedTimeStamp": 1618877948.881
    }
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[查看推荐并提供反馈](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/give-feedback-from-code-review-details.html)和[步骤 4：提供反馈](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/provide-feedback.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DescribeRecommendationFeedback](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/describe-recommendation-feedback.html)。

### `describe-repository-association`
<a name="codeguru-reviewer_DescribeRepositoryAssociation_cli_topic"></a>

以下代码示例演示了如何使用 `describe-repository-association`。

**AWS CLI**  
**示例 1：返回有关 GitHub 存储库关联的信息**  
以下 `describe-repository-association` 示例返回有关使用 GitHub Enterprise 存储库且处于 `Associated` 状态的存储库关联的信息。  

```
aws codeguru-reviewer describe-repository-association \
    --association-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
输出：  

```
{
    "RepositoryAssociation": {
        "AssociationId": "b822717e-0711-4e8a-bada-0e738289c75e",
        "Name": "mySampleRepo",
        "LastUpdatedTimeStamp": 1588102637.649,
        "ProviderType": "GitHub",
        "CreatedTimeStamp": 1588102615.636,
        "Owner": "sample-owner",
        "State": "Associated",
        "StateReason": "Pull Request Notification configuration successful",
        "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
    }
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[在 Amazon CodeGuru Reviewer 中创建 GitHub Enterprise Server 存储库关联](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/create-github-enterprise-association.html)。  
**示例 2：返回有关失败的存储库关联的信息**  
以下 `describe-repository-association` 示例返回有关使用 GitHub Enterprise 存储库且处于 `Failed` 状态的存储库关联的信息。  

```
aws codeguru-reviewer describe-repository-association \
    --association-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
输出：  

```
{
    "RepositoryAssociation": {
        "ProviderType": "GitHubEnterpriseServer",
        "Name": "mySampleRepo",
        "LastUpdatedTimeStamp": 1596217036.892,
        "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "CreatedTimeStamp": 1596216896.979,
        "ConnectionArn": "arn:aws:codestar-connections:us-west-2:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "State": "Failed",
        "StateReason": "Failed, Please retry.",
        "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE33333",
        "Owner": "sample-owner"
    }
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[在 Amazon CodeGuru Reviewer 中创建 GitHub Enterprise Server 存储库关联](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/create-github-enterprise-association.html)。  
**示例 3：返回有关正在解除关联的存储库关联的信息**  
以下 `describe-repository-association` 示例返回有关使用 GitHub Enterprise 存储库且处于 `Disassociating` 状态的存储库关联的信息。  

```
aws codeguru-reviewer describe-repository-association \
    --association-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
输出：  

```
{
    "RepositoryAssociation": {
        "ProviderType": "GitHubEnterpriseServer",
        "Name": "mySampleRepo",
        "LastUpdatedTimeStamp": 1596217036.892,
        "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "CreatedTimeStamp": 1596216896.979,
        "ConnectionArn": "arn:aws:codestar-connections:us-west-2:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "State": "Disassociating",
        "StateReason": "Source code access removal in progress",
        "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE33333",
        "Owner": "sample-owner"
    }
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[在 Amazon CodeGuru Reviewer 中创建 GitHub Enterprise Server 存储库关联](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/create-github-enterprise-association.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DescribeRepositoryAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/describe-repository-association.html)。

### `disassociate-repository`
<a name="codeguru-reviewer_DisassociateRepository_cli_topic"></a>

以下代码示例演示了如何使用 `disassociate-repository`。

**AWS CLI**  
**解除与存储库关联的关联**  
以下 `disassociate-repository` 解除正在使用 AWS CodeCommit 存储库的存储库关联的关联。  

```
aws codeguru-reviewer disassociate-repository \
    --association-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
输出：  

```
{
    "RepositoryAssociation": {
        "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "Name": "my-repository",
        "Owner": "123456789012",
        "ProviderType": "CodeCommit",
        "State": "Disassociating",
        "LastUpdatedTimeStamp": 1618939174.759,
        "CreatedTimeStamp": 1595636947.096
    },
    "Tags": {
        "Status": "Secret",
        "Team": "Saanvi"
    }
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[在 CodeGuru Reviewer 中解除与存储库的关联](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/disassociate-repository-association.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DisassociateRepository](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/disassociate-repository.html)。

### `list-code-reviews`
<a name="codeguru-reviewer_ListCodeReviews_cli_topic"></a>

以下代码示例演示了如何使用 `list-code-reviews`。

**AWS CLI**  
**列出过去 90 天内在您 AWS 账户中创建的代码审查。**  
以下 `list-code-reviews` 示例列出在过去 90 天内使用拉取请求创建的代码审查。  

```
aws codeguru-reviewer list-code-reviews \
    --type PullRequest
```
输出：  

```
{
    "CodeReviewSummaries": [
        {
            "LastUpdatedTimeStamp": 1588897288.054,
            "Name": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "ProviderType": "GitHub",
            "PullRequestId": "5",
            "MetricsSummary": {
                "MeteredLinesOfCodeCount": 24,
                "FindingsCount": 1
            },
            "CreatedTimeStamp": 1588897068.512,
            "State": "Completed",
            "CodeReviewArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:code-review:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "Owner": "sample-owner",
            "RepositoryName": "sample-repository-name",
            "Type": "PullRequest"
        },
        {
            "LastUpdatedTimeStamp": 1588869793.263,
            "Name": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
            "ProviderType": "GitHub",
            "PullRequestId": "4",
            "MetricsSummary": {
                "MeteredLinesOfCodeCount": 29,
                "FindingsCount": 0
            },
            "CreatedTimeStamp": 1588869575.949,
            "State": "Completed",
            "CodeReviewArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:code-review:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
            "Owner": "sample-owner",
            "RepositoryName": "sample-repository-name",
            "Type": "PullRequest"
        },
        {
            "LastUpdatedTimeStamp": 1588870511.211,
            "Name": "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333",
            "ProviderType": "GitHub",
            "PullRequestId": "4",
            "MetricsSummary": {
                "MeteredLinesOfCodeCount": 2,
                "FindingsCount": 0
            },
            "CreatedTimeStamp": 1588870292.425,
            "State": "Completed",
            "CodeReviewArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:code-review:a1b2c3d4-5678-90ab-cdef-EXAMPLE33333",
            "Owner": "sample-owner",
            "RepositoryName": "sample-repository-name",
            "Type": "PullRequest"
        },
        {
            "LastUpdatedTimeStamp": 1588118522.452,
            "Name": "a1b2c3d4-5678-90ab-cdef-EXAMPLE44444",
            "ProviderType": "GitHub",
            "PullRequestId": "3",
            "MetricsSummary": {
                "MeteredLinesOfCodeCount": 29,
                "FindingsCount": 0
            },
            "CreatedTimeStamp": 1588118301.131,
            "State": "Completed",
            "CodeReviewArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:code-review:a1b2c3d4-5678-90ab-cdef-EXAMPLE44444",
            "Owner": "sample-owner",
            "RepositoryName": "sample-repository-name",
            "Type": "PullRequest"
        },
        {
            "LastUpdatedTimeStamp": 1588112205.207,
            "Name": "a1b2c3d4-5678-90ab-cdef-EXAMPLE55555",
            "ProviderType": "GitHub",
            "PullRequestId": "2",
            "MetricsSummary": {
                "MeteredLinesOfCodeCount": 25,
                "FindingsCount": 0
            },
            "CreatedTimeStamp": 1588111987.443,
            "State": "Completed",
            "CodeReviewArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:code-review:a1b2c3d4-5678-90ab-cdef-EXAMPLE55555",
            "Owner": "sample-owner",
            "RepositoryName": "sample-repository-name",
            "Type": "PullRequest"
        },
        {
            "LastUpdatedTimeStamp": 1588104489.981,
            "Name": "a1b2c3d4-5678-90ab-cdef-EXAMPLE66666",
            "ProviderType": "GitHub",
            "PullRequestId": "1",
            "MetricsSummary": {
                "MeteredLinesOfCodeCount": 25,
                "FindingsCount": 0
            },
            "CreatedTimeStamp": 1588104270.223,
            "State": "Completed",
            "CodeReviewArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:code-review:a1b2c3d4-5678-90ab-cdef-EXAMPLE66666",
            "Owner": "sample-owner",
            "RepositoryName": "sample-repository-name",
            "Type": "PullRequest"
        }
    ]
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[查看所有代码审查](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/view-all-code-reviews.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [ListCodeReviews](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/list-code-reviews.html)。

### `list-recommendation-feedback`
<a name="codeguru-reviewer_ListRecommendationFeedback_cli_topic"></a>

以下代码示例演示了如何使用 `list-recommendation-feedback`。

**AWS CLI**  
**在关联存储库中列出客户对推荐的推荐反馈**  
以下 `list-recommendation-feedback` 列出客户对代码审查中所有推荐的反馈。此代码审查包含来自客户的一条反馈，即“ThumbsUp”。  

```
aws codeguru-reviewer list-recommendation-feedback \
    --code-review-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111:code-review:RepositoryAnalysis-my-repository-name-branch-abcdefgh12345678
```
输出：  

```
{
    "RecommendationFeedbackSummaries": [
        {
            "RecommendationId": "3be1b2e5d7ef6e298a06499379ee290c9c596cf688fdcadb08285ddb0dd390eb",
            "Reactions": [
                "ThumbsUp"
            ],
            "UserId": "aws-user-id"
        }
    ]
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[步骤 4：提供反馈](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/provide-feedback.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [ListRecommendationFeedback](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/list-recommendation-feedback.html)。

### `list-recommendations`
<a name="codeguru-reviewer_ListRecommendations_cli_topic"></a>

以下代码示例演示了如何使用 `list-recommendations`。

**AWS CLI**  
**列出已完成代码审查的推荐**  
以下 `list-recommendations` 示例列出已完成代码审查的建议。此代码审查有一条推荐。  

```
aws codeguru-reviewer list-recommendations \
    --code-review-arn arn:aws:codeguru-reviewer:us-west-2:544120495673:code-review:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
输出：  

```
{
    "RecommendationSummaries": [
        {
            "Description": "\n\n**Problem**  \n You are using a `ConcurrentHashMap`, but your usage of `containsKey()` and `get()` may not be thread-safe at lines: **63 and 64**. In between the check and the `get()` another thread can remove the key and the `get()` will return `null`. The remove that can remove the key is at line: **59**.\n\n**Fix**  \n Consider calling `get()`, checking instead of your current check if the returned object is `null`, and then using that object only, without calling `get()` again.\n\n**More info**  \n [View an example on GitHub](https://github.com/apache/hadoop/blob/f16cf877e565084c66bc63605659b157c4394dc8/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3Guard.java#L302-L304) (external link).",
            "RecommendationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
            "StartLine": 63,
            "EndLine": 64,
            "FilePath": "src/main/java/com/company/sample/application/CreateOrderThread.java"
        }
    ]
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[步骤 4：提供反馈](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/provide-feedback.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [ListRecommendations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/list-recommendations.html)。

### `list-repository-associations`
<a name="codeguru-reviewer_ListRepositoryAssociations_cli_topic"></a>

以下代码示例演示了如何使用 `list-repository-associations`。

**AWS CLI**  
**列出您 AWS 账户中的存储库关联**  
以下 `list-repository-associations` 示例返回您账户中存储库关联摘要对象的列表。您可以按 `ProviderType`、`Name`、`State` 和 `Owner` 筛选返回的列表。  

```
aws codeguru-reviewer list-repository-associations
```
输出：  

```
{
    "RepositoryAssociationSummaries": [
        {
            "LastUpdatedTimeStamp": 1595886609.616,
            "Name": "test",
            "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "Owner": "sample-owner",
            "State": "Associated",
            "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "ProviderType": "Bitbucket"
        },
        {
            "LastUpdatedTimeStamp": 1595636969.035,
            "Name": "CodeDeploy-CodePipeline-ECS-Tutorial",
            "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
            "Owner": "123456789012",
            "State": "Associated",
            "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
            "ProviderType": "CodeCommit"
        },
        {
            "LastUpdatedTimeStamp": 1595634785.983,
            "Name": "My-ecs-beta-repo",
            "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333",
            "Owner": "123456789012",
            "State": "Associated",
            "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE33333",
            "ProviderType": "CodeCommit"
        },
        {
            "LastUpdatedTimeStamp": 1590712811.77,
            "Name": "MyTestCodeCommit",
            "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE44444",
            "Owner": "123456789012",
            "State": "Associated",
            "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE44444",
            "ProviderType": "CodeCommit"
        },
        {
            "LastUpdatedTimeStamp": 1588102637.649,
            "Name": "aws-codeguru-profiler-sample-application",
            "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE55555",
            "Owner": "sample-owner",
            "State": "Associated",
            "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE55555",
            "ProviderType": "GitHub"
        },
        {
            "LastUpdatedTimeStamp": 1588028233.995,
            "Name": "codeguru-profiler-demo-app",
            "AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE66666",
            "Owner": "sample-owner",
            "State": "Associated",
            "AssociationArn": "arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE66666",
            "ProviderType": "GitHub"
        }
    ]
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[在 CodeGuru Reviewer 中查看所有存储库关联](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/repository-association-view-all.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [ListRepositoryAssociations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/list-repository-associations.html)。

### `list-tags-for-resource`
<a name="codeguru-reviewer_ListTagsForResource_cli_topic"></a>

以下代码示例演示了如何使用 `list-tags-for-resource`。

**AWS CLI**  
**列出关联存储库上的标签**  
以下 `list-tags-for-resource` 列出关联存储库上的标签。此关联存储库有两个标签。  

```
aws codeguru-reviewer list-tags-for-resource \
    --resource-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
输出：  

```
{
    "Tags": {
        "Status": "Secret",
        "Team": "Saanvi"
    }
}
```
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[查看 CodeGuru Reviewer 关联存储库的标签（AWS CLI）](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/how-to-tag-associated-repository-view-cli.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/list-tags-for-resource.html)。

### `put-recommendation-feedback`
<a name="codeguru-reviewer_PutRecommendationFeedback_cli_topic"></a>

以下代码示例演示了如何使用 `put-recommendation-feedback`。

**AWS CLI**  
**向代码审查添加推荐**  
以下 `put-recommendation-feedback` 为代码审查添加 `ThumbsUp` 推荐。  

```
aws codeguru-reviewer put-recommendation-feedback \
    --code-review-arn \arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111:code-review:RepositoryAnalysis-my-repository-name-branch-abcdefgh12345678 \
    --recommendation-id 3be1b2e5d7ef6e298a06499379ee290c9c596cf688fdcadb08285ddb0dd390eb \
    --reactions ThumbsUp
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[步骤 4：提供反馈](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/provide-feedback.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [PutRecommendationFeedback](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/put-recommendation-feedback.html)。

### `tag-resource`
<a name="codeguru-reviewer_TagResource_cli_topic"></a>

以下代码示例演示了如何使用 `tag-resource`。

**AWS CLI**  
**向关联存储库添加标签**  
以下 `tag-resource` 向关联存储库添加两个标签。  

```
aws codeguru-reviewer tag-resource \
    --resource-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --tags Status=Secret,Team=Saanvi
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[向 CodeGuru Reviewer 关联存储库添加标签（AWS CLI）](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/how-to-tag-associated-repository-add-cli.html)和[在 CodeGuru Reviewer 关联存储库中添加或更新标签（AWS CLI）](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/how-to-tag-associated-repository-update-cli.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/tag-resource.html)。

### `untag-resource`
<a name="codeguru-reviewer_UntagResource_cli_topic"></a>

以下代码示例演示了如何使用 `untag-resource`。

**AWS CLI**  
**取消关联存储库的标记**  
以下 `untag-resource` 从关联存储库中移除两个密钥为“Secret”和“Team”的标签。  

```
aws codeguru-reviewer untag-resource \
    --resource-arn arn:aws:codeguru-reviewer:us-west-2:123456789012:association:a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --tag-keys Status Team
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon CodeGuru Reviewer 用户指南》**中的[从 CodeGuru Reviewer 关联存储库中移除标签（AWS CLI）](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/how-to-tag-associated-repository-remove-cli.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeguru-reviewer/untag-resource.html)。