Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block

Set up notifications

Notifications can be configured following:

Code Block
languagepy
#!/usr/bin/python3
import boto3

access_key_id='xx' # from Cypher
secret_access_key='xx'  # from Cypher 
ceph_endpoint = "https://s3.waw3-1.cloudferro.com"
region = 'waw3-1'  # required by boto3, any value works 

bucket_name = "reflectivity.composite.opera.hdf5"

s3 = boto3.client('s3',
                endpoint_url=ceph_endpoint ,
                aws_access_key_id=access_key_id,
                aws_secret_access_key=secret_access_key)

# Create notification configuration
response = s3.put_bucket_notification_configuration(
    Bucket=bucket_name,
    NotificationConfiguration={
        'TopicConfigurations': [
            {
                'Id': 'test-http-topic',
                'TopicArn': 'arn:aws:sns:waw3-1::example-topic',
                'Events': ['s3:ObjectCreated:*']
            }
        ]
    }
)




List topics

Available topics can be listed following:

Code Block
#!/usr/bin/python3

import boto3

access_key_id = 'xx' # stored in Cypher
secret_access_key = 'xx' # stored in Cypher

ceph_endpoint = 'https://s3.waw3-1.cloudferro.com'
region_name = 'waw3-1' # required by boto3, any value works

s3 = boto3.client('sns',
region_name=region_name,
endpoint_url= ceph_endpoint,
aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key)

response = s3.list_topics()

# Print the Topic ARNs
print('All topics:')
for topic in response['Topics']:
print(' -'+topic['TopicArn'])

Delete topics

Code Block