Type annotations for boto3 CloudWatchObservabilityAccessManager

1.42.3 · active · verified Sat Apr 11

mypy-boto3-oam provides type annotations for the boto3 CloudWatchObservabilityAccessManager service, enabling static type checking and improved IDE support for AWS SDK for Python (boto3) users. It is generated with `mypy-boto3-builder 8.12.0` and currently stands at version 1.42.3, aligning with the versioning of `boto3` for which it provides stubs. The `mypy-boto3` project actively releases updates, often in sync with `boto3` and `botocore` releases, as well as `mypy-boto3-builder` updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `CloudWatchObservabilityAccessManagerClient` using `boto3` and `mypy-boto3-oam`. It includes a `TYPE_CHECKING` guard for conditional imports, which is a common practice to avoid runtime dependencies on stub packages. Replace placeholder credentials or ensure your environment is configured for AWS authentication.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_oam.client import CloudWatchObservabilityAccessManagerClient

def get_oam_client() -> 'CloudWatchObservabilityAccessManagerClient':
    """Gets a type-hinted CloudWatch Observability Access Manager client."""
    # In a real application, credentials would be managed by boto3's configuration
    # or environment variables.
    client: CloudWatchObservabilityAccessManagerClient = boto3.client(
        "oam",
        region_name="us-east-1",
        aws_access_key_id="{}".format(os.environ.get('AWS_ACCESS_KEY_ID', '')) if os.environ.get('AWS_ACCESS_KEY_ID') else None,
        aws_secret_access_key="{}".format(os.environ.get('AWS_SECRET_ACCESS_KEY', '')) if os.environ.get('AWS_SECRET_ACCESS_KEY') else None
    )
    return client

# Example usage (will not actually call AWS without valid credentials)
oam_client = get_oam_client()
print(f"Client type: {type(oam_client)}")
# mypy will now correctly infer methods like oam_client.list_attachments()
# without requiring a runtime call.

view raw JSON →