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.