mypy-boto3-notificationscontacts Type Stubs
mypy-boto3-notificationscontacts provides type annotations for the `boto3` AWS UserNotificationsContacts service. It is part of the `mypy-boto3-builder` project, which frequently releases updates to keep pace with `boto3` and `botocore` releases, ensuring up-to-date and accurate type hints for AWS service clients. The current version is 1.42.3.
Warnings
- breaking Starting with `mypy-boto3-builder` version 8.12.0 (which generates these stubs), Python 3.8 is no longer supported. Ensure your project uses Python 3.9 or newer.
- breaking The `mypy-boto3-builder` project migrated to PEP 561 compliant packages (with `py.typed` markers) in version 8.12.0. While this generally improves type checker integration, older `mypy` versions or custom `mypy` configurations might need adjustments if stubs are not being picked up correctly.
- gotcha This package provides *only* type stubs. You must explicitly install `boto3` (e.g., `pip install boto3`) for your code to run at runtime. These stubs are for static analysis by tools like `mypy`.
- gotcha This specific package (`mypy-boto3-notificationscontacts`) provides type stubs for the AWS UserNotificationsContacts service only. If you need type stubs for multiple or all `boto3` services, consider installing the `mypy-boto3` meta-package or individual service stubs as needed to avoid potential conflicts or missing types.
- deprecated AWS services can be deprecated, renamed, or replaced, which will be reflected in `mypy-boto3` packages. For example, `sms-voice` was removed in `builder` 8.11.0, replaced by `pinpoint-sms-voice`. Always check the `mypy-boto3-builder` release notes for changes affecting service availability or naming.
Install
-
pip install mypy-boto3-notificationscontacts boto3
Imports
- NotificationsContactsClient
from mypy_boto3_notificationscontacts.client import NotificationsContactsClient
- NotificationsContactsServiceResource
from mypy_boto3_notificationscontacts.service_resource import NotificationsContactsServiceResource
- ContactChannelTypeDef
from mypy_boto3_notificationscontacts.type_defs import ContactChannelTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
import os
# Ensure boto3 is installed: pip install boto3
# Ensure stubs are installed: pip install mypy-boto3-notificationscontacts
if TYPE_CHECKING:
from mypy_boto3_notificationscontacts.client import NotificationsContactsClient
from mypy_boto3_notificationscontacts.type_defs import ListContactChannelsResponseTypeDef
def get_notifications_contacts_client() -> "NotificationsContactsClient":
# Use environment variables for credentials in production
# Example: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME
return boto3.client(
"notifications-contacts",
region_name=os.environ.get('AWS_REGION', 'us-east-1')
)
client = get_notifications_contacts_client()
try:
# Example: Listing contact channels
response: ListContactChannelsResponseTypeDef = client.list_contact_channels()
print("Successfully listed contact channels:")
for channel in response.get("ContactChannels", []):
print(f" - Channel ID: {channel.get('ChannelId')}, Type: {channel.get('ChannelType')}")
except client.exceptions.ClientError as e:
print(f"Error calling list_contact_channels: {e}")
if e.response.get('Error', {}).get('Code') == 'AccessDeniedException':
print("Check your AWS credentials and IAM permissions for NotificationsContacts.")
# Example: Creating a contact (requires specific parameters and permissions)
# try:
# create_contact_response = client.create_contact(
# ContactAlias="my-contact",
# DisplayName="My Contact",
# Type="PERSONAL", # or 'STANDARD'
# # 'Plan': {'Stage': [{'StageName': 'Default', 'DurationInMinutes': 5, 'Targets': [...]}]}
# )
# print(f"Created contact: {create_contact_response.get('ContactArn')}")
# except client.exceptions.ClientError as e:
# print(f"Error creating contact: {e}")