Examples#
Index > CloudTrail > Examples
Auto-generated documentation for CloudTrail type annotations stubs module types-boto3-cloudtrail.
Client#
Implicit type annotations#
Can be used with types-boto3[cloudtrail]
package installed.
Write your CloudTrail
code as usual,
type checking and code completion should work out of the box.
# CloudTrailClient usage example
from boto3.session import Session
session = Session()
client = session.client("cloudtrail") # (1)
result = client.cancel_query() # (2)
- client: CloudTrailClient
- result: CancelQueryResponseTypeDef
# ListImportFailuresPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("cloudtrail") # (1)
paginator = client.get_paginator("list_import_failures") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: CloudTrailClient
- paginator: ListImportFailuresPaginator
- item: ListImportFailuresResponseTypeDef
Explicit type annotations#
With types-boto3-lite[cloudtrail]
or a standalone types_boto3_cloudtrail
package, you have to explicitly specify client: CloudTrailClient
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.
# CloudTrailClient usage example with type annotations
from boto3.session import Session
from types_boto3_cloudtrail.client import CloudTrailClient
from types_boto3_cloudtrail.type_defs import CancelQueryResponseTypeDef
from types_boto3_cloudtrail.type_defs import CancelQueryRequestRequestTypeDef
session = Session()
client: CloudTrailClient = session.client("cloudtrail")
kwargs: CancelQueryRequestRequestTypeDef = {...}
result: CancelQueryResponseTypeDef = client.cancel_query(**kwargs)
# ListImportFailuresPaginator usage example with type annotations
from boto3.session import Session
from types_boto3_cloudtrail.client import CloudTrailClient
from types_boto3_cloudtrail.paginator import ListImportFailuresPaginator
from types_boto3_cloudtrail.type_defs import ListImportFailuresResponseTypeDef
session = Session()
client: CloudTrailClient = session.client("cloudtrail")
paginator: ListImportFailuresPaginator = client.get_paginator("list_import_failures")
for item in paginator.paginate(...):
item: ListImportFailuresResponseTypeDef
print(item)