Mypy Boto3 Timestream Write Stubs

1.42.3 · active · verified Sat Apr 11

mypy-boto3-timestream-write provides type annotations for the `boto3` TimestreamWrite service (version 1.42.3), enabling static analysis, improved IDE autocompletion, and robust type checking for your AWS interactions. This package is generated by `mypy-boto3-builder` (version 8.12.0) and is updated frequently to stay in sync with `boto3` and `botocore` releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` client with `mypy-boto3-timestream-write` type annotations and make a basic API call like `describe_endpoints`. It also shows how to import and use generated `TypedDict` definitions. Remember to install `boto3` alongside the stub package.

import boto3
import os
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_timestream_write.client import TimestreamWriteClient
    from mypy_boto3_timestream_write.type_defs import DescribeEndpointsResponseTypeDef

# It's recommended to install boto3 in addition to mypy-boto3-timestream-write
# pip install boto3 mypy-boto3-timestream-write

# Initialize a boto3 client with explicit type annotation
# This helps IDEs and type checkers provide accurate suggestions
client: TimestreamWriteClient = boto3.client(
    "timestream-write",
    region_name=os.environ.get('AWS_REGION', 'us-east-1'),
    aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY'),
    aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')
)

try:
    # Use a simple method to demonstrate type checking
    response: DescribeEndpointsResponseTypeDef = client.describe_endpoints()
    print("Timestream Write Endpoints:")
    for endpoint in response.get('Endpoints', []):
        print(f"  Address: {endpoint.get('Address')}, CachePeriodInMinutes: {endpoint.get('CachePeriodInMinutes')}")
except Exception as e:
    print(f"Error describing endpoints: {e}")

# Example of using a TypedDict
# from mypy_boto3_timestream_write.type_defs import WriteRecordsRequestRequestTypeDef
# write_request: WriteRecordsRequestRequestTypeDef = {
#     "DatabaseName": "my_database",
#     "TableName": "my_table",
#     "Records": [
#         {
#             "MeasureName": "cpu_utilization",
#             "MeasureValue": "10.5",
#             "MeasureValueType": "DOUBLE",
#             "Time": "1678886400000",
#             "TimeUnit": "MILLISECONDS"
#         }
#     ]
# }
# print(f"\nSample WriteRecordsRequestRequestTypeDef: {write_request}")

view raw JSON →