SNS odběry

Introduction to AWS Boto in Python

Maksim Pecherskiy

Data Engineer

Seznam odběrů

Seznam odběrů

Introduction to AWS Boto in Python

Seznam odběrů

Seznam odběrů

Introduction to AWS Boto in Python

Seznam odběrů

Seznam odběrů

Introduction to AWS Boto in Python

Seznam odběrů

Seznam odběrů

Introduction to AWS Boto in Python

Vytvoření SMS odběru

sns = boto3.client('sns', 
                   region_name='us-east-1', 
                   aws_access_key_id=AWS_KEY_ID,                   
                   aws_secret_access_key=AWS_SECRET)
response = sns.subscribe(
  TopicArn = 'arn:aws:sns:us-east-1:320333787981:city_alerts',
  Protocol = 'SMS',
  Endpoint = '+13125551123')
Introduction to AWS Boto in Python

Vytvoření SMS odběru

Vytvoření SMS odběru

Introduction to AWS Boto in Python

Vytvoření e-mailového odběru

response = sns.subscribe(
  TopicArn = 'arn:aws:sns:us-east-1:320333787981:city_alerts', 
  Protocol='email', 
  Endpoint='[email protected]')
Introduction to AWS Boto in Python

Vytvoření e-mailového odběru

Vytvoření e-mailového odběru

Introduction to AWS Boto in Python

Vytvoření e-mailového odběru

Vytvoření e-mailového odběru

Potvrzení e-mailové adresy Potvrdit e-mail

Introduction to AWS Boto in Python

Výpis odběrů podle tématu

sns.list_subscriptions_by_topic(
  TopicArn='arn:aws:sns:us-east-1:320333787981:city_alerts')
Introduction to AWS Boto in Python

Výpis odběrů

Seznam odběrů

Introduction to AWS Boto in Python

Výpis odběrů

sns.list_subscriptions()['Subscriptions']
Introduction to AWS Boto in Python

Odstranění odběrů

sns.unsubscribe(
  SubscriptionArn='arn:aws:sns:us-east-1:320333787981:city_alerts:9f2dad1d-8844-4fe8-86f7-3f627ae8420f'
)
Introduction to AWS Boto in Python

Odstranění více odběrů

Získání seznamu odběrů

response = sns.list_subscriptions_by_topic(
  TopicArn='arn:aws:sns:us-east-1:320333787981:city_alerts')
subs = response['Subscriptions']

Zrušení SMS odběrů

for sub in subs:
  if sub['Protocol'] == 'sms':
    sns.unsubscribe(sub['SubscriptionArn'])
Introduction to AWS Boto in Python

Shrnutí

SMS
  • Protocol='sms'
  • Endpoint='+13122334433'
  • Status: 'confirmed'
Email
Introduction to AWS Boto in Python

Shrnutí

Vytvoření odběru

response = sns.subscribe(
  TopicArn = 'arn:aws:sns:us-east-1:320333787981:city_alerts',
  Protocol = 'sms',
  Endpoint = '+13125551123')

Výpis odběrů podle tématu

response = sns.list_subscriptions_by_topic(
  TopicArn='arn:aws:sns:us-east-1:320333787981:city_alerts')
subs = response['Subscriptions']
Introduction to AWS Boto in Python

Shrnutí

Výpis odběrů

sns.list_subscriptions()['Subscriptions']

Odstranění odběru

sns.unsubscribe(
  SubscriptionArn='arn:aws:sns:us-east-1:320333787981:city_alerts:9f2dad1d-8844-4fe8-86f7-3f627ae8420f'
)
Introduction to AWS Boto in Python

Lass uns üben!

Introduction to AWS Boto in Python

Preparing Video For Download...