Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
此页面仅适用于使用保管库的 S3 Glacier 服务的现有客户以及 2012 年以RESTAPI来的原始客户。
如果您正在寻找档案存储解决方案,我们建议您在亚马逊 S3、S3 Glacier 即时检索、S3 Glacier 灵活检索和 S3 Glacier Deep Archive Dee p Archive 中使用 S3 Glacier 存储类。要了解有关这些存储选项的更多信息,请参阅 Amazon S3 用户指南中的 S3 Glacier 存储类和使用 S3 Glacier 存储类的长期数据存储。这些存储类别使用 Amazon S3API,适用于所有区域,并且可以在 Amazon S3 控制台中进行管理。它们提供存储成本分析、存储镜头、高级可选加密功能等功能。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 Amazon SDK或ListJobs
一起使用 CLI
以下代码示例演示如何使用 ListJobs
。
操作示例是大型程序的代码摘录,必须在上下文中运行。您可以在以下代码示例中查看此操作的上下文:
- .NET
-
- Amazon SDK for .NET
-
/// <summary>
/// List Amazon S3 Glacier jobs.
/// </summary>
/// <param name="vaultName">The name of the vault to list jobs for.</param>
/// <returns>A list of Amazon S3 Glacier jobs.</returns>
public async Task<List<GlacierJobDescription>> ListJobsAsync(string vaultName)
{
var request = new ListJobsRequest
{
// Using a hyphen "-" for the Account Id will
// cause the SDK to use the Account Id associated
// with the current account.
AccountId = "-",
VaultName = vaultName,
};
var response = await _glacierService.ListJobsAsync(request);
return response.JobList;
}
- CLI
-
- Amazon CLI
-
以下命令列出了名为 my-vault
的文件库的正在进行和最近完成的任务:
aws glacier list-
jobs --account-id - --vault-name my-vault
输出:
{
"JobList": [
{
"VaultARN": "arn:aws:glacier:us-west-2:0123456789012:vaults/my-vault",
"RetrievalByteRange": "0-3145727",
"SNSTopic": "arn:aws:sns:us-west-2:0123456789012:my-vault",
"Completed": false,
"SHA256TreeHash": "9628195fcdbcbbe76cdde932d4646fa7de5f219fb39823836d81f0cc0e18aa67",
"JobId": "l7IL5-EkXyEY9Ws95fClzIbk2O5uLYaFdAYOi-azsX_Z8V6NH4yERHzars8wTKYQMX6nBDI9cMNHzyZJO59-8N9aHWav",
"ArchiveId": "kKB7ymWJVpPSwhGP6ycSOAekp9ZYe_--zM_mw6k76ZFGEIWQX-ybtRDvc2VkPSDtfKmQrj0IRQLSGsNuDp-AJVlu2ccmDSyDUmZwKbwbpAdGATGDiB3hHO0bjbGehXTcApVud_wyDw",
"JobDescription": "Retrieve archive on 2015-07-17",
"ArchiveSizeInBytes": 3145728,
"Action": "ArchiveRetrieval",
"ArchiveSHA256TreeHash": "9628195fcdbcbbe76cdde932d4646fa7de5f219fb39823836d81f0cc0e18aa67",
"CreationDate": "2015-07-17T21:16:13.840Z",
"StatusCode": "InProgress"
},
{
"InventoryRetrievalParameters": {
"Format": "JSON"
},
"VaultARN": "arn:aws:glacier:us-west-2:0123456789012:vaults/my-vault",
"Completed": false,
"JobId": "zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW",
"Action": "InventoryRetrieval",
"CreationDate": "2015-07-17T20:23:41.616Z",
"StatusCode": ""InProgress""
}
]
}
Amazon Glacier 在执行操作时需要一个账户 ID 参数,但您可以使用连字符来指定正在使用的账户。
- Python
-
- SDK适用于 Python (Boto3)
-
class GlacierWrapper:
"""Encapsulates Amazon S3 Glacier API operations."""
def __init__(self, glacier_resource):
"""
:param glacier_resource: A Boto3 Amazon S3 Glacier resource.
"""
self.glacier_resource = glacier_resource
@staticmethod
def list_jobs(vault, job_type):
"""
Lists jobs by type for the specified vault.
:param vault: The vault to query.
:param job_type: The type of job to list.
:return: The list of jobs of the requested type.
"""
job_list = []
try:
if job_type == "all":
jobs = vault.jobs.all()
elif job_type == "in_progress":
jobs = vault.jobs_in_progress.all()
elif job_type == "completed":
jobs = vault.completed_jobs.all()
elif job_type == "succeeded":
jobs = vault.succeeded_jobs.all()
elif job_type == "failed":
jobs = vault.failed_jobs.all()
else:
jobs = []
logger.warning("%s isn't a type of job I can get.", job_type)
for job in jobs:
job_list.append(job)
logger.info("Got %s %s job %s.", job_type, job.action, job.id)
except ClientError:
logger.exception("Couldn't get %s jobs from %s.", job_type, vault.name)
raise
else:
return job_list
有关 Amazon SDK开发者指南和代码示例的完整列表,请参阅将 S3 Glacier 与 S Amazon DK 配。本主题还包括有关入门的信息以及有关先前SDK版本的详细信息。