mypy-boto3-mediapackage: Type Annotations for AWS MediaPackage

1.42.3 · active · verified Sat Apr 11

mypy-boto3-mediapackage provides type annotations for the boto3 MediaPackage 1.42.3 service. It enables static type checking for AWS MediaPackage clients within Python applications, enhancing code quality and developer experience. The library is generated by `mypy-boto3-builder` and is actively maintained with frequent updates, often aligning with new boto3 releases and builder improvements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` MediaPackage client and apply type annotations from `mypy-boto3-mediapackage`. Explicitly typing the client (`mediapackage_client: MediaPackageClient`) is crucial for enabling comprehensive type checking and autocompletion in IDEs.

import os
from boto3.session import Session
from mypy_boto3_mediapackage.client import MediaPackageClient

# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
# For example: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME
# Using os.environ.get for example purposes, in real apps boto3 handles credentials automatically.
if not os.environ.get('AWS_ACCESS_KEY_ID'):
    print("Warning: AWS_ACCESS_KEY_ID not set. Quickstart might fail if credentials are not configured.")

session = Session()

# Explicitly type the client for full type-hinting and autocompletion
mediapackage_client: MediaPackageClient = session.client("mediapackage")

# Example: List origin endpoints (replace with an actual method if needed)
try:
    response = mediapackage_client.list_origin_endpoints()
    print("Successfully listed MediaPackage origin endpoints.")
    for endpoint in response.get('OriginEndpoints', []):
        print(f" - Endpoint ID: {endpoint.get('Id')}, ARN: {endpoint.get('Arn')}")
except Exception as e:
    print(f"Error listing origin endpoints: {e}")

view raw JSON →