Type Annotations for boto3 Runtime for Bedrock Data Automation

1.42.44 · active · verified Sat Apr 11

mypy-boto3-bedrock-data-automation-runtime provides type annotations for the `boto3` AWS SDK, specifically for the `RuntimeforBedrockDataAutomation` service, ensuring type safety and improved IDE auto-completion. It is part of the `mypy-boto3-builder` ecosystem, currently at version 1.42.44, and follows a frequent release cadence, often synchronizing with `boto3` updates to provide up-to-date type information.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a type-hinted client for the Bedrock Data Automation Runtime service using `boto3` and its corresponding `mypy-boto3` stubs. It includes a placeholder for calling a common operation like `list_tags_for_resource`, highlighting how type checking enhances development.

import boto3
from mypy_boto3_bedrock_data_automation_runtime.client import RuntimeforBedrockDataAutomationClient
from os import environ

def get_bedrock_data_automation_runtime_client() -> RuntimeforBedrockDataAutomationClient:
    """
    Initializes and returns a typed Bedrock Data Automation Runtime client.
    """
    # Using environment variables for AWS credentials is a common practice
    # and makes the example runnable without hardcoding.
    # In a real application, boto3 will automatically look for credentials
    # in various locations (e.g., ~/.aws/credentials, IAM roles).
    aws_access_key_id = environ.get('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY')
    aws_secret_access_key = environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')
    aws_region = environ.get('AWS_REGION', 'us-east-1')

    # The actual boto3 client is untyped; mypy-boto3 provides the type hint.
    client: RuntimeforBedrockDataAutomationClient = boto3.client(
        "bedrock-data-automation-runtime",
        region_name=aws_region,
        aws_access_key_id=aws_access_key_id,
        aws_secret_access_key=aws_secret_access_key
    )
    return client

if __name__ == "__main__":
    bedrock_data_automation_client = get_bedrock_data_automation_runtime_client()
    print(f"Successfully created Bedrock Data Automation Runtime client: {bedrock_data_automation_client}")

    # Example of calling a method (requires a valid resourceARN for actual execution)
    # This demonstrates type-checked interaction with the client.
    # In a real application, consult AWS Bedrock Data Automation Runtime API docs for valid operations.
    try:
        # Replace with a real resource ARN if you want to run this successfully
        response = bedrock_data_automation_client.list_tags_for_resource(resourceARN="arn:aws:bedrock:us-east-1:123456789012:data-automation/example")
        print("list_tags_for_resource call successful:")
        print(response)
    except Exception as e:
        print(f"Caught exception during list_tags_for_resource call (expected if ARN is not real): {e}")

view raw JSON →