]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | #!/usr/bin/python |
2 | ||
3 | import boto3 | |
4 | import sys | |
5 | ||
6 | if len(sys.argv) == 3: | |
7 | # bucket name as first argument | |
8 | bucketname = sys.argv[1] | |
9 | # notification name as second argument | |
10 | notification_name = sys.argv[2] | |
11 | elif len(sys.argv) == 2: | |
12 | # bucket name as first argument | |
13 | bucketname = sys.argv[1] | |
14 | notification_name = "" | |
15 | else: | |
f67539c2 | 16 | print('Usage: ' + sys.argv[0] + ' <bucket> [notification]') |
9f95a23c TL |
17 | sys.exit(1) |
18 | ||
19 | # endpoint and keys from vstart | |
20 | endpoint = 'http://127.0.0.1:8000' | |
21 | access_key='0555b35654ad1656d804' | |
22 | secret_key='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==' | |
23 | ||
24 | client = boto3.client('s3', | |
25 | endpoint_url=endpoint, | |
26 | aws_access_key_id=access_key, | |
27 | aws_secret_access_key=secret_key) | |
28 | ||
20effc67 | 29 | # deleting a specific notification configuration from a bucket (when NotificationId is provided) or |
9f95a23c TL |
30 | # deleting all notification configurations on a bucket (without deleting the bucket itself) are extension to AWS S3 API |
31 | ||
32 | if notification_name == "": | |
f67539c2 | 33 | print(client.delete_bucket_notification_configuration(Bucket=bucketname)) |
9f95a23c | 34 | else: |
f67539c2 TL |
35 | print(client.delete_bucket_notification_configuration(Bucket=bucketname, |
36 | Notification=notification_name)) |