AWS SDKを使用して Amazon S3 Glacier ボールト通知を設定します - AWSSDK コードサンプル

AWSDocAWS SDKGitHub サンプルリポジトリには、さらに多くの SDK サンプルがあります

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AWS SDKを使用して Amazon S3 Glacier ボールト通知を設定します

次のコード例は、Amazon S3 Glacier ボールト通知を設定する方法を示しています。

Python
SDK for Python (Boto3)
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

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 def set_notifications(self, vault, sns_topic_arn): """ Sets an Amazon Simple Notification Service (Amazon SNS) topic as a target for notifications. Amazon S3 Glacier publishes messages to this topic for the configured list of events. :param vault: The vault to set up to publish notifications. :param sns_topic_arn: The Amazon Resource Name (ARN) of the topic that receives notifications. :return: Data about the new notification configuration. """ try: notification = self.glacier_resource.Notification('-', vault.name) notification.set(vaultNotificationConfig={ 'SNSTopic': sns_topic_arn, 'Events': ['ArchiveRetrievalCompleted', 'InventoryRetrievalCompleted'] }) logger.info( "Notifications will be sent to %s for events %s from %s.", notification.sns_topic, notification.events, notification.vault_name) except ClientError: logger.exception( "Couldn't set notifications to %s on %s.", sns_topic_arn, vault.name) raise else: return notification
  • API の詳細については、「AWSSDK for Python (Boto3) API リファレンス」のを参照してくださいSetVaultNotifications