mypy-boto3-payment-cryptography-data Type Stubs
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
- breaking Starting with `mypy-boto3-builder` version 8.12.0 (which generated this package), Python 3.8 is no longer supported. Projects using this package must upgrade to Python 3.9 or newer.
- breaking The `mypy-boto3-builder` migrated to PEP 561 packages in version 8.12.0. This change primarily affects packaging and how type checkers locate stubs. While generally backward compatible, some custom build systems or older `mypy` versions might need configuration adjustments.
- gotcha These packages (`mypy-boto3-*`) provide *only* type definitions for static analysis. They do not contain any runtime code and must be installed alongside the actual `boto3` library to function correctly.
- breaking The `mypy-boto3-builder` version 8.9.0 introduced breaking changes to `TypeDef` naming conventions, simplifying long names (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`). While this package is for 'payment-cryptography-data', similar changes may apply to its `TypeDef` structures.
- gotcha When instantiating the client with `boto3.client()`, the service name string `payment-cryptography-data` must be exact. Typographical errors will lead to `UnknownServiceError` at runtime and untyped clients.
Install
-
pip install mypy-boto3-payment-cryptography-data boto3
Imports
- PaymentCryptographyDataPlaneClient
from mypy_boto3_payment_cryptography_data.client import PaymentCryptographyDataPlaneClient
- ListKeysOutputTypeDef
from mypy_boto3_payment_cryptography_data.type_defs import ListKeysOutputTypeDef
Quickstart
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.")