mypy-boto3-cloudhsmv2

1.42.3 · active · verified Sat Apr 11

mypy-boto3-cloudhsmv2 provides type annotations (stubs) for the `boto3` AWS SDK, specifically for the CloudHSMV2 service. It enhances development experience by enabling static type checking for `boto3` clients and responses. The library is currently at version 1.42.3, with releases closely mirroring `boto3` service updates and more frequent updates for the underlying `mypy-boto3-builder`.

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `mypy-boto3-cloudhsmv2` for type-hinted interaction with the CloudHSMV2 service. It shows how to obtain a type-annotated client and call an operation (`describe_clusters`), with type checkers verifying argument and return types. For actual execution, ensure AWS credentials are configured in your environment.

import boto3
from mypy_boto3_cloudhsmv2.client import CloudHSMV2Client
from mypy_boto3_cloudhsmv2.type_defs import DescribeClustersResponseTypeDef
import os # For example credentials

def get_cloudhsmv2_clusters() -> None:
    # Ensure AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials)
    # For this example to run without errors, ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, 
    # and AWS_REGION are set in your environment if not using IAM roles or config files.
    
    # The type annotation helps type checkers understand the client's methods and return types.
    client: CloudHSMV2Client = boto3.client("cloudhsmv2", region_name=os.environ.get('AWS_REGION', 'us-east-1'))
    
    try:
        response: DescribeClustersResponseTypeDef = client.describe_clusters()
        print("Successfully described CloudHSM V2 clusters:")
        for cluster in response.get('Clusters', []):
            print(f"  - Cluster ID: {cluster.get('ClusterId')}, State: {cluster.get('State')}")
    except Exception as e:
        print(f"Error describing clusters: {e}")

if __name__ == "__main__":
    # This code requires valid AWS credentials to run successfully.
    # For type checking, simply running `mypy your_script.py` is sufficient.
    get_cloudhsmv2_clusters()

view raw JSON →