mypy-boto3-rum: CloudWatchRUM Type Stubs

1.42.3 · active · verified Sat Apr 11

mypy-boto3-rum provides type annotations for the `boto3` CloudWatchRUM service, enhancing static analysis with tools like Mypy and Pyright. It is part of the `mypy-boto3` family of packages, generated by `mypy-boto3-builder`. The library is actively maintained with frequent updates, aligning with `boto3` releases to ensure up-to-date type information.

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize a `boto3` CloudWatchRUM client and use it to list app monitors, benefiting from `mypy-boto3-rum`'s type annotations for improved code completion and static analysis. Explicit type hints are included for better IDE support.

import boto3
from typing import TYPE_CHECKING

# For explicit type hinting, especially helpful for IDEs
if TYPE_CHECKING:
    from mypy_boto3_rum.client import CloudWatchRUMClient
    from mypy_boto3_rum.type_defs import ListAppMonitorsResponseTypeDef


def get_rum_client() -> 'CloudWatchRUMClient':
    """Initializes and returns a typed CloudWatchRUM client."""
    # Mypy will correctly infer the type of 'client' if mypy-boto3-rum is installed
    client: CloudWatchRUMClient = boto3.client('rum')
    return client


def list_rum_app_monitors():
    client = get_rum_client()
    try:
        response: ListAppMonitorsResponseTypeDef = client.list_app_monitors()
        print(f"Found {len(response.get('AppMonitorSummaries', []))} app monitors.")
        for monitor_summary in response.get('AppMonitorSummaries', []):
            print(f"  - {monitor_summary.get('Name')}: {monitor_summary.get('Id')}")
    except client.exceptions.ResourceNotFoundException:
        print("No CloudWatch RUM app monitors found.")
    except Exception as e:
        print(f"An error occurred: {e}")


if __name__ == '__main__':
    # This assumes AWS credentials are configured (e.g., via ~/.aws/credentials or env vars)
    # For a real application, consider explicit region and credentials
    list_rum_app_monitors()

view raw JSON →