Type Annotations for aiobotocore Route53

3.4.0 · active · verified Wed Apr 15

Provides static type checking for `aiobotocore`'s Route53 service using `mypy`. It enhances asynchronous AWS operations in Python by offering precise type hints for clients, requests, and responses. The project is actively maintained, with frequent releases that often align with `boto3`/`aiobotocore` updates and `mypy-boto3-builder` improvements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `types-aiobotocore-route53` to provide type hints for an `aiobotocore` Route53 client. It initializes an asynchronous client and fetches a list of hosted zones, leveraging the provided TypedDicts for type-safe access to the response structure.

import asyncio
from aiobotocore.session import get_session
from types_aiobotocore_route53 import Route53Client, Route53ServiceName
from types_aiobotocore_route53.type_defs import ListHostedZonesResponseTypeDef, HostedZoneSummaryTypeDef

async def main():
    # Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
    session = get_session()
    async with session.create_client(Route53ServiceName.route53) as client: # type: Route53Client
        print(f"Successfully created Route53 client: {type(client)}")
        try:
            response: ListHostedZonesResponseTypeDef = await client.list_hosted_zones()
            print(f"Number of hosted zones: {len(response['HostedZones'])}")
            for zone: HostedZoneSummaryTypeDef in response['HostedZones']:
                print(f"  ID: {zone['Id']}, Name: {zone['Name']}, Public: {not zone['Config']['PrivateZone']}")
        except Exception as e:
            print(f"An error occurred: {e}")

if __name__ == "__main__":
    asyncio.run(main())

view raw JSON →