Type Annotations for Boto3 S3Outposts

1.42.3 · active · verified Sat Apr 11

mypy-boto3-s3outposts provides type annotations for the `boto3` S3Outposts service, enhancing development with static type checking and IDE autocomplete. It is generated by `mypy-boto3-builder` and keeps pace with `boto3` releases, typically seeing frequent updates. The current version is 1.42.3.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a typed S3Outposts client using `boto3.session.Session` and `mypy-boto3-s3outposts` for enhanced type checking. It includes an example of listing endpoints and a commented-out example of using a `TypedDict` for a request payload.

import os
from typing import TYPE_CHECKING

import boto3
from boto3.session import Session

if TYPE_CHECKING:
    from mypy_boto3_s3outposts.client import S3OutpostsClient
    from mypy_boto3_s3outposts.type_defs import CreateEndpointRequestTypeDef


def get_s3outposts_client() -> 'S3OutpostsClient':
    # Explicit type annotation is optional with full mypy-boto3-stubs
    # but can be helpful for IDEs and type checkers like mypy/pyright.
    session = Session(region_name=os.environ.get('AWS_DEFAULT_REGION', 'us-east-1'))
    client: S3OutpostsClient = session.client('s3outposts')
    return client


if __name__ == "__main__":
    s3outposts_client = get_s3outposts_client()

    print("Listing S3Outposts endpoints:")
    try:
        response = s3outposts_client.list_endpoints()
        for endpoint in response.get("Endpoints", []):
            print(f"  Endpoint Id: {endpoint.get('EndpointId')}, Status: {endpoint.get('Status')}")
    except Exception as e:
        print(f"Error listing endpoints: {e}")

    # Example of using a TypedDict for a request payload (if creating an endpoint)
    # Note: This is a placeholder and would require actual valid parameters to run.
    if TYPE_CHECKING:
        create_endpoint_request: CreateEndpointRequestTypeDef = {
            "OutpostId": "op-0123456789abcdef0",
            "S3OutpostsArn": "arn:aws:s3-outposts:us-east-1:123456789012:outpost/op-0123456789abcdef0/accesspoint/my-accesspoint",
            "EndpointDetails": {
                "SecurityGroupId": "sg-0abcdef1234567890",
                "SubnetId": "subnet-0abcdef1234567890"
            }
        }
        # result = s3outposts_client.create_endpoint(**create_endpoint_request)
        # print(f"Created endpoint: {result.get('EndpointArn')}")

view raw JSON →