sample/put_bucket_https_config.py (30 lines of code) (raw):

import argparse import alibabacloud_oss_v2 as oss parser = argparse.ArgumentParser(description="put bucket https config sample") parser.add_argument('--region', help='The region in which the bucket is located.', required=True) parser.add_argument('--bucket', help='The name of the bucket.', required=True) parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS') parser.add_argument('--enable', help='Specifies whether to enable TLS version management for the bucket.Valid values:true or false ', default='false') 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 client = oss.Client(cfg) result = client.put_bucket_https_config(oss.PutBucketHttpsConfigRequest( bucket=args.bucket, https_configuration=oss.HttpsConfiguration( tls=oss.TLS( enable=args.enable, tls_versions=['TLSv1.2', 'TLSv1.3'], ), ), )) print(f'status code: {result.status_code},' f' request id: {result.request_id},' ) if __name__ == "__main__": main()