mypy-boto3-kinesisvideo
mypy-boto3-kinesisvideo provides type annotations for the `boto3` KinesisVideo service, ensuring type compatibility with tools like mypy, VSCode, and PyCharm. It is automatically generated by `mypy-boto3-builder` and released frequently, often in sync with `boto3` updates to maintain accurate type hints for the latest AWS API specifications. The current version is 1.42.3.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 will need to upgrade their Python version to 3.9 or higher to use recent versions of this library.
- breaking The library migrated to PEP 561 compatible packages in `mypy-boto3-builder` version 8.12.0. This might affect custom build systems or environments that expect the older package structure.
- breaking TypeDef naming conventions were changed in `mypy-boto3-builder` 8.9.0. Specifically, packed method arguments' TypeDefs use shorter names, and conflicting `Extra` postfixes were moved to the end. While this might not directly impact `KinesisVideo` specifically, it is a general change in the builder that could affect other services used alongside `KinesisVideo`.
- gotcha This package provides type annotations only. For the actual runtime functionality, the `boto3` library must also be installed in your environment.
- gotcha For optimal type checking and IDE auto-completion, especially for `boto3.client` and `boto3.session.client` calls, explicit type annotations are highly recommended.
- gotcha Pylint might report undefined variables when using `TYPE_CHECKING` for conditional imports. To avoid this, set all types to `object` in the non-`TYPE_CHECKING` branch.
Install
-
pip install mypy-boto3-kinesisvideo -
pip install boto3-stubs[kinesisvideo]
Imports
- KinesisVideoClient
from mypy_boto3_kinesisvideo.client import KinesisVideoClient
- DescribeStreamOutputTypeDef
from mypy_boto3_kinesisvideo.type_defs import DescribeStreamOutputTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_kinesisvideo.client import KinesisVideoClient
from mypy_boto3_kinesisvideo.type_defs import ListStreamsOutputTypeDef
def get_kinesisvideo_client() -> 'KinesisVideoClient':
# In a real application, credentials and region would be configured
# via environment variables, ~/.aws/credentials, or other boto3 methods.
# Using os.environ.get for example runnable code.
session = boto3.Session(
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'test'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'test'),
region_name=os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')
)
client: KinesisVideoClient = session.client("kinesisvideo")
return client
def list_kinesis_streams():
client = get_kinesisvideo_client()
response: ListStreamsOutputTypeDef = client.list_streams()
print("Kinesis Video Streams:")
for stream_info in response.get('StreamInfoList', []):
print(f" - {stream_info.get('StreamName')} (ARN: {stream_info.get('StreamARN')})")
# Example usage:
if __name__ == '__main__':
import os
# Set dummy AWS credentials for local execution if not already set
# For actual AWS interaction, ensure valid credentials are configured.
os.environ.setdefault('AWS_ACCESS_KEY_ID', 'AKIAIOSFODNN7EXAMPLE')
os.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')
os.environ.setdefault('AWS_DEFAULT_REGION', 'us-east-1')
try:
list_kinesis_streams()
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure AWS credentials are correctly configured if you expect real data.")