mypy-boto3-storagegateway: Boto3 StorageGateway Type Stubs

1.42.3 · active · verified Sat Apr 11

mypy-boto3-storagegateway provides type annotations for the AWS Boto3 StorageGateway service. It helps developers write type-safe Python code that interacts with StorageGateway by providing static type hints for clients, resources, and data structures. The library is generated by `mypy-boto3-builder` and is updated frequently, often daily or weekly, to keep pace with new `boto3` releases and AWS API changes, ensuring up-to-date type definitions.

Warnings

Install

Imports

Quickstart

Demonstrates how to obtain a type-hinted StorageGateway client using `boto3` and leverage the provided stubs for static analysis, including type-hinted method calls and response objects. It includes error handling for a runnable example.

import boto3
from mypy_boto3_storagegateway import StorageGatewayClient
from mypy_boto3_storagegateway.type_defs import ListGatewaysOutputTypeDef

def get_storagegateway_client() -> StorageGatewayClient:
    """Returns a typed StorageGateway client."""
    # boto3.client will automatically pick up the type hints
    # if mypy-boto3-storagegateway is installed.
    return boto3.client("storagegateway")

# Get a type-hinted StorageGateway client
client: StorageGatewayClient = get_storagegateway_client()

try:
    # Use the client with type-hinted response
    response: ListGatewaysOutputTypeDef = client.list_gateways(Limit=10)
    
    gateway_names = [g['GatewayARN'] for g in response.get('GatewayInfos', [])]
    if gateway_names:
        print(f"Found gateways: {', '.join(gateway_names)}")
    else:
        print("No gateways found.")

except Exception as e:
    print(f"An error occurred: {e}")

# For authentication, ensure AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials, or IAM roles)
# This quickstart assumes default credential setup.

view raw JSON →