View a markdown version of this page

ListTagsForVault 搭配 AWS SDK 或 CLI 使用 - AWS SDK 程式碼範例

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

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

ListTagsForVault 搭配 AWS SDK 或 CLI 使用

下列程式碼範例示範如何使用 ListTagsForVault

.NET
適用於 .NET 的 SDK
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

/// <summary> /// List tags for an Amazon S3 Glacier vault. /// </summary> /// <param name="vaultName">The name of the vault to list tags for.</param> /// <returns>A dictionary listing the tags attached to each object in the /// vault and its tags.</returns> public async Task<Dictionary<string, string>> ListTagsForVaultAsync(string vaultName) { var request = new ListTagsForVaultRequest { // Using a hyphen "-" for the Account Id will // cause the SDK to use the Account Id associated // with the default user. AccountId = "-", VaultName = vaultName, }; var response = await _glacierService.ListTagsForVaultAsync(request); return response.Tags; }
  • 如需 API 詳細資訊,請參閱《適用於 .NET 的 AWS SDK API 參考》中的 ListTagsForVault

CLI
AWS CLI

下列命令會列出套用到 my-vault 文件庫的標籤:

aws glacier list-tags-for-vault --account-id - --vault-name my-vault

輸出:

{ "Tags": { "date": "july2015", "id": "1234" } }

Amazon Glacier 在執行操作時需要帳戶 ID 引數,但您可以使用連字號來指定使用中的帳戶。

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