mypy-boto3-arc-zonal-shift
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
- breaking Python 3.8 support was removed for all `mypy-boto3` packages, including `mypy-boto3-arc-zonal-shift`, starting with `mypy-boto3-builder` version 8.12.0. The `requires_python` specifier is now `>=3.9`.
- breaking Some TypeDef names for method arguments and responses might have changed in `mypy-boto3-builder` version 8.9.0 to be shorter or to resolve naming conflicts. This can cause `mypy` errors if your code explicitly references these TypeDefs.
- gotcha This package provides *type stubs only*. It does not replace the `boto3` library itself. `boto3` must be installed and available at runtime for your application to function. These stubs merely add type-checking capabilities for `boto3` interactions.
- gotcha AWS service names passed to `boto3.client()` (e.g., 'arc-zonal-shift') are case-sensitive and must exactly match the expected service identifier. Mismatches will lead to `UnknownServiceError` at runtime and may not be caught by `mypy` if not using literal types.
Install
-
pip install mypy-boto3-arc-zonal-shift boto3 mypy
Imports
- ARCZonalShiftClient
from mypy_boto3_arc_zonal_shift import ARCZonalShiftClient
- GetManagedResourceResponseTypeDef
from mypy_boto3_arc_zonal_shift.type_defs import GetManagedResourceResponseTypeDef
- ARCZonalShiftServiceName
from mypy_boto3_arc_zonal_shift.literals import ARCZonalShiftServiceName
Quickstart
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.")