Examples#
Auto-generated documentation for SNS type annotations stubs module types-boto3-sns.
Client#
Implicit type annotations#
Can be used with types-boto3[sns]
package installed.
Write your SNS
code as usual,
type checking and code completion should work out of the box.
# SNSClient usage example
from boto3.session import Session
session = Session()
client = session.client("sns") # (1)
result = client.add_permission() # (2)
- client: SNSClient
- result: EmptyResponseMetadataTypeDef
# ListEndpointsByPlatformApplicationPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("sns") # (1)
paginator = client.get_paginator("list_endpoints_by_platform_application") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: SNSClient
- paginator: ListEndpointsByPlatformApplicationPaginator
- item: ListEndpointsByPlatformApplicationResponseTypeDef
Explicit type annotations#
With types-boto3-lite[sns]
or a standalone types_boto3_sns
package, you have to explicitly specify client: SNSClient
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
# SNSClient usage example with type annotations
from boto3.session import Session
from types_boto3_sns.client import SNSClient
from types_boto3_sns.type_defs import EmptyResponseMetadataTypeDef
from types_boto3_sns.type_defs import AddPermissionInputRequestTypeDef
session = Session()
client: SNSClient = session.client("sns")
kwargs: AddPermissionInputRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.add_permission(**kwargs)
# ListEndpointsByPlatformApplicationPaginator usage example with type annotations
from boto3.session import Session
from types_boto3_sns.client import SNSClient
from types_boto3_sns.paginator import ListEndpointsByPlatformApplicationPaginator
from types_boto3_sns.type_defs import ListEndpointsByPlatformApplicationResponseTypeDef
session = Session()
client: SNSClient = session.client("sns")
paginator: ListEndpointsByPlatformApplicationPaginator = client.get_paginator("list_endpoints_by_platform_application")
for item in paginator.paginate(...):
item: ListEndpointsByPlatformApplicationResponseTypeDef
print(item)
Service Resource#
Implicit type annotations#
Can be used with types-boto3[sns]
package installed.
# SNSServiceResource usage example
from boto3.session import Session
session = Session()
resource = session.resource("sns") # (1)
result = resource.get_available_subresources() # (2)
- resource: SNSServiceResource
- result:
# ServiceResourcePlatformApplicationsCollection usage example
from boto3.session import Session
session = Session()
resource = session.resource("sns") # (1)
collection = resource.platform_applications # (2)
for item in collection:
print(item) # (3)
- resource: SNSServiceResource
- collection: SNSServiceResource
- item: PlatformApplication
Explicit type annotations#
With types-boto3-lite[sns]
or a standalone types_boto3_sns
package, you have to explicitly specify
resource: SNSServiceResource
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
# SNSServiceResource usage example with type annotations
from boto3.session import Session
from types_boto3_sns.service_resource import SNSServiceResource
from types_boto3_sns.service_resource import get_available_subresources
session = Session()
resource: SNSServiceResource = session.resource("sns")
result: get_available_subresources = resource.get_available_subresources()
# ServiceResourcePlatformApplicationsCollection usage example with type annotations
from boto3.session import Session
from types_boto3_sns.service_resource import SNSServiceResource
from types_boto3_sns.service_resource import ServiceResourcePlatformApplicationsCollection
from types_boto3_sns.service_resource import PlatformApplication
session = Session()
resource: SNSServiceResource = session.resource("sns")
collection: ServiceResourcePlatformApplicationsCollection = resource.platform_applications
for item in collection:
item: PlatformApplication
print(item)