Examples#
Index > CloudWatchLogs > Examples
Auto-generated documentation for CloudWatchLogs type annotations stubs module types-aiobotocore-logs.
Client#
Implicit type annotations#
Can be used with types-aiobotocore[logs]
package installed.
Write your CloudWatchLogs
code as usual,
type checking and code completion should work out of the box.
# CloudWatchLogsClient usage example
from aiobotocore.session import get_session
session = get_session()
async with session.create_client("logs") as client: # (1)
result = await client.associate_kms_key() # (2)
- client: CloudWatchLogsClient
- result: EmptyResponseMetadataTypeDef
# DescribeDestinationsPaginator usage example
from aiobotocore.session import get_session
session = get_session()
async with session.create_client("logs") as client: # (1)
paginator = client.get_paginator("describe_destinations") # (2)
async for item in paginator.paginate(...):
print(item) # (3)
- client: CloudWatchLogsClient
- paginator: DescribeDestinationsPaginator
- item: DescribeDestinationsResponseTypeDef
Explicit type annotations#
With types-aiobotocore-lite[logs]
or a standalone types_aiobotocore_logs
package, you have to explicitly specify
client: CloudWatchLogsClient
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
# CloudWatchLogsClient usage example with type annotations
from aiobotocore.session import get_session
from types_aiobotocore_logs.client import CloudWatchLogsClient
from types_aiobotocore_logs.type_defs import EmptyResponseMetadataTypeDef
from types_aiobotocore_logs.type_defs import AssociateKmsKeyRequestRequestTypeDef
session = get_session()
async with session.create_client("logs") as client:
client: CloudWatchLogsClient
kwargs: AssociateKmsKeyRequestRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = await client.associate_kms_key(**kwargs)
# DescribeDestinationsPaginator usage example with type annotations
from aiobotocore.session import get_session
from types_aiobotocore_logs.client import CloudWatchLogsClient
from types_aiobotocore_logs.paginator import DescribeDestinationsPaginator
from types_aiobotocore_logs.type_defs import DescribeDestinationsResponseTypeDef
session = get_session()
async with session.create_client("logs") as client:
client: CloudWatchLogsClient
paginator: DescribeDestinationsPaginator = client.get_paginator("describe_destinations")
async for item in paginator.paginate(...):
item: DescribeDestinationsResponseTypeDef
print(item)