mypy-boto3-payment-cryptography-data Type Stubs

1.42.12 · active · verified Sat Apr 11

This package provides type annotations for the `boto3` library's `PaymentCryptographyDataPlane` service. It allows for static type checking of `boto3` client calls and responses using tools like `mypy`. The current version is 1.42.12, generated by `mypy-boto3-builder 8.12.0`, and it's released frequently to keep pace with `boto3` updates and AWS service changes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to get a type-hinted `boto3` client for Payment Cryptography Data Plane and perform a basic operation, `list_keys`. Remember that `mypy-boto3-*` packages provide only type stubs, so `boto3` must be installed alongside for runtime functionality. Ensure AWS credentials are configured for successful execution.

import boto3
from mypy_boto3_payment_cryptography_data.client import PaymentCryptographyDataPlaneClient
from mypy_boto3_payment_cryptography_data.type_defs import (
    ListKeysInputRequestTypeDef,
    ListKeysOutputTypeDef
)
import os # For accessing environment variables for auth, if needed

# This package provides type stubs for boto3, not the actual client.
# Ensure boto3 is installed: pip install boto3

# AWS credentials and region should be configured (e.g., via ~/.aws/credentials, environment variables)
# For example, ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, AWS_REGION are set or a profile is configured.

def get_payment_crypto_client() -> PaymentCryptographyDataPlaneClient:
    """Returns a type-hinted PaymentCryptographyDataPlane client."""
    # boto3.client will automatically pick up credentials from environment variables or ~/.aws/credentials
    return boto3.client(
        "payment-cryptography-data",
        region_name=os.environ.get("AWS_REGION", "us-east-1") # Example: use env var for region
    )

client: PaymentCryptographyDataPlaneClient = get_payment_crypto_client()

# Example: List keys (replace with actual logic if needed)
# This operation requires appropriate IAM permissions (e.g., payment-cryptography:ListKeys)
try:
    request: ListKeysInputRequestTypeDef = {"MaxResults": 5}
    response: ListKeysOutputTypeDef = client.list_keys(**request)
    print(f"Successfully called list_keys. Found {len(response.get('Keys', []))} keys.")
    if response.get('Keys'):
        print(f"First key ARN: {response['Keys'][0]['KeyArn']}")

except Exception as e:
    print(f"Error listing keys: {e}")
    print("\n--- Troubleshooting ---")
    print("1. Ensure you have AWS credentials configured (environment variables or ~/.aws/credentials).")
    print("2. Verify your IAM user/role has 'payment-cryptography:ListKeys' permission.")
    print("3. Check the AWS region (e.g., 'us-east-1') is correct for your resources.")
    print("\nThis quickstart primarily demonstrates type hinting; actual API calls require a valid AWS setup.")

view raw JSON →