Table of Contents
SNS.
Client
¶A low-level client representing Amazon Simple Notification Service (SNS):
import boto3
client = boto3.client('sns')
These are the available methods:
add_permission()
can_paginate()
confirm_subscription()
create_platform_application()
create_platform_endpoint()
create_topic()
delete_endpoint()
delete_platform_application()
delete_topic()
generate_presigned_url()
get_endpoint_attributes()
get_paginator()
get_platform_application_attributes()
get_subscription_attributes()
get_topic_attributes()
get_waiter()
list_endpoints_by_platform_application()
list_platform_applications()
list_subscriptions()
list_subscriptions_by_topic()
list_topics()
publish()
remove_permission()
set_endpoint_attributes()
set_platform_application_attributes()
set_subscription_attributes()
set_topic_attributes()
subscribe()
unsubscribe()
add_permission
(**kwargs)¶Adds a statement to a topic's access control policy, granting access for the specified AWS accounts to the specified actions.
Request Syntax
response = client.add_permission(
TopicArn='string',
Label='string',
AWSAccountId=[
'string',
],
ActionName=[
'string',
]
)
Parameters: |
|
---|---|
Returns: | None |
can_paginate
(operation_name)¶Check if an operation can be paginated.
Parameters: | operation_name (string) -- The operation name. This is the same name
as the method name on the client. For example, if the
method name is create_foo , and you'd normally invoke the
operation as client.create_foo(**kwargs) , if the
create_foo operation can be paginated, you can use the
call client.get_paginator("create_foo") . |
---|---|
Returns: | True if the operation can be paginated,
False otherwise. |
confirm_subscription
(**kwargs)¶Verifies an endpoint owner's intent to receive messages by validating the token sent to the endpoint by an earlier Subscribe
action. If the token is valid, the action creates a new subscription and returns its Amazon Resource Name (ARN). This call requires an AWS signature only when the AuthenticateOnUnsubscribe
flag is set to "true".
Request Syntax
response = client.confirm_subscription(
TopicArn='string',
Token='string',
AuthenticateOnUnsubscribe='string'
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'SubscriptionArn': 'string'
}
Response Structure
|
create_platform_application
(**kwargs)¶Creates a platform application object for one of the supported push notification services, such as APNS and GCM, to which devices and mobile apps may register. You must specify PlatformPrincipal and PlatformCredential attributes when using the CreatePlatformApplication
action. The PlatformPrincipal is received from the notification service. For APNS/APNS_SANDBOX, PlatformPrincipal is "SSL certificate". For GCM, PlatformPrincipal is not applicable. For ADM, PlatformPrincipal is "client id". The PlatformCredential is also received from the notification service. For APNS/APNS_SANDBOX, PlatformCredential is "private key". For GCM, PlatformCredential is "API key". For ADM, PlatformCredential is "client secret". The PlatformApplicationArn that is returned when using CreatePlatformApplication
is then used as an attribute for the CreatePlatformEndpoint
action. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = client.create_platform_application(
Name='string',
Platform='string',
Attributes={
'string': 'string'
}
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'PlatformApplicationArn': 'string'
}
Response Structure
|
create_platform_endpoint
(**kwargs)¶Creates an endpoint for a device and mobile app on one of the supported push notification services, such as GCM and APNS. CreatePlatformEndpoint
requires the PlatformApplicationArn that is returned from CreatePlatformApplication
. The EndpointArn that is returned when using CreatePlatformEndpoint
can then be used by the Publish
action to send a message to a mobile app or by the Subscribe
action for subscription to a topic. The CreatePlatformEndpoint
action is idempotent, so if the requester already owns an endpoint with the same device token and attributes, that endpoint's ARN is returned without creating a new endpoint. For more information, see Using Amazon SNS Mobile Push Notifications .
When using CreatePlatformEndpoint
with Baidu, two attributes must be provided: ChannelId and UserId. The token field must also contain the ChannelId. For more information, see Creating an Amazon SNS Endpoint for Baidu .
Request Syntax
response = client.create_platform_endpoint(
PlatformApplicationArn='string',
Token='string',
CustomUserData='string',
Attributes={
'string': 'string'
}
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'EndpointArn': 'string'
}
Response Structure
|
create_topic
(**kwargs)¶Creates a topic to which notifications can be published. Users can create at most 3000 topics. For more information, see http://aws.amazon.com/sns . This action is idempotent, so if the requester already owns a topic with the specified name, that topic's ARN is returned without creating a new topic.
Request Syntax
response = client.create_topic(
Name='string'
)
Parameters: | Name (string) -- [REQUIRED] The name of the topic you want to create. Constraints: Topic names must be made up of only uppercase and lowercase ASCII letters, numbers, underscores, and hyphens, and must be between 1 and 256 characters long. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'TopicArn': 'string'
}
Response Structure
|
delete_endpoint
(**kwargs)¶Deletes the endpoint from Amazon SNS. This action is idempotent. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = client.delete_endpoint(
EndpointArn='string'
)
Parameters: | EndpointArn (string) -- [REQUIRED] EndpointArn of endpoint to delete. |
---|---|
Returns: | None |
delete_platform_application
(**kwargs)¶Deletes a platform application object for one of the supported push notification services, such as APNS and GCM. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = client.delete_platform_application(
PlatformApplicationArn='string'
)
Parameters: | PlatformApplicationArn (string) -- [REQUIRED] PlatformApplicationArn of platform application object to delete. |
---|---|
Returns: | None |
delete_topic
(**kwargs)¶Deletes a topic and all its subscriptions. Deleting a topic might prevent some messages previously sent to the topic from being delivered to subscribers. This action is idempotent, so deleting a topic that does not exist does not result in an error.
Request Syntax
response = client.delete_topic(
TopicArn='string'
)
Parameters: | TopicArn (string) -- [REQUIRED] The ARN of the topic you want to delete. |
---|---|
Returns: | None |
generate_presigned_url
(ClientMethod, Params=None, ExpiresIn=3600, HttpMethod=None)¶Generate a presigned url given a client, its method, and arguments
Parameters: |
|
---|---|
Returns: | The presigned url |
get_endpoint_attributes
(**kwargs)¶Retrieves the endpoint attributes for a device on one of the supported push notification services, such as GCM and APNS. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = client.get_endpoint_attributes(
EndpointArn='string'
)
Parameters: | EndpointArn (string) -- [REQUIRED] EndpointArn for GetEndpointAttributes input. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Attributes': {
'string': 'string'
}
}
Response Structure
|
get_paginator
(operation_name)¶Create a paginator for an operation.
Parameters: | operation_name (string) -- The operation name. This is the same name
as the method name on the client. For example, if the
method name is create_foo , and you'd normally invoke the
operation as client.create_foo(**kwargs) , if the
create_foo operation can be paginated, you can use the
call client.get_paginator("create_foo") . |
---|---|
Raises OperationNotPageableError: | |
Raised if the operation is not
pageable. You can use the client.can_paginate method to
check if an operation is pageable. |
|
Return type: | L{botocore.paginate.Paginator} |
Returns: | A paginator object. |
get_platform_application_attributes
(**kwargs)¶Retrieves the attributes of the platform application object for the supported push notification services, such as APNS and GCM. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = client.get_platform_application_attributes(
PlatformApplicationArn='string'
)
Parameters: | PlatformApplicationArn (string) -- [REQUIRED] PlatformApplicationArn for GetPlatformApplicationAttributesInput. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Attributes': {
'string': 'string'
}
}
Response Structure
|
get_subscription_attributes
(**kwargs)¶Returns all of the properties of a subscription.
Request Syntax
response = client.get_subscription_attributes(
SubscriptionArn='string'
)
Parameters: | SubscriptionArn (string) -- [REQUIRED] The ARN of the subscription whose properties you want to get. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Attributes': {
'string': 'string'
}
}
Response Structure
|
get_topic_attributes
(**kwargs)¶Returns all of the properties of a topic. Topic properties returned might differ based on the authorization of the user.
Request Syntax
response = client.get_topic_attributes(
TopicArn='string'
)
Parameters: | TopicArn (string) -- [REQUIRED] The ARN of the topic whose properties you want to get. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Attributes': {
'string': 'string'
}
}
Response Structure
|
get_waiter
(waiter_name)¶list_endpoints_by_platform_application
(**kwargs)¶Lists the endpoints and endpoint attributes for devices in a supported push notification service, such as GCM and APNS. The results for ListEndpointsByPlatformApplication
are paginated and return a limited list of endpoints, up to 100. If additional records are available after the first page results, then a NextToken string will be returned. To receive the next page, you call ListEndpointsByPlatformApplication
again using the NextToken string received from the previous call. When there are no more records to return, NextToken will be null. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = client.list_endpoints_by_platform_application(
PlatformApplicationArn='string',
NextToken='string'
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'Endpoints': [
{
'EndpointArn': 'string',
'Attributes': {
'string': 'string'
}
},
],
'NextToken': 'string'
}
Response Structure
|
list_platform_applications
(**kwargs)¶Lists the platform application objects for the supported push notification services, such as APNS and GCM. The results for ListPlatformApplications
are paginated and return a limited list of applications, up to 100. If additional records are available after the first page results, then a NextToken string will be returned. To receive the next page, you call ListPlatformApplications
using the NextToken string received from the previous call. When there are no more records to return, NextToken will be null. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = client.list_platform_applications(
NextToken='string'
)
Parameters: | NextToken (string) -- NextToken string is used when calling ListPlatformApplications action to retrieve additional records that are available after the first page results. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'PlatformApplications': [
{
'PlatformApplicationArn': 'string',
'Attributes': {
'string': 'string'
}
},
],
'NextToken': 'string'
}
Response Structure
|
list_subscriptions
(**kwargs)¶Returns a list of the requester's subscriptions. Each call returns a limited list of subscriptions, up to 100. If there are more subscriptions, a NextToken
is also returned. Use the NextToken
parameter in a new ListSubscriptions
call to get further results.
Request Syntax
response = client.list_subscriptions(
NextToken='string'
)
Parameters: | NextToken (string) -- Token returned by the previous ListSubscriptions request. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Subscriptions': [
{
'SubscriptionArn': 'string',
'Owner': 'string',
'Protocol': 'string',
'Endpoint': 'string',
'TopicArn': 'string'
},
],
'NextToken': 'string'
}
Response Structure
|
list_subscriptions_by_topic
(**kwargs)¶Returns a list of the subscriptions to a specific topic. Each call returns a limited list of subscriptions, up to 100. If there are more subscriptions, a NextToken
is also returned. Use the NextToken
parameter in a new ListSubscriptionsByTopic
call to get further results.
Request Syntax
response = client.list_subscriptions_by_topic(
TopicArn='string',
NextToken='string'
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'Subscriptions': [
{
'SubscriptionArn': 'string',
'Owner': 'string',
'Protocol': 'string',
'Endpoint': 'string',
'TopicArn': 'string'
},
],
'NextToken': 'string'
}
Response Structure
|
list_topics
(**kwargs)¶Returns a list of the requester's topics. Each call returns a limited list of topics, up to 100. If there are more topics, a NextToken
is also returned. Use the NextToken
parameter in a new ListTopics
call to get further results.
Request Syntax
response = client.list_topics(
NextToken='string'
)
Parameters: | NextToken (string) -- Token returned by the previous ListTopics request. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Topics': [
{
'TopicArn': 'string'
},
],
'NextToken': 'string'
}
Response Structure
|
publish
(**kwargs)¶Sends a message to all of a topic's subscribed endpoints. When a messageId
is returned, the message has been saved and Amazon SNS will attempt to deliver it to the topic's subscribers shortly. The format of the outgoing message to each subscribed endpoint depends on the notification protocol selected.
To use the Publish
action for sending a message to a mobile endpoint, such as an app on a Kindle device or mobile phone, you must specify the EndpointArn. The EndpointArn is returned when making a call with the CreatePlatformEndpoint
action. The second example below shows a request and response for publishing to a mobile endpoint.
Request Syntax
response = client.publish(
TopicArn='string',
TargetArn='string',
Message='string',
Subject='string',
MessageStructure='string',
MessageAttributes={
'string': {
'DataType': 'string',
'StringValue': 'string',
'BinaryValue': b'bytes'
}
}
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'MessageId': 'string'
}
Response Structure
|
remove_permission
(**kwargs)¶Removes a statement from a topic's access control policy.
Request Syntax
response = client.remove_permission(
TopicArn='string',
Label='string'
)
Parameters: |
|
---|---|
Returns: | None |
set_endpoint_attributes
(**kwargs)¶Sets the attributes for an endpoint for a device on one of the supported push notification services, such as GCM and APNS. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = client.set_endpoint_attributes(
EndpointArn='string',
Attributes={
'string': 'string'
}
)
Parameters: |
|
---|---|
Returns: | None |
set_platform_application_attributes
(**kwargs)¶Sets the attributes of the platform application object for the supported push notification services, such as APNS and GCM. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = client.set_platform_application_attributes(
PlatformApplicationArn='string',
Attributes={
'string': 'string'
}
)
Parameters: |
|
---|---|
Returns: | None |
set_subscription_attributes
(**kwargs)¶Allows a subscription owner to set an attribute of the topic to a new value.
Request Syntax
response = client.set_subscription_attributes(
SubscriptionArn='string',
AttributeName='string',
AttributeValue='string'
)
Parameters: |
|
---|---|
Returns: | None |
set_topic_attributes
(**kwargs)¶Allows a topic owner to set an attribute of the topic to a new value.
Request Syntax
response = client.set_topic_attributes(
TopicArn='string',
AttributeName='string',
AttributeValue='string'
)
Parameters: |
|
---|---|
Returns: | None |
subscribe
(**kwargs)¶Prepares to subscribe an endpoint by sending the endpoint a confirmation message. To actually create a subscription, the endpoint owner must call the ConfirmSubscription
action with the token from the confirmation message. Confirmation tokens are valid for three days.
Request Syntax
response = client.subscribe(
TopicArn='string',
Protocol='string',
Endpoint='string'
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'SubscriptionArn': 'string'
}
Response Structure
|
unsubscribe
(**kwargs)¶Deletes a subscription. If the subscription requires authentication for deletion, only the owner of the subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the Unsubscribe
call does not require authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the endpoint owner can easily resubscribe to the topic if the Unsubscribe
request was unintended.
Request Syntax
response = client.unsubscribe(
SubscriptionArn='string'
)
Parameters: | SubscriptionArn (string) -- [REQUIRED] The ARN of the subscription to be deleted. |
---|---|
Returns: | None |
The available paginators are:
SNS.Paginator.list_endpoints_by_platform_application
SNS.Paginator.list_platform_applications
SNS.Paginator.list_subscriptions
SNS.Paginator.list_subscriptions_by_topic
SNS.Paginator.list_topics
SNS.Paginator.
list_endpoints_by_platform_application
¶paginator = client.get_paginator('list_endpoints_by_platform_application')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from SNS.Client.list_endpoints_by_platform_application()
.
Request Syntax
response_iterator = paginator.paginate(
PlatformApplicationArn='string',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'Endpoints': [
{
'EndpointArn': 'string',
'Attributes': {
'string': 'string'
}
},
],
}
Response Structure
|
SNS.Paginator.
list_platform_applications
¶paginator = client.get_paginator('list_platform_applications')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from SNS.Client.list_platform_applications()
.
Request Syntax
response_iterator = paginator.paginate(
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
Parameters: | PaginationConfig (dict) -- A dictionary that provides parameters to control pagination.
|
---|---|
Return type: | dict |
Returns: | Response Syntax{
'PlatformApplications': [
{
'PlatformApplicationArn': 'string',
'Attributes': {
'string': 'string'
}
},
],
}
Response Structure
|
SNS.Paginator.
list_subscriptions
¶paginator = client.get_paginator('list_subscriptions')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from SNS.Client.list_subscriptions()
.
Request Syntax
response_iterator = paginator.paginate(
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
Parameters: | PaginationConfig (dict) -- A dictionary that provides parameters to control pagination.
|
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Subscriptions': [
{
'SubscriptionArn': 'string',
'Owner': 'string',
'Protocol': 'string',
'Endpoint': 'string',
'TopicArn': 'string'
},
],
}
Response Structure
|
SNS.Paginator.
list_subscriptions_by_topic
¶paginator = client.get_paginator('list_subscriptions_by_topic')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from SNS.Client.list_subscriptions_by_topic()
.
Request Syntax
response_iterator = paginator.paginate(
TopicArn='string',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'Subscriptions': [
{
'SubscriptionArn': 'string',
'Owner': 'string',
'Protocol': 'string',
'Endpoint': 'string',
'TopicArn': 'string'
},
],
}
Response Structure
|
SNS.Paginator.
list_topics
¶paginator = client.get_paginator('list_topics')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from SNS.Client.list_topics()
.
Request Syntax
response_iterator = paginator.paginate(
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
Parameters: | PaginationConfig (dict) -- A dictionary that provides parameters to control pagination.
|
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Topics': [
{
'TopicArn': 'string'
},
],
}
Response Structure
|
SNS.
ServiceResource
¶A resource representing Amazon Simple Notification Service (SNS):
import boto3
sns = boto3.resource('sns')
These are the resource's available actions:
These are the resource's available sub-resources:
These are the resource's available collections:
Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
create_platform_application
(**kwargs)¶Creates a platform application object for one of the supported push notification services, such as APNS and GCM, to which devices and mobile apps may register. You must specify PlatformPrincipal and PlatformCredential attributes when using the CreatePlatformApplication
action. The PlatformPrincipal is received from the notification service. For APNS/APNS_SANDBOX, PlatformPrincipal is "SSL certificate". For GCM, PlatformPrincipal is not applicable. For ADM, PlatformPrincipal is "client id". The PlatformCredential is also received from the notification service. For APNS/APNS_SANDBOX, PlatformCredential is "private key". For GCM, PlatformCredential is "API key". For ADM, PlatformCredential is "client secret". The PlatformApplicationArn that is returned when using CreatePlatformApplication
is then used as an attribute for the CreatePlatformEndpoint
action. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
platform_application = sns.create_platform_application(
Name='string',
Platform='string',
Attributes={
'string': 'string'
}
)
Parameters: |
|
---|---|
Return type: |
|
Returns: | A PlatformApplication resource |
create_topic
(**kwargs)¶Creates a topic to which notifications can be published. Users can create at most 3000 topics. For more information, see http://aws.amazon.com/sns . This action is idempotent, so if the requester already owns a topic with the specified name, that topic's ARN is returned without creating a new topic.
Request Syntax
topic = sns.create_topic(
Name='string'
)
Parameters: | Name (string) -- [REQUIRED] The name of the topic you want to create. Constraints: Topic names must be made up of only uppercase and lowercase ASCII letters, numbers, underscores, and hyphens, and must be between 1 and 256 characters long. |
---|---|
Return type: | sns.Topic |
Returns: | A Topic resource |
Sub-resources
Sub-resources are methods that create a new instance of a child resource. This resource's identifiers get passed along to the child. For more information about sub-resources refer to the Resources Introduction Guide.
PlatformApplication
(arn)¶Creates a PlatformApplication resource.:
platform_application = sns.PlatformApplication('arn')
Parameters: | arn (string) -- The PlatformApplication's arn identifier. This must be set. |
---|---|
Return type: | SNS.PlatformApplication |
Returns: | A PlatformApplication resource |
PlatformEndpoint
(arn)¶Creates a PlatformEndpoint resource.:
platform_endpoint = sns.PlatformEndpoint('arn')
Parameters: | arn (string) -- The PlatformEndpoint's arn identifier. This must be set. |
---|---|
Return type: | SNS.PlatformEndpoint |
Returns: | A PlatformEndpoint resource |
Subscription
(arn)¶Creates a Subscription resource.:
subscription = sns.Subscription('arn')
Parameters: | arn (string) -- The Subscription's arn identifier. This must be set. |
---|---|
Return type: | SNS.Subscription |
Returns: | A Subscription resource |
Topic
(arn)¶Creates a Topic resource.:
topic = sns.Topic('arn')
Parameters: | arn (string) -- The Topic's arn identifier. This must be set. |
---|---|
Return type: | SNS.Topic |
Returns: | A Topic resource |
Collections
Collections provide an interface to iterate over and manipulate groups of resources. For more information about collections refer to the Resources Introduction Guide.
platform_applications
¶all
()¶Creates an iterable of all PlatformApplication resources in the collection.
Request Syntax
platform_application_iterator = sns.platform_applications.all()
Return type: | sns.PlatformApplication |
---|---|
Returns: | A PlatformApplication resource |
filter
(**kwargs)¶Creates an iterable of all PlatformApplication resources in the collection filtered by kwargs passed to method.
Request Syntax
platform_application_iterator = sns.platform_applications.filter(
NextToken='string'
)
Parameters: | NextToken (string) -- NextToken string is used when calling ListPlatformApplications action to retrieve additional records that are available after the first page results. |
---|---|
Return type: | sns.PlatformApplication |
Returns: | A PlatformApplication resource |
limit
(**kwargs)¶Creates an iterable up to a specified amount of PlatformApplication resources in the collection.
Request Syntax
platform_application_iterator = sns.platform_applications.limit(
count=123
)
Parameters: | count (integer) -- The limit to the number of resources in the iterable. |
---|---|
Return type: | sns.PlatformApplication |
Returns: | A PlatformApplication resource |
page_size
(**kwargs)¶Creates an iterable of all PlatformApplication resources in the collection, but limits the number of items returned by each service call by the specified amount.
Request Syntax
platform_application_iterator = sns.platform_applications.page_size(
count=123
)
Parameters: | count (integer) -- The number of items returned by each service call |
---|---|
Return type: | sns.PlatformApplication |
Returns: | A PlatformApplication resource |
subscriptions
¶all
()Creates an iterable of all Subscription resources in the collection.
Request Syntax
subscription_iterator = sns.subscriptions.all()
Return type: | sns.Subscription |
---|---|
Returns: | A Subscription resource |
filter
(**kwargs)Creates an iterable of all Subscription resources in the collection filtered by kwargs passed to method.
Request Syntax
subscription_iterator = sns.subscriptions.filter(
NextToken='string'
)
Parameters: | NextToken (string) -- Token returned by the previous ListSubscriptions request. |
---|---|
Return type: | sns.Subscription |
Returns: | A Subscription resource |
limit
(**kwargs)Creates an iterable up to a specified amount of Subscription resources in the collection.
Request Syntax
subscription_iterator = sns.subscriptions.limit(
count=123
)
Parameters: | count (integer) -- The limit to the number of resources in the iterable. |
---|---|
Return type: | sns.Subscription |
Returns: | A Subscription resource |
page_size
(**kwargs)Creates an iterable of all Subscription resources in the collection, but limits the number of items returned by each service call by the specified amount.
Request Syntax
subscription_iterator = sns.subscriptions.page_size(
count=123
)
Parameters: | count (integer) -- The number of items returned by each service call |
---|---|
Return type: | sns.Subscription |
Returns: | A Subscription resource |
topics
¶all
()Creates an iterable of all Topic resources in the collection.
Request Syntax
topic_iterator = sns.topics.all()
Return type: | sns.Topic |
---|---|
Returns: | A Topic resource |
filter
(**kwargs)Creates an iterable of all Topic resources in the collection filtered by kwargs passed to method.
Request Syntax
topic_iterator = sns.topics.filter(
NextToken='string'
)
Parameters: | NextToken (string) -- Token returned by the previous ListTopics request. |
---|---|
Return type: | sns.Topic |
Returns: | A Topic resource |
limit
(**kwargs)Creates an iterable up to a specified amount of Topic resources in the collection.
Request Syntax
topic_iterator = sns.topics.limit(
count=123
)
Parameters: | count (integer) -- The limit to the number of resources in the iterable. |
---|---|
Return type: | sns.Topic |
Returns: | A Topic resource |
page_size
(**kwargs)Creates an iterable of all Topic resources in the collection, but limits the number of items returned by each service call by the specified amount.
Request Syntax
topic_iterator = sns.topics.page_size(
count=123
)
Parameters: | count (integer) -- The number of items returned by each service call |
---|---|
Return type: | sns.Topic |
Returns: | A Topic resource |
SNS.
PlatformApplication
(arn)¶A resource representing an Amazon Simple Notification Service (SNS) PlatformApplication:
import boto3
sns = boto3.resource('sns')
platform_application = sns.PlatformApplication('arn')
Parameters: | arn (string) -- The PlatformApplication's arn identifier. This must be set. |
---|
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
These are the resource's available collections:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
arn
¶(string) The PlatformApplication's arn identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load()
method.
For more information about attributes refer to the Resources Introduction Guide.
attributes
¶(dict)
Attributes include the following:
EventEndpointCreated
-- Topic ARN to which EndpointCreated event notifications should be sent.EventEndpointDeleted
-- Topic ARN to which EndpointDeleted event notifications should be sent.EventEndpointUpdated
-- Topic ARN to which EndpointUpdate event notifications should be sent.EventDeliveryFailure
-- Topic ARN to which DeliveryFailure event notifications should be sent upon Direct Publish delivery failure (permanent) to one of the application's endpoints.Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
create_platform_endpoint
(**kwargs)¶Creates an endpoint for a device and mobile app on one of the supported push notification services, such as GCM and APNS. CreatePlatformEndpoint
requires the PlatformApplicationArn that is returned from CreatePlatformApplication
. The EndpointArn that is returned when using CreatePlatformEndpoint
can then be used by the Publish
action to send a message to a mobile app or by the Subscribe
action for subscription to a topic. The CreatePlatformEndpoint
action is idempotent, so if the requester already owns an endpoint with the same device token and attributes, that endpoint's ARN is returned without creating a new endpoint. For more information, see Using Amazon SNS Mobile Push Notifications .
When using CreatePlatformEndpoint
with Baidu, two attributes must be provided: ChannelId and UserId. The token field must also contain the ChannelId. For more information, see Creating an Amazon SNS Endpoint for Baidu .
Request Syntax
platform_endpoint = platform_application.create_platform_endpoint(
Token='string',
CustomUserData='string',
Attributes={
'string': 'string'
}
)
Parameters: |
|
---|---|
Return type: |
|
Returns: | A PlatformEndpoint resource |
delete
()¶Deletes a platform application object for one of the supported push notification services, such as APNS and GCM. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = platform_application.delete()
Returns: | None |
---|
load
()¶Calls sns.Client.get_platform_application_attributes()
to update the attributes of the PlatformApplication resource
Request Syntax
platform_application.load()
Returns: | None |
---|
reload
()¶Calls sns.Client.get_platform_application_attributes()
to update the attributes of the PlatformApplication resource
Request Syntax
platform_application.reload()
Returns: | None |
---|
set_attributes
(**kwargs)¶Sets the attributes of the platform application object for the supported push notification services, such as APNS and GCM. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = platform_application.set_attributes(
Attributes={
'string': 'string'
}
)
Parameters: | Attributes (dict) -- [REQUIRED] A map of the platform application attributes. Attributes in this map include the following:
|
---|---|
Returns: | None |
Collections
Collections provide an interface to iterate over and manipulate groups of resources. For more information about collections refer to the Resources Introduction Guide.
endpoints
¶all
()¶Creates an iterable of all PlatformEndpoint resources in the collection.
Request Syntax
platform_endpoint_iterator = platform_application.endpoints.all()
Return type: | sns.PlatformEndpoint |
---|---|
Returns: | A PlatformEndpoint resource |
filter
(**kwargs)¶Creates an iterable of all PlatformEndpoint resources in the collection filtered by kwargs passed to method.
Request Syntax
platform_endpoint_iterator = platform_application.endpoints.filter(
NextToken='string'
)
Parameters: | NextToken (string) -- NextToken string is used when calling ListEndpointsByPlatformApplication action to retrieve additional records that are available after the first page results. |
---|---|
Return type: | sns.PlatformEndpoint |
Returns: | A PlatformEndpoint resource |
limit
(**kwargs)¶Creates an iterable up to a specified amount of PlatformEndpoint resources in the collection.
Request Syntax
platform_endpoint_iterator = platform_application.endpoints.limit(
count=123
)
Parameters: | count (integer) -- The limit to the number of resources in the iterable. |
---|---|
Return type: | sns.PlatformEndpoint |
Returns: | A PlatformEndpoint resource |
page_size
(**kwargs)¶Creates an iterable of all PlatformEndpoint resources in the collection, but limits the number of items returned by each service call by the specified amount.
Request Syntax
platform_endpoint_iterator = platform_application.endpoints.page_size(
count=123
)
Parameters: | count (integer) -- The number of items returned by each service call |
---|---|
Return type: | sns.PlatformEndpoint |
Returns: | A PlatformEndpoint resource |
SNS.
PlatformEndpoint
(arn)¶A resource representing an Amazon Simple Notification Service (SNS) PlatformEndpoint:
import boto3
sns = boto3.resource('sns')
platform_endpoint = sns.PlatformEndpoint('arn')
Parameters: | arn (string) -- The PlatformEndpoint's arn identifier. This must be set. |
---|
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
arn
¶(string) The PlatformEndpoint's arn identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load()
method.
For more information about attributes refer to the Resources Introduction Guide.
attributes
¶(dict)
Attributes include the following:
CustomUserData
-- arbitrary user data to associate with the endpoint. Amazon SNS does not use this data. The data must be in UTF-8 format and less than 2KB.Enabled
-- flag that enables/disables delivery to the endpoint. Amazon SNS will set this to false when a notification service indicates to Amazon SNS that the endpoint is invalid. Users can set it back to true, typically after updating Token.Token
-- device token, also referred to as a registration id, for an app and mobile device. This is returned from the notification service when an app and mobile device are registered with the notification service.Actions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
delete
()¶Deletes the endpoint from Amazon SNS. This action is idempotent. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = platform_endpoint.delete()
Returns: | None |
---|
load
()¶Calls sns.Client.get_endpoint_attributes()
to update the attributes of the PlatformEndpoint resource
Request Syntax
platform_endpoint.load()
Returns: | None |
---|
publish
(**kwargs)¶Sends a message to all of a topic's subscribed endpoints. When a messageId
is returned, the message has been saved and Amazon SNS will attempt to deliver it to the topic's subscribers shortly. The format of the outgoing message to each subscribed endpoint depends on the notification protocol selected.
To use the Publish
action for sending a message to a mobile endpoint, such as an app on a Kindle device or mobile phone, you must specify the EndpointArn. The EndpointArn is returned when making a call with the CreatePlatformEndpoint
action. The second example below shows a request and response for publishing to a mobile endpoint.
Request Syntax
response = platform_endpoint.publish(
TopicArn='string',
Message='string',
Subject='string',
MessageStructure='string',
MessageAttributes={
'string': {
'DataType': 'string',
'StringValue': 'string',
'BinaryValue': b'bytes'
}
}
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'MessageId': 'string'
}
Response Structure
|
reload
()¶Calls sns.Client.get_endpoint_attributes()
to update the attributes of the PlatformEndpoint resource
Request Syntax
platform_endpoint.reload()
Returns: | None |
---|
set_attributes
(**kwargs)¶Sets the attributes for an endpoint for a device on one of the supported push notification services, such as GCM and APNS. For more information, see Using Amazon SNS Mobile Push Notifications .
Request Syntax
response = platform_endpoint.set_attributes(
Attributes={
'string': 'string'
}
)
Parameters: | Attributes (dict) -- [REQUIRED] A map of the endpoint attributes. Attributes in this map include the following:
|
---|---|
Returns: | None |
SNS.
Subscription
(arn)¶A resource representing an Amazon Simple Notification Service (SNS) Subscription:
import boto3
sns = boto3.resource('sns')
subscription = sns.Subscription('arn')
Parameters: | arn (string) -- The Subscription's arn identifier. This must be set. |
---|
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
arn
¶(string) The Subscription's arn identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load()
method.
For more information about attributes refer to the Resources Introduction Guide.
attributes
¶(dict)
A map of the subscription's attributes. Attributes in this map include the following:
SubscriptionArn
-- the subscription's ARNTopicArn
-- the topic ARN that the subscription is associated withOwner
-- the AWS account ID of the subscription's ownerConfirmationWasAuthenticated
-- true if the subscription confirmation request was authenticatedDeliveryPolicy
-- the JSON serialization of the subscription's delivery policyEffectiveDeliveryPolicy
-- the JSON serialization of the effective delivery policy that takes into account the topic delivery policy and account system defaultsActions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
delete
()¶Deletes a subscription. If the subscription requires authentication for deletion, only the owner of the subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the Unsubscribe
call does not require authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the endpoint owner can easily resubscribe to the topic if the Unsubscribe
request was unintended.
Request Syntax
response = subscription.delete()
Returns: | None |
---|
load
()¶Calls sns.Client.get_subscription_attributes()
to update the attributes of the Subscription resource
Request Syntax
subscription.load()
Returns: | None |
---|
reload
()¶Calls sns.Client.get_subscription_attributes()
to update the attributes of the Subscription resource
Request Syntax
subscription.reload()
Returns: | None |
---|
set_attributes
(**kwargs)¶Allows a subscription owner to set an attribute of the topic to a new value.
Request Syntax
response = subscription.set_attributes(
AttributeName='string',
AttributeValue='string'
)
Parameters: |
|
---|---|
Returns: | None |
SNS.
Topic
(arn)¶A resource representing an Amazon Simple Notification Service (SNS) Topic:
import boto3
sns = boto3.resource('sns')
topic = sns.Topic('arn')
Parameters: | arn (string) -- The Topic's arn identifier. This must be set. |
---|
These are the resource's available identifiers:
These are the resource's available attributes:
These are the resource's available actions:
add_permission()
confirm_subscription()
delete()
load()
publish()
reload()
remove_permission()
set_attributes()
subscribe()
These are the resource's available collections:
Identifiers
Identifiers are properties of a resource that are set upon instantation of the resource. For more information about identifiers refer to the Resources Introduction Guide.
arn
¶(string) The Topic's arn identifier. This must be set.
Attributes
Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the load()
method.
For more information about attributes refer to the Resources Introduction Guide.
attributes
¶(dict)
A map of the topic's attributes. Attributes in this map include the following:
TopicArn
-- the topic's ARNOwner
-- the AWS account ID of the topic's ownerPolicy
-- the JSON serialization of the topic's access control policyDisplayName
-- the human-readable name used in the "From" field for notifications to email and email-json endpointsSubscriptionsPending
-- the number of subscriptions pending confirmation on this topicSubscriptionsConfirmed
-- the number of confirmed subscriptions on this topicSubscriptionsDeleted
-- the number of deleted subscriptions on this topicDeliveryPolicy
-- the JSON serialization of the topic's delivery policyEffectiveDeliveryPolicy
-- the JSON serialization of the effective delivery policy that takes into account system defaultsActions
Actions call operations on resources. They may automatically handle the passing in of arguments set from identifiers and some attributes. For more information about actions refer to the Resources Introduction Guide.
add_permission
(**kwargs)¶Adds a statement to a topic's access control policy, granting access for the specified AWS accounts to the specified actions.
Request Syntax
response = topic.add_permission(
Label='string',
AWSAccountId=[
'string',
],
ActionName=[
'string',
]
)
Parameters: |
|
---|---|
Returns: | None |
confirm_subscription
(**kwargs)¶Verifies an endpoint owner's intent to receive messages by validating the token sent to the endpoint by an earlier Subscribe
action. If the token is valid, the action creates a new subscription and returns its Amazon Resource Name (ARN). This call requires an AWS signature only when the AuthenticateOnUnsubscribe
flag is set to "true".
Request Syntax
subscription = topic.confirm_subscription(
Token='string',
AuthenticateOnUnsubscribe='string'
)
Parameters: |
|
---|---|
Return type: |
|
Returns: | A Subscription resource |
delete
()¶Deletes a topic and all its subscriptions. Deleting a topic might prevent some messages previously sent to the topic from being delivered to subscribers. This action is idempotent, so deleting a topic that does not exist does not result in an error.
Request Syntax
response = topic.delete()
Returns: | None |
---|
load
()¶Calls sns.Client.get_topic_attributes()
to update the attributes of the Topic resource
Request Syntax
topic.load()
Returns: | None |
---|
publish
(**kwargs)¶Sends a message to all of a topic's subscribed endpoints. When a messageId
is returned, the message has been saved and Amazon SNS will attempt to deliver it to the topic's subscribers shortly. The format of the outgoing message to each subscribed endpoint depends on the notification protocol selected.
To use the Publish
action for sending a message to a mobile endpoint, such as an app on a Kindle device or mobile phone, you must specify the EndpointArn. The EndpointArn is returned when making a call with the CreatePlatformEndpoint
action. The second example below shows a request and response for publishing to a mobile endpoint.
Request Syntax
response = topic.publish(
TargetArn='string',
Message='string',
Subject='string',
MessageStructure='string',
MessageAttributes={
'string': {
'DataType': 'string',
'StringValue': 'string',
'BinaryValue': b'bytes'
}
}
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'MessageId': 'string'
}
Response Structure
|
reload
()¶Calls sns.Client.get_topic_attributes()
to update the attributes of the Topic resource
Request Syntax
topic.reload()
Returns: | None |
---|
remove_permission
(**kwargs)¶Removes a statement from a topic's access control policy.
Request Syntax
response = topic.remove_permission(
Label='string'
)
Parameters: | Label (string) -- [REQUIRED] The unique label of the statement you want to remove. |
---|---|
Returns: | None |
set_attributes
(**kwargs)¶Allows a topic owner to set an attribute of the topic to a new value.
Request Syntax
response = topic.set_attributes(
AttributeName='string',
AttributeValue='string'
)
Parameters: |
|
---|---|
Returns: | None |
subscribe
(**kwargs)¶Prepares to subscribe an endpoint by sending the endpoint a confirmation message. To actually create a subscription, the endpoint owner must call the ConfirmSubscription
action with the token from the confirmation message. Confirmation tokens are valid for three days.
Request Syntax
subscription = topic.subscribe(
Protocol='string',
Endpoint='string'
)
Parameters: |
|
---|---|
Return type: |
|
Returns: | A Subscription resource |
Collections
Collections provide an interface to iterate over and manipulate groups of resources. For more information about collections refer to the Resources Introduction Guide.
subscriptions
¶all
()¶Creates an iterable of all Subscription resources in the collection.
Request Syntax
subscription_iterator = topic.subscriptions.all()
Return type: | sns.Subscription |
---|---|
Returns: | A Subscription resource |
filter
(**kwargs)¶Creates an iterable of all Subscription resources in the collection filtered by kwargs passed to method.
Request Syntax
subscription_iterator = topic.subscriptions.filter(
NextToken='string'
)
Parameters: | NextToken (string) -- Token returned by the previous ListSubscriptionsByTopic request. |
---|---|
Return type: | sns.Subscription |
Returns: | A Subscription resource |
limit
(**kwargs)¶Creates an iterable up to a specified amount of Subscription resources in the collection.
Request Syntax
subscription_iterator = topic.subscriptions.limit(
count=123
)
Parameters: | count (integer) -- The limit to the number of resources in the iterable. |
---|---|
Return type: | sns.Subscription |
Returns: | A Subscription resource |
page_size
(**kwargs)¶Creates an iterable of all Subscription resources in the collection, but limits the number of items returned by each service call by the specified amount.
Request Syntax
subscription_iterator = topic.subscriptions.page_size(
count=123
)
Parameters: | count (integer) -- The number of items returned by each service call |
---|---|
Return type: | sns.Subscription |
Returns: | A Subscription resource |