将 DescribeVault 与 AWS SDK 或 CLI 配合使用 - AWS SDK 代码示例

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

DescribeVault 与 AWS SDK 或 CLI 配合使用

以下代码示例演示如何使用 DescribeVault

.NET
适用于 .NET 的 SDK
注意

查看 GitHub,了解更多信息。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

/// <summary> /// Describe an Amazon S3 Glacier vault. /// </summary> /// <param name="vaultName">The name of the vault to describe.</param> /// <returns>The Amazon Resource Name (ARN) of the vault.</returns> public async Task<string> DescribeVaultAsync(string vaultName) { var request = new DescribeVaultRequest { AccountId = "-", VaultName = vaultName, }; var response = await _glacierService.DescribeVaultAsync(request); // Display the information about the vault. Console.WriteLine($"{response.VaultName}\tARN: {response.VaultARN}"); Console.WriteLine($"Created on: {response.CreationDate}\tNumber of Archives: {response.NumberOfArchives}\tSize (in bytes): {response.SizeInBytes}"); if (response.LastInventoryDate != DateTime.MinValue) { Console.WriteLine($"Last inventory: {response.LastInventoryDate}"); } return response.VaultARN; }
  • 有关 API 详细信息,请参阅《适用于 .NET 的 AWS SDK API Reference》中的 DescribeVault

CLI
AWS CLI

以下命令检索名为 my-vault 的文件库的相关数据:

aws glacier describe-vault --vault-name my-vault --account-id -

Amazon Glacier 在执行操作时需要一个账户 ID 参数,但您可以使用连字符来指定正在使用的账户。

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DescribeVault