mypy-boto3-iotfleetwise type stubs

1.42.3 · active · verified Sat Apr 11

mypy-boto3-iotfleetwise provides type annotations for the `boto3` AWS IoT FleetWise service, ensuring static type checking with tools like `mypy` and enhancing IDE auto-completion for `boto3` clients. It is currently at version 1.42.3, in sync with `boto3` releases, and is generated by `mypy-boto3-builder 8.12.0` which has a frequent release cadence, often aligning with new `boto3` versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-iotfleetwise` with a `boto3` client for the IoT FleetWise service. It explicitly types the client and uses a `TypedDict` for the request payload to ensure full static type checking during development.

import boto3
from mypy_boto3_iotfleetwise.client import IoTFleetWiseClient
from mypy_boto3_iotfleetwise.type_defs import CreateFleetRequestTypeDef, CreateFleetResponseTypeDef

def create_iot_fleet(fleet_id: str, fleet_description: str, tags: list[dict]) -> CreateFleetResponseTypeDef:
    client: IoTFleetWiseClient = boto3.client("iotfleetwise")

    request_payload: CreateFleetRequestTypeDef = {
        "fleetId": fleet_id,
        "description": fleet_description,
        "tags": tags,
    }

    try:
        response: CreateFleetResponseTypeDef = client.create_fleet(**request_payload)
        print(f"Successfully created fleet: {response['fleetArn']}")
        return response
    except client.exceptions.ConflictException:
        print(f"Fleet '{fleet_id}' already exists.")
        # Handle the case where the fleet already exists, e.g., get its details
        return client.get_fleet(fleetId=fleet_id)
    except Exception as e:
        print(f"Error creating fleet: {e}")
        raise

# Example usage (requires AWS credentials configured)
# Replace with actual desired values
# try:
#     fleet_response = create_iot_fleet(
#         fleet_id="my-example-fleet",
#         fleet_description="Fleet for testing purposes",
#         tags=[{"key": "Environment", "value": "Dev"}]
#     )
#     print(f"Fleet details: {fleet_response}")
# except Exception as e:
#     print(f"An error occurred: {e}")

view raw JSON →