mypy-boto3-marketplace-agreement: Type Stubs for AWS Marketplace Agreement Service

1.42.80 · active · verified Sat Apr 11

mypy-boto3-marketplace-agreement provides a comprehensive set of type annotations for the AWS Marketplace Agreement Service client in boto3. This library is part of the `mypy-boto3-builder` ecosystem, which generates type stubs for all boto3 services, enhancing static type checking capabilities for AWS SDK users. The project actively maintains and updates its stubs, with version 1.42.80 reflecting the latest boto3 API for AgreementService and aligning with `mypy-boto3-builder` version 8.12.0. Releases are frequent, following boto3 updates and builder enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a type-hinted `AgreementServiceClient` and use it to call an API operation, such as `accept_agreement`. It highlights the correct import paths for both the client and its associated type definitions, which are essential for leveraging static type checking with `mypy-boto3` stubs.

import boto3
from mypy_boto3_marketplace_agreement.client import AgreementServiceClient
from mypy_boto3_marketplace_agreement.type_defs import AcceptAgreementOutputTypeDef, AcceptAgreementRequestRequestTypeDef
import os

def get_agreement_client() -> AgreementServiceClient:
    """Returns a type-hinted boto3 AgreementService client."""
    # Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
    # For local testing, you might mock this or ensure your environment has AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.
    return boto3.client("marketplace-agreement")

def accept_agreement(agreement_id: str) -> AcceptAgreementOutputTypeDef:
    """Accepts a Marketplace agreement using the type-hinted client."""
    client: AgreementServiceClient = get_agreement_client()
    
    # Example request payload, adjust as per actual API requirements
    request_payload: AcceptAgreementRequestRequestTypeDef = {
        "agreementId": agreement_id
    }
    
    response: AcceptAgreementOutputTypeDef = client.accept_agreement(**request_payload)
    print(f"Agreement accepted: {response.get('agreementId')}")
    return response

if __name__ == "__main__":
    # Replace with a real agreement ID for actual testing
    test_agreement_id = os.environ.get('MARKETPLACE_AGREEMENT_ID', 'ag-xxxxxxxxxxxxxxxxx') 
    if test_agreement_id == 'ag-xxxxxxxxxxxxxxxxx':
        print("Please set the MARKETPLACE_AGREEMENT_ID environment variable for a real test.")
        print("Using a placeholder ID.")

    try:
        # This call will require valid AWS credentials and a real agreement ID to succeed.
        # If credentials are not configured or ID is invalid, it will raise a boto3 exception.
        accept_agreement(test_agreement_id)
    except Exception as e:
        print(f"An error occurred: {e}")
        print("Ensure 'boto3' is installed and AWS credentials are configured correctly.")

view raw JSON →