Type Annotations for Boto3 Bedrock Agent Core Control

1.42.87 · active · verified Sat Apr 11

This library provides PEP 561-compliant type annotations for the `boto3` Bedrock Agent Core Control service, enabling static type checking with tools like `mypy`. It helps developers catch type-related errors early and improves IDE autocompletion for `boto3`. The current version is 1.42.87, and it is updated frequently to align with new `boto3` releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` client with `mypy-boto3` type hints for the Bedrock Agent Core Control service. It shows typical usage of type-hinted request and response dictionaries. Remember to install `boto3` separately.

import boto3
from mypy_boto3_bedrock_agent_core_control.client import BedrockAgentCoreControlClient
from mypy_boto3_bedrock_agent_core_control.type_defs import ListAgentsRequestRequestTypeDef, ListAgentsResponseTypeDef
from typing import TYPE_CHECKING, cast

# Ensure boto3 is configured, e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME env vars
# This example does not use actual credentials, but they would be needed for a real call.

# Use TYPE_CHECKING for type hints that are not needed at runtime
if TYPE_CHECKING:
    # Cast the boto3 client to the specific type stub for better type checking
    client: BedrockAgentCoreControlClient = cast(BedrockAgentCoreControlClient, boto3.client("bedrock-agent-core-control"))
else:
    client = boto3.client("bedrock-agent-core-control")

# Example of using a typed request and response
try:
    request: ListAgentsRequestRequestTypeDef = {
        "maxResults": 10
    }
    response: ListAgentsResponseTypeDef = client.list_agents(**request)

    print(f"Successfully listed agents. Total agents found: {len(response.get('agentSummaries', []))}")
    for agent in response.get('agentSummaries', []):
        print(f"  - Agent ID: {agent['agentId']}, Status: {agent['agentStatus']}")
except Exception as e:
    print(f"Error listing agents: {e}")
    print("Ensure your AWS credentials and region are configured correctly and Bedrock Agent Core Control is available.")

view raw JSON →