mypy-boto3-payment-cryptography Type Stubs

1.42.83 · active · verified Sat Apr 11

mypy-boto3-payment-cryptography provides type annotations for the boto3 AWS Payment Cryptography Control Plane service (version 1.42.83). It is part of the `mypy-boto3-builder` project, which automatically generates comprehensive type stubs for boto3 to enable static type checking with tools like MyPy, Pyright, and enhance IDE auto-completion. The project is actively maintained, with releases typically synchronized with upstream boto3 updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `PaymentCryptographyControlPlaneClient` with type hints and how to use a `TypeDef` for request parameters. The `if TYPE_CHECKING:` block ensures that `mypy-boto3-payment-cryptography` is only a development dependency. The example attempts to create a key in AWS Payment Cryptography Control Plane.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_payment_cryptography.client import PaymentCryptographyControlPlaneClient
    from mypy_boto3_payment_cryptography.type_defs import CreateKeyInputRequestTypeDef


def create_payment_cryptography_key():
    # The 'client' variable will be type-checked as PaymentCryptographyControlPlaneClient
    client: 'PaymentCryptographyControlPlaneClient' = boto3.client(
        'payment-cryptography-control-plane'
    )

    key_alias = "alias/my-test-key"
    
    # Example of using a TypedDict for a request payload
    create_key_params: CreateKeyInputRequestTypeDef = {
        "KeyAttributes": {
            "KeyUsage": "TR31_K0_CARD_PROCESSING_EMV_COMPATIBILITY",
            "KeyClass": "SYMMETRIC_KEY",
            "KeyAlgorithm": "AES_128",
            "KeyModesOfUse": {
                "Encrypt": True,
                "Decrypt": True
            }
        },
        "Enabled": True,
        "KeyCheckValueAlgorithm": "CMAC"
    }

    try:
        response = client.create_key(**create_key_params)
        print(f"Key created successfully with ARN: {response['Key']['KeyArn']}")
        # Type checkers will understand the structure of 'response'
    except client.exceptions.ConflictException:
        print(f"Key alias {key_alias} already exists.")
    except Exception as e:
        print(f"An error occurred: {e}")


# To run this example, ensure you have AWS credentials configured
# or set environment variables like AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION.
# Example: os.environ['AWS_REGION'] = os.environ.get('AWS_REGION', 'us-east-1')
create_payment_cryptography_key()

view raw JSON →