使用 boto3 进行 GCP 保留设置
Using boto3 for GCP retention settings
我正在使用 python boto3 包来访问 AWS S3 和 GCP 存储桶。
这些桶将对象 lock/retention 设置为各自的桶。
是否有一个常见的 packge/SDK 可以获取 lock/retention 详细信息。
session = boto3.session.Session(aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
region_name=region_name)
s3_client = session.client('s3', endpoint_url=endpoint)
head = s3_client.head_bucket(Bucket=bucket_name)
result = s3_client.get_object_lock_configuration(Bucket=bucket_name)
此代码块适用于 AWS S3,但会引发 GCP 存储桶异常。
抛出异常:
[DEBUG] Response body: b"<?xml version='1.0' encoding='UTF-8'?><Error><Code>InvalidArgument</Code>
<Message>Invalid argument.</Message><Details>Invalid query parameter(s): [object-lock]</Details></Error>" 2022-03-03 20:16:37,111 botocore.hooks
[DEBUG] Event needs-retry.s3.GetObjectLockConfiguration: calling handler <botocore.retryhandler.RetryHandler object at 0x7f518264a310> 2022-03-03 20:16:37,112 botocore.retryhandler
[DEBUG] No retry needed. 2022-03-03 20:16:37,113 botocore.hooks
[DEBUG] Event needs-retry.s3.GetObjectLockConfiguration: calling handler <bound method S3RegionRedirector.redirect_from_error of <botocore.utils.S3RegionRedirector object at 0x7f518264a370>>
An error occurred (InvalidArgument) when calling the GetObjectLockConfiguration operation: Invalid argument.
谢谢!!
我正在使用 python boto3 包来访问 AWS S3 和 GCP 存储桶。 这些桶将对象 lock/retention 设置为各自的桶。 是否有一个常见的 packge/SDK 可以获取 lock/retention 详细信息。
session = boto3.session.Session(aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
region_name=region_name)
s3_client = session.client('s3', endpoint_url=endpoint)
head = s3_client.head_bucket(Bucket=bucket_name)
result = s3_client.get_object_lock_configuration(Bucket=bucket_name)
此代码块适用于 AWS S3,但会引发 GCP 存储桶异常。 抛出异常:
[DEBUG] Response body: b"<?xml version='1.0' encoding='UTF-8'?><Error><Code>InvalidArgument</Code>
<Message>Invalid argument.</Message><Details>Invalid query parameter(s): [object-lock]</Details></Error>" 2022-03-03 20:16:37,111 botocore.hooks
[DEBUG] Event needs-retry.s3.GetObjectLockConfiguration: calling handler <botocore.retryhandler.RetryHandler object at 0x7f518264a310> 2022-03-03 20:16:37,112 botocore.retryhandler
[DEBUG] No retry needed. 2022-03-03 20:16:37,113 botocore.hooks
[DEBUG] Event needs-retry.s3.GetObjectLockConfiguration: calling handler <bound method S3RegionRedirector.redirect_from_error of <botocore.utils.S3RegionRedirector object at 0x7f518264a370>>
An error occurred (InvalidArgument) when calling the GetObjectLockConfiguration operation: Invalid argument.
谢谢!!