Table of Contents
SNS.
Client
¶A low-level client representing Amazon Simple Notification Service (SNS):
client = session.create_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
|