View a markdown version of this page

ListTagsForVault搭配使用 AWS SDK 或 CLI - AWS SDK 代码示例

文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

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中的。