文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DeleteBucketLifecycle
搭配 a AWS SDK 或 CLI 使用
下列程式碼範例示範如何使用 DeleteBucketLifecycle
。
- .NET
-
- AWS SDK for .NET
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 /// <summary> /// This method removes the Lifecycle configuration from the named /// S3 bucket. /// </summary> /// <param name="client">The S3 client object used to call /// the RemoveLifecycleConfigAsync method.</param> /// <param name="bucketName">A string representing the name of the /// S3 bucket from which the configuration will be removed.</param> public static async Task RemoveLifecycleConfigAsync(IAmazonS3 client, string bucketName) { var request = new DeleteLifecycleConfigurationRequest() { BucketName = bucketName, }; await client.DeleteLifecycleConfigurationAsync(request); }
-
如需 API 詳細資訊,請參閱 DeleteBucketLifecycle AWS SDK for .NET 參考中的 API。
-
- CLI
-
- AWS CLI
-
下列命令會從名為 的儲存貯體中刪除生命週期組態
my-bucket
:aws s3api delete-bucket-lifecycle --bucket
my-bucket
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteBucketLifecycle
。
-
- Python
-
- SDK for Python (Boto3)
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 class BucketWrapper: """Encapsulates S3 bucket actions.""" def __init__(self, bucket): """ :param bucket: A Boto3 Bucket resource. This is a high-level resource in Boto3 that wraps bucket actions in a class-like structure. """ self.bucket = bucket self.name = bucket.name def delete_lifecycle_configuration(self): """ Remove the lifecycle configuration from the specified bucket. """ try: self.bucket.LifecycleConfiguration().delete() logger.info( "Deleted lifecycle configuration for bucket '%s'.", self.bucket.name ) except ClientError: logger.exception( "Couldn't delete lifecycle configuration for bucket '%s'.", self.bucket.name, ) raise
-
如需 API 詳細資訊,請參閱 DeleteBucketLifecycle AWS SDK for Python (Boto3) Word 參考中的 API。
-
DeleteBucketInventoryConfiguration
DeleteBucketMetricsConfiguration