mypy-boto3-connecthealth

1.42.62 · active · verified Wed Apr 15

mypy-boto3-connecthealth provides static type annotations for the `boto3` AWS SDK's ConnectHealth service. Generated with `mypy-boto3-builder` (version 8.12.0 for the current package version), it enhances developer experience by enabling comprehensive type checking, improved IDE auto-completion, and early error detection for `boto3` code interacting with AWS ConnectHealth. The library is actively maintained with frequent updates reflecting `boto3` releases and new AWS services.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` ConnectHealth client with type annotations and fetch events. It includes explicit type hints for `ConnectHealthClient` and `EventTypeDef` to leverage static analysis. Ensure `boto3` is installed alongside `mypy-boto3-connecthealth`.

from typing import TYPE_CHECKING
import boto3
import os

if TYPE_CHECKING:
    from mypy_boto3_connecthealth.client import ConnectHealthClient
    from mypy_boto3_connecthealth.type_defs import EventTypeDef


def get_connect_health_events(region_name: str) -> list["EventTypeDef"]:
    # boto3 client creation without explicit type hint will still work
    # but explicit type hints provide better IDE support and type checking
    client: ConnectHealthClient = boto3.client(
        "connect-health",
        region_name=region_name,
        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', ''),
        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', ''),
        aws_session_token=os.environ.get('AWS_SESSION_TOKEN', '')
    )

    # Example: Describe events (Connect Health operations might require specific permissions)
    try:
        response = client.describe_events(
            Filter={
                'EventType': {'Values': ['AWS_HEALTH_EVENT']}
            }
        )
        return response['Events']
    except client.exceptions.InvalidRequestException as e:
        print(f"Error describing events: {e}")
        return []

if __name__ == "__main__":
    events = get_connect_health_events("us-east-1")
    print(f"Found {len(events)} Connect Health events.")
    for event in events:
        print(f"  - Event ARN: {event['eventArn']}")

view raw JSON →