mypy-boto3-cloudsearchdomain Type Stubs for AWS CloudSearchDomain
This library provides type annotations for the `boto3` CloudSearchDomain service (version 1.42.3), generated by `mypy-boto3-builder` 8.12.0. It allows static type checking with tools like MyPy, enhancing code quality and developer experience when working with AWS CloudSearchDomain using `boto3`. The package closely follows `boto3` releases, offering frequent updates to maintain compatibility.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 should upgrade to Python 3.9 or newer.
- breaking The `mypy-boto3` project migrated to PEP 561-compliant packages starting with `mypy-boto3-builder` 8.12.0. This might change how some tools discover or interpret the stubs. If you encounter issues, ensure your type checker (e.g., MyPy) is up-to-date and correctly configured for PEP 561 packages.
- breaking In `mypy-boto3-builder` version 8.9.0, there were changes to how TypeDef names for packed method arguments are generated (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). If you directly import and reference these TypedDicts in your code, they might need renaming.
- gotcha The `cloudsearchdomain` service client (`boto3.client('cloudsearchdomain')`) requires a domain-specific `endpoint_url` for operations like `search` and `upload_documents`. Without it, these calls will fail. The endpoint must be retrieved from the `cloudsearch` configuration service using `boto3.client('cloudsearch').describe_domains()`.
- gotcha This package provides *only* type annotations (stubs). To actually run your code, you must also install the `boto3` library itself (`pip install boto3`).
Install
-
pip install mypy-boto3-cloudsearchdomain boto3
Imports
- CloudSearchDomainClient
from mypy_boto3_cloudsearchdomain import CloudSearchDomainClient
- CloudSearchDomainClient
from mypy_boto3_cloudsearchdomain.client import CloudSearchDomainClient
Quickstart
import os
import boto3
from mypy_boto3_cloudsearchdomain import CloudSearchDomainClient
# The CloudSearchDomain client often requires an explicit endpoint_url.
# In a real application, you would retrieve this dynamically from
# boto3.client("cloudsearch").describe_domains().
# Replace with your actual CloudSearch domain search endpoint URL or set as env var.
CLOUDSEARCH_DOMAIN_ENDPOINT = os.environ.get(
"CLOUDSEARCH_DOMAIN_ENDPOINT",
"https://search-your-domain-xyz.us-east-1.cloudsearch.amazonaws.com" # Placeholder
)
try:
# Create a type-hinted CloudSearchDomain client
client: CloudSearchDomainClient = boto3.client(
"cloudsearchdomain",
endpoint_url=CLOUDSEARCH_DOMAIN_ENDPOINT,
# region_name=os.environ.get("AWS_REGION", "us-east-1") # Optional
)
# Perform a dummy search operation (requires a valid domain and query)
# This call will likely fail if CLOUDSEARCH_DOMAIN_ENDPOINT is not valid or domain is empty.
response = client.search(
query="example",
queryParser="simple"
)
print(f"Search found {response.get('hits', {}).get('found', 0)} items.")
# Further operations with type-checked client...
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure 'CLOUDSEARCH_DOMAIN_ENDPOINT' is set to a valid CloudSearch domain search endpoint.")
print("You might need to use `boto3.client('cloudsearch').describe_domains()` to obtain it.")
print("Also, verify AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials).")