in sample/put_bucket_replication.py [0:0]
def main():
args = parser.parse_args()
# Loading credentials values from the environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Using the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
if args.endpoint is not None:
cfg.endpoint = args.endpoint
# source
client = oss.Client(cfg)
# put bucket replication
result = client.put_bucket_replication(oss.PutBucketReplicationRequest(
bucket=args.bucket,
replication_configuration=oss.ReplicationConfiguration(
rules=[oss.ReplicationRule(
source_selection_criteria=oss.ReplicationSourceSelectionCriteria(
sse_kms_encrypted_objects=oss.SseKmsEncryptedObjects(
status=oss.StatusType.ENABLED,
),
),
rtc=oss.ReplicationTimeControl(
status='disabled',
),
destination=oss.ReplicationDestination(
bucket=args.target_bucket,
location=args.target_location,
transfer_type=oss.TransferType.INTERNAL,
),
historical_object_replication=oss.HistoricalObjectReplicationType.DISABLED,
sync_role=args.sync_role,
status='Disabled',
prefix_set=oss.ReplicationPrefixSet(
prefixs=['aaa/', 'bbb/'],
),
action='ALL',
)],
),
))
print(f'status code: {result.status_code},'
f' request id: {result.request_id},'
)