Skip to content

SNSClient#

Index > SNS > SNSClient

Auto-generated documentation for SNS type annotations stubs module mypy-boto3-sns.

SNSClient#

Type annotations and code completion for boto3.client("sns"). boto3 documentation

# SNSClient usage example

from boto3.session import Session
from mypy_boto3_sns.client import SNSClient

def get_sns_client() -> SNSClient:
    return Session().client("sns")

Exceptions#

boto3 client exceptions are generated in runtime. This class provides code completion for boto3.client("sns").exceptions structure.

# Exceptions.exceptions usage example

client = boto3.client("sns")

try:
    do_something(client)
except (
    client.exceptions.AuthorizationErrorException,
    client.exceptions.BatchEntryIdsNotDistinctException,
    client.exceptions.BatchRequestTooLongException,
    client.exceptions.ClientError,
    client.exceptions.ConcurrentAccessException,
    client.exceptions.EmptyBatchRequestException,
    client.exceptions.EndpointDisabledException,
    client.exceptions.FilterPolicyLimitExceededException,
    client.exceptions.InternalErrorException,
    client.exceptions.InvalidBatchEntryIdException,
    client.exceptions.InvalidParameterException,
    client.exceptions.InvalidParameterValueException,
    client.exceptions.InvalidSecurityException,
    client.exceptions.InvalidStateException,
    client.exceptions.KMSAccessDeniedException,
    client.exceptions.KMSDisabledException,
    client.exceptions.KMSInvalidStateException,
    client.exceptions.KMSNotFoundException,
    client.exceptions.KMSOptInRequired,
    client.exceptions.KMSThrottlingException,
    client.exceptions.NotFoundException,
    client.exceptions.OptedOutException,
    client.exceptions.PlatformApplicationDisabledException,
    client.exceptions.ReplayLimitExceededException,
    client.exceptions.ResourceNotFoundException,
    client.exceptions.StaleTagException,
    client.exceptions.SubscriptionLimitExceededException,
    client.exceptions.TagLimitExceededException,
    client.exceptions.TagPolicyException,
    client.exceptions.ThrottledException,
    client.exceptions.TooManyEntriesInBatchRequestException,
    client.exceptions.TopicLimitExceededException,
    client.exceptions.UserErrorException,
    client.exceptions.ValidationException,
    client.exceptions.VerificationException,
) as e:
    print(e)
# Exceptions.exceptions type checking example

from mypy_boto3_sns.client import Exceptions

def handle_error(exc: Exceptions.AuthorizationErrorException) -> None:
    ...

Methods#

add_permission#

Adds a statement to a topic's access control policy, granting access for the specified Amazon Web Services accounts to the specified actions.

Type annotations and code completion for boto3.client("sns").add_permission method. boto3 documentation

# add_permission method definition

def add_permission(
    self,
    *,
    TopicArn: str,
    Label: str,
    AWSAccountId: Sequence[str],
    ActionName: Sequence[str],
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# add_permission method usage example with argument unpacking

kwargs: AddPermissionInputRequestTypeDef = {  # (1)
    "TopicArn": ...,
    "Label": ...,
    "AWSAccountId": ...,
    "ActionName": ...,
}

parent.add_permission(**kwargs)
  1. See AddPermissionInputRequestTypeDef

can_paginate#

Check if an operation can be paginated.

Type annotations and code completion for boto3.client("sns").can_paginate method. boto3 documentation

# can_paginate method definition

def can_paginate(
    self,
    operation_name: str,
) -> bool:
    ...

check_if_phone_number_is_opted_out#

Accepts a phone number and indicates whether the phone holder has opted out of receiving SMS messages from your Amazon Web Services account.

Type annotations and code completion for boto3.client("sns").check_if_phone_number_is_opted_out method. boto3 documentation

# check_if_phone_number_is_opted_out method definition

def check_if_phone_number_is_opted_out(
    self,
    *,
    phoneNumber: str,
) -> CheckIfPhoneNumberIsOptedOutResponseTypeDef:  # (1)
    ...
  1. See CheckIfPhoneNumberIsOptedOutResponseTypeDef
# check_if_phone_number_is_opted_out method usage example with argument unpacking

kwargs: CheckIfPhoneNumberIsOptedOutInputRequestTypeDef = {  # (1)
    "phoneNumber": ...,
}

parent.check_if_phone_number_is_opted_out(**kwargs)
  1. See CheckIfPhoneNumberIsOptedOutInputRequestTypeDef

close#

Closes underlying endpoint connections.

Type annotations and code completion for boto3.client("sns").close method. boto3 documentation

# close method definition

def close(
    self,
) -> None:
    ...

confirm_subscription#

Verifies an endpoint owner's intent to receive messages by validating the token sent to the endpoint by an earlier Subscribe action.

Type annotations and code completion for boto3.client("sns").confirm_subscription method. boto3 documentation

# confirm_subscription method definition

def confirm_subscription(
    self,
    *,
    TopicArn: str,
    Token: str,
    AuthenticateOnUnsubscribe: str = ...,
) -> ConfirmSubscriptionResponseTypeDef:  # (1)
    ...
  1. See ConfirmSubscriptionResponseTypeDef
# confirm_subscription method usage example with argument unpacking

kwargs: ConfirmSubscriptionInputRequestTypeDef = {  # (1)
    "TopicArn": ...,
    "Token": ...,
}

parent.confirm_subscription(**kwargs)
  1. See ConfirmSubscriptionInputRequestTypeDef

create_platform_application#

Creates a platform application object for one of the supported push notification services, such as APNS and GCM (Firebase Cloud Messaging), to which devices and mobile apps may register.

Type annotations and code completion for boto3.client("sns").create_platform_application method. boto3 documentation

# create_platform_application method definition

def create_platform_application(
    self,
    *,
    Name: str,
    Platform: str,
    Attributes: Mapping[str, str],
) -> CreatePlatformApplicationResponseTypeDef:  # (1)
    ...
  1. See CreatePlatformApplicationResponseTypeDef
# create_platform_application method usage example with argument unpacking

kwargs: CreatePlatformApplicationInputRequestTypeDef = {  # (1)
    "Name": ...,
    "Platform": ...,
    "Attributes": ...,
}

parent.create_platform_application(**kwargs)
  1. See CreatePlatformApplicationInputRequestTypeDef

create_platform_endpoint#

Creates an endpoint for a device and mobile app on one of the supported push notification services, such as GCM (Firebase Cloud Messaging) and APNS.

Type annotations and code completion for boto3.client("sns").create_platform_endpoint method. boto3 documentation

# create_platform_endpoint method definition

def create_platform_endpoint(
    self,
    *,
    PlatformApplicationArn: str,
    Token: str,
    CustomUserData: str = ...,
    Attributes: Mapping[str, str] = ...,
) -> CreateEndpointResponseTypeDef:  # (1)
    ...
  1. See CreateEndpointResponseTypeDef
# create_platform_endpoint method usage example with argument unpacking

kwargs: CreatePlatformEndpointInputRequestTypeDef = {  # (1)
    "PlatformApplicationArn": ...,
    "Token": ...,
}

parent.create_platform_endpoint(**kwargs)
  1. See CreatePlatformEndpointInputRequestTypeDef

create_sms_sandbox_phone_number#

Adds a destination phone number to an Amazon Web Services account in the SMS sandbox and sends a one-time password (OTP) to that phone number.

Type annotations and code completion for boto3.client("sns").create_sms_sandbox_phone_number method. boto3 documentation

# create_sms_sandbox_phone_number method definition

def create_sms_sandbox_phone_number(
    self,
    *,
    PhoneNumber: str,
    LanguageCode: LanguageCodeStringType = ...,  # (1)
) -> Dict[str, Any]:
    ...
  1. See LanguageCodeStringType
# create_sms_sandbox_phone_number method usage example with argument unpacking

kwargs: CreateSMSSandboxPhoneNumberInputRequestTypeDef = {  # (1)
    "PhoneNumber": ...,
}

parent.create_sms_sandbox_phone_number(**kwargs)
  1. See CreateSMSSandboxPhoneNumberInputRequestTypeDef

create_topic#

Creates a topic to which notifications can be published.

Type annotations and code completion for boto3.client("sns").create_topic method. boto3 documentation

# create_topic method definition

def create_topic(
    self,
    *,
    Name: str,
    Attributes: Mapping[str, str] = ...,
    Tags: Sequence[TagTypeDef] = ...,  # (1)
    DataProtectionPolicy: str = ...,
) -> CreateTopicResponseTypeDef:  # (2)
    ...
  1. See TagTypeDef
  2. See CreateTopicResponseTypeDef
# create_topic method usage example with argument unpacking

kwargs: CreateTopicInputRequestTypeDef = {  # (1)
    "Name": ...,
}

parent.create_topic(**kwargs)
  1. See CreateTopicInputRequestTypeDef

delete_endpoint#

Deletes the endpoint for a device and mobile app from Amazon SNS.

Type annotations and code completion for boto3.client("sns").delete_endpoint method. boto3 documentation