How to use put_bucket_inventory_configuration method in localstack

Best Python code snippet using localstack_python

test_bucket_inventory.py

Source:test_bucket_inventory.py Github

copy

Full Screen

...48 included_object_versions=INVENTORY_INCLUDED_OBJECT_VERSIONS_ALL,49 inventory_filter=InventoryFilter(prefix="obj-prefix"),50 optional_fields=optional_fields,51 inventory_destination=InventoryDestination(bucket_destination=bucket_destination))52 self.bucket1.put_bucket_inventory_configuration(inventory_configuration);53 result = self.bucket1.get_bucket_inventory_configuration(inventory_id = inventory_id);54 self.assertEquals(inventory_id, result.inventory_id)55 self.assertEquals(True, result.is_enabled)56 self.assertEquals(INVENTORY_FREQUENCY_WEEKLY, result.inventory_schedule.frequency)57 self.assertEquals(INVENTORY_INCLUDED_OBJECT_VERSIONS_ALL, result.included_object_versions)58 self.assertEquals("obj-prefix", result.inventory_filter.prefix)59 self.assertEquals(len(optional_fields), len(result.optional_fields))60 ret_bucket_destin = result.inventory_destination.bucket_destination61 self.assertEquals(OSS_INVENTORY_BUCKET_DESTINATION_ACCOUNT, ret_bucket_destin.account_id)62 self.assertEquals(OSS_INVENTORY_BUCKET_DESTINATION_ARN, ret_bucket_destin.role_arn)63 self.assertEquals(dest_bucket_name, ret_bucket_destin.bucket)64 self.assertEquals(INVENTORY_FORMAT_CSV, ret_bucket_destin.inventory_format)65 self.assertEquals("destination-prefix", ret_bucket_destin.prefix)66 self.assertIsNone(ret_bucket_destin.sse_kms_encryption)67 self.assertIsNotNone(ret_bucket_destin.sse_oss_encryption)68 self.bucket1.delete_bucket_inventory_configuration(inventory_id)69 dest_bucket.delete_bucket()70 def test_error_bucket_encryption(self):71 # both encryption set.72 self.assertRaises(oss2.exceptions.ClientError, InventoryBucketDestination,73 account_id=OSS_INVENTORY_BUCKET_DESTINATION_ACCOUNT, 74 role_arn=OSS_INVENTORY_BUCKET_DESTINATION_ARN,75 bucket="test-bucket-name",76 inventory_format=INVENTORY_FORMAT_CSV,77 prefix="test-",78 sse_kms_encryption = InventoryServerSideEncryptionKMS("test-kms-id"),79 sse_oss_encryption=InventoryServerSideEncryptionOSS()) 80 def test_list_few_bucket_inventory(self):81 auth = oss2.Auth(OSS_ID, OSS_SECRET)82 dest_bucket_name = OSS_BUCKET + "-test-inventory-dest"83 dest_bucket = oss2.Bucket(auth, self.endpoint, dest_bucket_name)84 dest_bucket.create_bucket()85 inventory_id_prefix = "test-id-"86 for index in range(0, 3):87 inventory_id = inventory_id_prefix + str(index)88 optional_fields = [FIELD_SIZE, FIELD_LAST_MODIFIED_DATE, FIELD_STORAG_CLASS,89 FIELD_ETAG, FIELD_IS_MULTIPART_UPLOADED, FIELD_ENCRYPTION_STATUS]90 bucket_destination = InventoryBucketDestination(91 account_id=OSS_INVENTORY_BUCKET_DESTINATION_ACCOUNT, 92 role_arn=OSS_INVENTORY_BUCKET_DESTINATION_ARN,93 bucket=dest_bucket_name,94 inventory_format=INVENTORY_FORMAT_CSV,95 prefix="destination-prefix",96 sse_kms_encryption=InventoryServerSideEncryptionKMS("test-kms-id"))97 inventory_configuration = InventoryConfiguration(98 inventory_id=inventory_id,99 is_enabled=True, 100 inventory_schedule=InventorySchedule(frequency=INVENTORY_FREQUENCY_DAILY),101 included_object_versions=INVENTORY_INCLUDED_OBJECT_VERSIONS_CURRENT,102 inventory_filter=InventoryFilter(prefix="obj-prefix"),103 optional_fields=optional_fields,104 inventory_destination=InventoryDestination(bucket_destination=bucket_destination))105 self.bucket1.put_bucket_inventory_configuration(inventory_configuration);106 107 # test with param empty108 result = self.bucket1.list_bucket_inventory_configurations('')109 self.assertEquals(3, len(result.inventory_configurations))110 self.assertEquals(False, result.is_truncated)111 self.assertEquals(None, result.continuaiton_token)112 self.assertEquals(None, result.next_continuation_token)113 # test with param None114 result = self.bucket1.list_bucket_inventory_configurations()115 self.assertEquals(3, len(result.inventory_configurations))116 self.assertEquals(False, result.is_truncated)117 self.assertEquals(None, result.continuaiton_token)118 self.assertEquals(None, result.next_continuation_token)119 dest_bucket.delete_bucket()120 def test_list_lot_bucket_inventory(self):121 auth = oss2.Auth(OSS_ID, OSS_SECRET)122 dest_bucket_name = OSS_BUCKET + "-test-inventory-dest"123 dest_bucket = oss2.Bucket(auth, self.endpoint, dest_bucket_name)124 dest_bucket.create_bucket()125 inventory_id_prefix = "test-id-"126 for index in range(0, 120):127 inventory_id = inventory_id_prefix + str(index)128 optional_fields = [FIELD_SIZE, FIELD_LAST_MODIFIED_DATE, FIELD_STORAG_CLASS,129 FIELD_ETAG, FIELD_IS_MULTIPART_UPLOADED, FIELD_ENCRYPTION_STATUS]130 bucket_destination = InventoryBucketDestination(131 account_id=OSS_INVENTORY_BUCKET_DESTINATION_ACCOUNT, 132 role_arn=OSS_INVENTORY_BUCKET_DESTINATION_ARN,133 bucket=dest_bucket_name,134 inventory_format=INVENTORY_FORMAT_CSV,135 prefix="destination-prefix",136 sse_kms_encryption=InventoryServerSideEncryptionKMS("test-kms-id"))137 inventory_configuration = InventoryConfiguration(138 inventory_id=inventory_id,139 is_enabled=True, 140 inventory_schedule=InventorySchedule(frequency=INVENTORY_FREQUENCY_DAILY),141 included_object_versions=INVENTORY_INCLUDED_OBJECT_VERSIONS_CURRENT,142 inventory_filter=InventoryFilter(prefix="obj-prefix"),143 optional_fields=optional_fields,144 inventory_destination=InventoryDestination(bucket_destination=bucket_destination))145 self.bucket1.put_bucket_inventory_configuration(inventory_configuration);146 result = self.bucket1.list_bucket_inventory_configurations()147 self.assertEquals(100, len(result.inventory_configurations))148 self.assertEquals(True, result.is_truncated)149 self.assertEquals(None, result.continuaiton_token)150 self.assertIsNotNone(result.next_continuation_token)151 next_continuation_token = result.next_continuation_token152 result = self.bucket1.list_bucket_inventory_configurations(next_continuation_token)153 self.assertEquals(20, len(result.inventory_configurations))154 self.assertEquals(False, result.is_truncated)155 self.assertEquals(next_continuation_token, result.continuaiton_token)156 self.assertEquals(None, result.next_continuation_token)157 dest_bucket.delete_bucket()158 def test_list_none_inventory(self):159 self.assertRaises(oss2.exceptions.NoSuchInventory, self.bucket1.list_bucket_inventory_configurations)...

Full Screen

Full Screen

bucket_put_inventory.py

Source:bucket_put_inventory.py Github

copy

Full Screen

...26import boto327if __name__ == "__main__":28 client = boto3.client('s3')29 bucketname = "us-west-2.nag"30 inventory_config = client.put_bucket_inventory_configuration(Bucket=bucketname, InventoryConfiguration=config, Id="nag")...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful