Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
如果您不熟悉 Amazon Simple Storage Service (Amazon S3) 中的归档存储功能,建议您先详细了解 Amazon S3 中的 S3 Glacier 存储类、S3 Glacier 即时检索、S3 Glacier 灵活检索和 S3 Glacier 深度归档。有关更多信息,请参阅 Amazon S3 用户指南中的 S3 Glacier 存储类和用于存档对象的存储类。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
GetVaultNotifications
与 S Amazon DK 或命令行工具配合使用
以下代码示例显示了如何使用GetVaultNotifications
。
- CLI
-
- Amazon CLI
-
以下命令获取名为 my-vault
的文件库的通知配置的描述:
aws glacier get-vault-notifications --account-id - --vault-name my-vault
输出:
{
"vaultNotificationConfig": {
"Events": [
"InventoryRetrievalCompleted",
"ArchiveRetrievalCompleted"
],
"SNSTopic": "arn:aws:sns:us-west-2:0123456789012:my-vault"
}
}
如果没有为该文件库配置任何通知,则会返回错误。Amazon Glacier 在执行操作时需要一个账户 ID 参数,但您可以使用连字符来指定正在使用的账户。
- Python
-
- SDK for 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 get_notification(vault):
"""
Gets the currently notification configuration for a vault.
:param vault: The vault to query.
:return: The notification configuration for the specified vault.
"""
try:
notification = vault.Notification()
logger.info(
"Vault %s notifies %s on %s events.",
vault.name,
notification.sns_topic,
notification.events,
)
except ClientError:
logger.exception("Couldn't get notification data for %s.", vault.name)
raise
else:
return notification
有关 S Amazon DK 开发者指南和代码示例的完整列表,请参阅将 S3 Glacier 与 Amazon SDK 结合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。