mypy-boto3-controlcatalog

1.42.55 · active · verified Sat Apr 11

mypy-boto3-controlcatalog provides comprehensive type annotations for the AWS Control Catalog service within the `boto3` library. This allows static type checkers like MyPy and IDEs to offer accurate autocomplete, parameter suggestions, and error checking for your `boto3` client calls, improving code quality and developer productivity. It is generated by `mypy-boto3-builder` and its releases align with new `boto3` versions and `mypy-boto3-builder` updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `ControlCatalogClient` using `boto3` and perform a basic operation like `list_domains`. Ensure your AWS credentials and default region are configured in your environment or `~/.aws/credentials` file.

import os
from typing import TYPE_CHECKING
import boto3

if TYPE_CHECKING:
    from mypy_boto3_controlcatalog.client import ControlCatalogClient
    from mypy_boto3_controlcatalog.type_defs import ListDomainsOutputTypeDef

def get_controlcatalog_client() -> "ControlCatalogClient":
    """
    Returns a typed ControlCatalog client.
    """
    # boto3 automatically uses credentials from environment variables (e.g., AWS_ACCESS_KEY_ID)
    # or ~/.aws/credentials.
    # Replace "us-east-1" with your desired AWS region.
    session = boto3.Session(region_name=os.environ.get("AWS_REGION", "us-east-1"))
    client: "ControlCatalogClient" = session.client("controlcatalog")
    return client

if __name__ == "__main__":
    client = get_controlcatalog_client()
    try:
        # Example: List Control Catalog domains
        # Replace with an actual Control Catalog operation for your use case.
        response: "ListDomainsOutputTypeDef" = client.list_domains()
        print(f"Successfully listed {len(response.get('Domains', []))} domains.")
        for domain in response.get('Domains', []):
            print(f"- Domain ARN: {domain.get('Arn')}, Name: {domain.get('Name')}")
    except client.exceptions.ClientError as e:
        print(f"Error listing domains: {e}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

view raw JSON →