mypy-boto3-docdb-elastic

1.42.3 · active · verified Sat Apr 11

mypy-boto3-docdb-elastic provides type annotations for the boto3 DocDBElastic service. It ensures static type checking with tools like MyPy, offering improved code quality and developer experience for AWS DocumentDB Elastic Clusters interactions. The current version is 1.42.3, generated with mypy-boto3-builder 8.12.0, and new versions are released in sync with boto3 updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate a boto3 DocDBElastic client and use it with mypy-boto3-docdb-elastic for type annotations. The `TYPE_CHECKING` block ensures type hints are only active during static analysis, avoiding runtime dependency if desired. It includes error handling for common issues like AccessDeniedException.

import boto3
from mypy_boto3_docdb_elastic import DocDBElasticClient
from typing import TYPE_CHECKING

# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
# For local execution, you might mock credentials or ensure they're available.
# For example, using environment variables:
# os.environ['AWS_ACCESS_KEY_ID'] = 'YOUR_ACCESS_KEY'
# os.environ['AWS_SECRET_ACCESS_KEY'] = 'YOUR_SECRET_KEY'
# os.environ['AWS_REGION'] = 'us-east-1'

if TYPE_CHECKING:
    client: DocDBElasticClient = boto3.client('docdb-elastic')
else:
    client = boto3.client('docdb-elastic')

try:
    # Example: List DocumentDB Elastic clusters
    response = client.list_clusters(
        maxResults=10
    )
    print(f"Successfully listed {len(response.get('Clusters', []))} clusters.")
    for cluster in response.get('Clusters', []):
        print(f"  Cluster ARN: {cluster.get('ClusterArn')}, Status: {cluster.get('Status')}")
except client.exceptions.AccessDeniedException as e:
    print(f"Authentication or authorization error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →