SNS¶
boto.sns¶
-
boto.sns.
connect_to_region
(region_name, **kw_params)¶ Given a valid region name, return a
boto.sns.connection.SNSConnection
.Type: str Parameters: region_name – The name of the region to connect to. Return type: boto.sns.connection.SNSConnection
orNone
Returns: A connection to the given region, or None if an invalid region name is given
-
boto.sns.
get_region
(region_name, **kw_params)¶ Find and return a
boto.regioninfo.RegionInfo
object given a region name.Type: str Param: The name of the region. Return type: boto.regioninfo.RegionInfo
Returns: The RegionInfo object for the given region or None if an invalid region name is provided.
-
boto.sns.
regions
()¶ Get all available regions for the SNS service.
Return type: list Returns: A list of boto.regioninfo.RegionInfo
instances
-
class
boto.sns.
SNSConnection
(aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/', security_token=None)¶ -
APIVersion
= '2010-03-31'¶
-
DefaultRegionEndpoint
= 'sns.us-east-1.amazonaws.com'¶
-
DefaultRegionName
= 'us-east-1'¶
-
add_permission
(topic, label, account_ids, actions)¶ Adds a statement to a topic’s access control policy, granting access for the specified AWS accounts to the specified actions.
Parameters: - topic (string) – The ARN of the topic.
- label (string) – A unique identifier for the new policy statement.
- account_ids (list of strings) – The AWS account ids of the users who will be give access to the specified actions.
- actions (list of strings) – The actions you want to allow for each of the specified principal(s).
-
confirm_subscription
(topic, token, authenticate_on_unsubscribe=False)¶ Get properties of a Topic
Parameters:
-
get_all_subscriptions
(next_token=None)¶ Get list of all subscriptions.
Parameters: next_token (string) – Token returned by the previous call to this method.
-
get_all_subscriptions_by_topic
(topic, next_token=None)¶ Get list of all subscriptions to a specific topic.
Parameters:
-
get_all_topics
(next_token=None)¶ Parameters: next_token (string) – Token returned by the previous call to this method.
-
get_topic_attributes
(topic)¶ Get attributes of a Topic
Parameters: topic (string) – The ARN of the topic.
-
publish
(topic, message, subject=None)¶ Get properties of a Topic
Parameters:
-
remove_permission
(topic, label)¶ Removes a statement from a topic’s access control policy.
Parameters:
-
set_topic_attributes
(topic, attr_name, attr_value)¶ Get attributes of a Topic
Parameters:
-
subscribe
(topic, protocol, endpoint)¶ Subscribe to a Topic.
Parameters: - topic (string) – The name of the new topic.
- protocol (string) – The protocol used to communicate with the subscriber. Current choices are: email|email-json|http|https|sqs
- endpoint (string) – The location of the endpoint for the subscriber. * For email, this would be a valid email address * For email-json, this would be a valid email address * For http, this would be a URL beginning with http * For https, this would be a URL beginning with https * For sqs, this would be the ARN of an SQS Queue
-
subscribe_sqs_queue
(topic, queue)¶ Subscribe an SQS queue to a topic.
This is convenience method that handles most of the complexity involved in using an SQS queue as an endpoint for an SNS topic. To achieve this the following operations are performed:
- The correct ARN is constructed for the SQS queue and that ARN is then subscribed to the topic.
- A JSON policy document is contructed that grants permission to the SNS topic to send messages to the SQS queue.
- This JSON policy is then associated with the SQS queue using the queue’s set_attribute method. If the queue already has a policy associated with it, this process will add a Statement to that policy. If no policy exists, a new policy will be created.
Parameters: - topic (string) – The name of the new topic.
- queue (A boto Queue object) – The queue you wish to subscribe to the SNS Topic.
-