Best Python code snippet using localstack_python
s3.py
Source:s3.py
...86 """87 return client.get_bucket_notification_configuration(**kwargs)88@sts_conn('s3')89@rate_limited()90def get_bucket_accelerate_configuration(client=None, **kwargs):91 """92 Bucket='string'93 """94 return client.get_bucket_accelerate_configuration(**kwargs)95@sts_conn('s3')96@rate_limited()97def get_bucket_replication(client=None, **kwargs):98 """99 Bucket='string'100 """101 return client.get_bucket_replication(**kwargs)102@sts_conn('s3')103@paginated('AnalyticsConfigurationList', request_pagination_marker="ContinuationToken",104 response_pagination_marker="NextContinuationToken")105@rate_limited()106def list_bucket_analytics_configurations(client=None, **kwargs):107 """108 Bucket='string'...
s3_description.py
Source:s3_description.py
1import boto32import splunksdc.log as logging3import description as desc4import splunk_ta_aws.common.ta_aws_consts as tac5from botocore.client import Config6from botocore.exceptions import ClientError7logger = logging.get_module_logger()8skipped_error_code_list = ['NoSuchLifecycleConfiguration',9 'NoSuchCORSConfiguration', 'NoSuchTagSet',10 'UnsupportedArgument']11@desc.refresh_credentials12def s3_buckets(config):13 s3_client = desc.BotoRetryWrapper(boto_client=boto3.client(14 's3',15 region_name=config.get(tac.region),16 aws_access_key_id=config[tac.key_id],17 aws_secret_access_key=config[tac.secret_key],18 aws_session_token=config.get('aws_session_token'),19 config=Config(signature_version='s3v4')20 ))21 bucket_arr = s3_client.list_buckets()['Buckets']22 if bucket_arr is not None and len(bucket_arr) > 0:23 for bucket in bucket_arr:24 # add account id25 # TODO assume role changes this26 bucket[tac.account_id] = config[tac.account_id]27 # add other info28 for operation in ['get_bucket_accelerate_configuration',29 'get_bucket_cors', 'get_bucket_lifecycle',30 'get_bucket_location', 'get_bucket_logging',31 'get_bucket_tagging']:32 try:33 response = getattr(s3_client, operation)(Bucket = bucket['Name'])34 response.pop('ResponseMetadata', None)35 # http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETlocation.html#RESTBucketGETlocation-responses-response-elements36 # if location is us-east-1, it will return None37 if operation == 'get_bucket_location' and response['LocationConstraint'] is None:38 response['LocationConstraint'] = 'us-east-1'39 bucket.update(response)40 except ClientError as client_error:41 if 'Code' not in client_error.response['Error'] or client_error.response['Error']['Code'] not in skipped_error_code_list:42 logger.exception('%s operation is invalid in %s bucket.' % (operation, bucket['Name']))43 continue44 except Exception:45 logger.exception('An error occurred when attempting %s operation on %s bucket.' % (operation, bucket['Name']))46 continue47 bucket[tac.region] = bucket['LocationConstraint']...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!