使用 的 CodeGuru Reviewer 範例 AWS CLI - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 的 CodeGuru Reviewer 範例 AWS CLI

下列程式碼範例示範如何使用 AWS Command Line Interface with CodeGuru Reviewer 來執行動作和實作常見案例。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然 動作會示範如何呼叫個別服務函數,但您可以在其相關案例中查看內容中的動作。

每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例示範如何使用 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 使用者指南中的在 AmazonWord Reviewer 中建立 Bitbucket 儲存庫關聯 CodeGuru

範例 2:建立 a 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 GitHub Reviewer 使用者指南中的在 Amazon CodeGuru Reviewer 中建立 aWord Enterprise Server 儲存庫關聯

範例 3:建立 a 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 AWS CodeCommit Reviewer 使用者指南中的在 Amazon CodeGuru Reviewer 中建立 aWord 儲存庫關聯 CodeGuru

下列程式碼範例示範如何使用 create-code-review

AWS CLI

建立程式碼檢閱。

以下內容會在名為 的 AWS CodeCommit 儲存庫mainline分支中create-code-review建立程式碼檢閱my-repository-name

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 使用者指南中的在 AmazonWord Reviewer 中建立程式碼檢閱 CodeGuru

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CreateCodeReview

下列程式碼範例示範如何使用 describe-code-review

AWS CLI

列出程式碼檢閱的詳細資訊。

下列describe-code-review列出在名為 "my-repo-name" 的 a AWS CodeCommit 儲存庫的「主要」分支中檢閱程式碼的相關資訊。

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

輸出

{ "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 使用者指南中的檢視程式碼檢閱詳細資訊

下列程式碼範例示範如何使用 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 檢閱器使用者指南中的檢視建議並提供意見回饋步驟 4:提供意見回饋

下列程式碼範例示範如何使用 describe-repository-association

AWS CLI

範例 1:傳回有關 a GitHub 儲存庫關聯的資訊

下列describe-repository-association範例會傳回使用 a 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 GitHub 使用者指南中的在 Amazon CodeGuru Reviewer 中建立 aWord Enterprise Server 儲存庫關聯 CodeGuru

範例 2:傳回失敗儲存庫關聯的相關資訊

下列describe-repository-association範例會傳回使用 a 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 GitHub 使用者指南中的在 Amazon CodeGuru Reviewer 中建立 aWord Enterprise Server 儲存庫關聯 CodeGuru

範例 3:傳回有關取消關聯儲存庫關聯的資訊

下列describe-repository-association範例會傳回使用 a 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 GitHub 使用者指南中的在 Amazon CodeGuru Reviewer 中建立 aWord Enterprise Server 儲存庫關聯 CodeGuru

下列程式碼範例示範如何使用 disassociate-repository

AWS CLI

若要取消與儲存庫關聯的關聯

下列會disassociate-repository取消與使用 a 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 使用者指南中的取消儲存庫 inWord Reviewer 的關聯 CodeGuru

下列程式碼範例示範如何使用 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" } ] }

如需詳細資訊,請參閱 AmazonWord 檢閱器使用者指南中的檢視所有程式碼檢閱。 CodeGuru

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListCodeReviews

下列程式碼範例示範如何使用 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 檢閱者使用者指南中的步驟 4:提供意見回饋

下列程式碼範例示範如何使用 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 檢閱者使用者指南中的步驟 4:提供意見回饋

下列程式碼範例示範如何使用 list-repository-associations

AWS CLI

列出您 AWS 帳戶中的儲存庫關聯

下列list-repository-associations範例會傳回您帳戶中儲存庫關聯摘要物件的清單。您可以依 ProviderTypeNameState和 篩選傳回的清單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" } ] }

如需詳細資訊,請參閱 AmazonWord Reviewer 使用者指南中的在 CodeGuru Reviewer 中檢視所有儲存庫關聯 CodeGuru

下列程式碼範例示範如何使用 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 使用者指南中的檢視 aWord Reviewer 相關儲存庫 (AWS CLI) 的標籤 CodeGuru

下列程式碼範例示範如何使用 put-recommendation-feedback

AWS CLI

將建議新增至程式碼檢閱

以下ThumbsUp將建議put-recommendation-feedback放在程式碼檢閱上。

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 檢閱者使用者指南中的步驟 4:提供意見回饋

下列程式碼範例示範如何使用 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 使用者指南中的將標籤新增至 aWord Reviewer 相關儲存庫 (AWS CLI)新增或更新 a CodeGuru Reviewer 相關儲存庫 (AWS CLI) 的標籤 CodeGuru

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 TagResource

下列程式碼範例示範如何使用 untag-resource

AWS CLI

若要取消標記相關聯的儲存庫

以下內容會從相關聯的儲存庫untag-resource中移除兩個具有「秘密」和「團隊」金鑰的標籤。

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 使用者指南中的從 aWord Reviewer 相關儲存庫 (AWS CLI) 移除標籤 CodeGuru

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 UntagResource