mypy-boto3-arc-zonal-shift

1.42.3 · active · verified Sat Apr 11

This library provides type annotations (stubs) for the `boto3` AWS ARC Zonal Shift service, allowing developers to leverage static type checking with `mypy`. It is part of the `mypy-boto3-builder` ecosystem, which generates type stubs for all `boto3` services. The package version 1.42.3 aligns with the `boto3` version, and new versions are released frequently to match `boto3` updates and `mypy-boto3-builder` improvements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a type-hinted `ARCZonalShiftClient` using `boto3` and perform a basic `list_managed_resources` call, applying the type stubs for improved code completion and static analysis. It also includes an example for `get_managed_resource`, noting the need for a valid ARN.

import boto3
import os
from mypy_boto3_arc_zonal_shift import ARCZonalShiftClient
from mypy_boto3_arc_zonal_shift.type_defs import (
    GetManagedResourceResponseTypeDef,
    ListManagedResourcesResponseTypeDef,
)

# Initialize a typed client for the ARC Zonal Shift service
# Ensure AWS credentials are configured (e.g., via AWS CLI, environment variables)
client: ARCZonalShiftClient = boto3.client("arc-zonal-shift")

print("\n--- Listing Managed Resources ---")
try:
    # Using type hints for the response object
    response: ListManagedResourcesResponseTypeDef = client.list_managed_resources(
        MaxResults=5  # Example optional parameter
    )
    if "Items" in response:
        print(f"Found {len(response['Items'])} managed resources:")
        for resource in response["Items"]:
            print(f"  - ARN: {resource.get('ResourceArn')}, Name: {resource.get('ResourceName')}")
    else:
        print("No managed resources found.")

except client.exceptions.AccessDeniedException as e:
    print(f"Error: Access denied. Please check your AWS credentials and permissions. {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

# Example: Getting details for a specific managed resource (requires a valid ARN)
# Replace with an actual ARN from your AWS environment if you want to test this part.
# For a runnable example, we'll use a placeholder and warn the user.
example_resource_identifier = os.environ.get(
    "ARC_ZONAL_SHIFT_TEST_RESOURCE_ID",
    "arn:aws:arc-zonal-shift:us-east-1:123456789012:resource/example-123"
)

if "example-123" not in example_resource_identifier: # Avoid running with placeholder
    print(f"\n--- Getting Details for Resource: {example_resource_identifier} ---")
    try:
        resource_details: GetManagedResourceResponseTypeDef = client.get_managed_resource(
            ResourceIdentifier=example_resource_identifier
        )
        print(f"Details for {example_resource_identifier}: {resource_details}")
    except client.exceptions.ResourceNotFoundException:
        print(f"Resource '{example_resource_identifier}' not found.")
    except Exception as e:
        print(f"Error getting resource details: {e}")
else:
    print(f"\nSkipping 'Get Managed Resource' example. Set ARC_ZONAL_SHIFT_TEST_RESOURCE_ID environment variable with a valid ARN to run it.")

view raw JSON →