搭GetVaultNotifications配 AWS 開發套件或 CLI 使用 - Amazon S3 Glacier

如果您不熟悉 Amazon Simple Storage Service (Amazon S3) 中的封存儲存,建議您從深入了解 Amazon S3 中的 S3 Glacier 儲存類別、S3 Glacier Instant RetrievalS3 Glacier Flexible RetrievalS3 Glacier Deep Archive 開始。如需詳細資訊,請參閱 Amazon S3 使用者指南中的 S3 Glacier 儲存類別和存檔物件的儲存類別。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

GetVaultNotifications配 AWS 開發套件或 CLI 使用

下列程式碼範例會示範如何使用GetVaultNotifications

CLI
AWS 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
適用於 Python (Boto3) 的 SDK
注意

還有更多關於 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 @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
  • 如需 API 的詳細資訊,請參閱AWS 開發套件GetVaultNotifications中的 Python (博托 3) API 參考。

如需 AWS SDK 開發人員指南和程式碼範例的完整清單,請參閱搭配 AWS 開發套件使用 S3 冰川。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。