mypy-boto3-qapps: Type Annotations for AWS QApps

1.42.3 · active · verified Sat Apr 11

mypy-boto3-qapps provides high-quality type annotations for the `boto3` AWS QApps service client, enabling static type checking with tools like MyPy. It is generated using `mypy-boto3-builder` (currently version 8.12.0) and is updated frequently, often in sync with `boto3` and AWS API changes.

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize a `boto3` QApps client with type annotations and use a type-checked `CreateQAppRequestRequestTypeDef` for creating a QApp. The `TYPE_CHECKING` block ensures that stub imports are only active during static analysis, preventing runtime errors if stubs are a dev dependency. Remember to replace placeholder `instanceId` and `appDefinitionArn` with actual values.

import boto3
from typing import TYPE_CHECKING, Dict, Any

from mypy_boto3_qapps.client import QAppsClient
from mypy_boto3_qapps.type_defs import CreateQAppRequestRequestTypeDef, CreateQAppResponseTypeDef

# Instantiate the boto3 client, annotated with mypy-boto3 types
# Use TYPE_CHECKING block to avoid runtime dependency if stubs are dev-only
if TYPE_CHECKING:
    client: QAppsClient = boto3.client("qapps")
else:
    client = boto3.client("qapps")

# Example: Create a QApp
# Note: This is a dummy example; replace placeholder values with actual data.
# The instanceId typically refers to an Amazon Q instance.
instance_id = "your_amazon_q_instance_id" # e.g., 'your-instance-id'

create_qapp_params: CreateQAppRequestRequestTypeDef = {
    "instanceId": instance_id,
    "appDefinition": {
        "appDefinitionArn": "arn:aws:qapps:region:account:app/id", # Example ARN
        "appDefinitionType": "PACKAGE_JSON"
    }
    # "tags": {"key": "value"} # Optional
}

try:
    print(f"Attempting to create QApp for instance: {instance_id}")
    response: CreateQAppResponseTypeDef = client.create_q_app(
        **create_qapp_params
    )
    print(f"Successfully created QApp.")
    print(f"App ID: {response.get('appId')}")
    print(f"App ARN: {response.get('appArn')}")
    print(f"Status: {response.get('status')}")
except client.exceptions.ValidationException as e:
    print(f"Validation Error: {e}")
except client.exceptions.ResourceNotFoundException as e:
    print(f"Resource Not Found Error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →