Skip to content

CloudTrailClient#

Index > CloudTrail > CloudTrailClient

Auto-generated documentation for CloudTrail type annotations stubs module mypy-boto3-cloudtrail.

CloudTrailClient#

Type annotations and code completion for boto3.client("cloudtrail"). boto3 documentation

# CloudTrailClient usage example

from boto3.session import Session
from mypy_boto3_cloudtrail.client import CloudTrailClient

def get_cloudtrail_client() -> CloudTrailClient:
    return Session().client("cloudtrail")

Exceptions#

boto3 client exceptions are generated in runtime. This class provides code completion for boto3.client("cloudtrail").exceptions structure.

# Exceptions.exceptions usage example

client = boto3.client("cloudtrail")

try:
    do_something(client)
except (
    client.exceptions.AccessDeniedException,
    client.exceptions.AccountHasOngoingImportException,
    client.exceptions.AccountNotFoundException,
    client.exceptions.AccountNotRegisteredException,
    client.exceptions.AccountRegisteredException,
    client.exceptions.CannotDelegateManagementAccountException,
    client.exceptions.ChannelARNInvalidException,
    client.exceptions.ChannelAlreadyExistsException,
    client.exceptions.ChannelExistsForEDSException,
    client.exceptions.ChannelMaxLimitExceededException,
    client.exceptions.ChannelNotFoundException,
    client.exceptions.ClientError,
    client.exceptions.CloudTrailARNInvalidException,
    client.exceptions.CloudTrailAccessNotEnabledException,
    client.exceptions.CloudTrailInvalidClientTokenIdException,
    client.exceptions.CloudWatchLogsDeliveryUnavailableException,
    client.exceptions.ConcurrentModificationException,
    client.exceptions.ConflictException,
    client.exceptions.DelegatedAdminAccountLimitExceededException,
    client.exceptions.EventDataStoreARNInvalidException,
    client.exceptions.EventDataStoreAlreadyExistsException,
    client.exceptions.EventDataStoreFederationEnabledException,
    client.exceptions.EventDataStoreHasOngoingImportException,
    client.exceptions.EventDataStoreMaxLimitExceededException,
    client.exceptions.EventDataStoreNotFoundException,
    client.exceptions.EventDataStoreTerminationProtectedException,
    client.exceptions.ImportNotFoundException,
    client.exceptions.InactiveEventDataStoreException,
    client.exceptions.InactiveQueryException,
    client.exceptions.InsightNotEnabledException,
    client.exceptions.InsufficientDependencyServiceAccessPermissionException,
    client.exceptions.InsufficientEncryptionPolicyException,
    client.exceptions.InsufficientS3BucketPolicyException,
    client.exceptions.InsufficientSnsTopicPolicyException,
    client.exceptions.InvalidCloudWatchLogsLogGroupArnException,
    client.exceptions.InvalidCloudWatchLogsRoleArnException,
    client.exceptions.InvalidDateRangeException,
    client.exceptions.InvalidEventCategoryException,
    client.exceptions.InvalidEventDataStoreCategoryException,
    client.exceptions.InvalidEventDataStoreStatusException,
    client.exceptions.InvalidEventSelectorsException,
    client.exceptions.InvalidHomeRegionException,
    client.exceptions.InvalidImportSourceException,
    client.exceptions.InvalidInsightSelectorsException,
    client.exceptions.InvalidKmsKeyIdException,
    client.exceptions.InvalidLookupAttributesException,
    client.exceptions.InvalidMaxResultsException,
    client.exceptions.InvalidNextTokenException,
    client.exceptions.InvalidParameterCombinationException,
    client.exceptions.InvalidParameterException,
    client.exceptions.InvalidQueryStatementException,
    client.exceptions.InvalidQueryStatusException,
    client.exceptions.InvalidS3BucketNameException,
    client.exceptions.InvalidS3PrefixException,
    client.exceptions.InvalidSnsTopicNameException,
    client.exceptions.InvalidSourceException,
    client.exceptions.InvalidTagParameterException,
    client.exceptions.InvalidTimeRangeException,
    client.exceptions.InvalidTokenException,
    client.exceptions.InvalidTrailNameException,
    client.exceptions.KmsException,
    client.exceptions.KmsKeyDisabledException,
    client.exceptions.KmsKeyNotFoundException,
    client.exceptions.MaxConcurrentQueriesException,
    client.exceptions.MaximumNumberOfTrailsExceededException,
    client.exceptions.NoManagementAccountSLRExistsException,
    client.exceptions.NotOrganizationManagementAccountException,
    client.exceptions.NotOrganizationMasterAccountException,
    client.exceptions.OperationNotPermittedException,
    client.exceptions.OrganizationNotInAllFeaturesModeException,
    client.exceptions.OrganizationsNotInUseException,
    client.exceptions.QueryIdNotFoundException,
    client.exceptions.ResourceARNNotValidException,
    client.exceptions.ResourceNotFoundException,
    client.exceptions.ResourcePolicyNotFoundException,
    client.exceptions.ResourcePolicyNotValidException,
    client.exceptions.ResourceTypeNotSupportedException,
    client.exceptions.S3BucketDoesNotExistException,
    client.exceptions.TagsLimitExceededException,
    client.exceptions.ThrottlingException,
    client.exceptions.TrailAlreadyExistsException,
    client.exceptions.TrailNotFoundException,
    client.exceptions.TrailNotProvidedException,
    client.exceptions.UnsupportedOperationException,
) as e:
    print(e)
# Exceptions.exceptions type checking example

from mypy_boto3_cloudtrail.client import Exceptions

def handle_error(exc: Exceptions.AccessDeniedException) -> None:
    ...

Methods#

add_tags#

Adds one or more tags to a trail, event data store, or channel, up to a limit of 50.

Type annotations and code completion for boto3.client("cloudtrail").add_tags method. boto3 documentation

# add_tags method definition

def add_tags(
    self,
    *,
    ResourceId: str,
    TagsList: Sequence[TagTypeDef],  # (1)
) -> Dict[str, Any]:
    ...
  1. See TagTypeDef
# add_tags method usage example with argument unpacking

kwargs: AddTagsRequestRequestTypeDef = {  # (1)
    "ResourceId": ...,
    "TagsList": ...,
}

parent.add_tags(**kwargs)
  1. See AddTagsRequestRequestTypeDef

can_paginate#

Check if an operation can be paginated.

Type annotations and code completion for boto3.client("cloudtrail").can_paginate method. boto3 documentation

# can_paginate method definition

def can_paginate(
    self,
    operation_name: str,
) -> bool:
    ...

cancel_query#

Cancels a query if the query is not in a terminated state, such as CANCELLED, FAILED, TIMED_OUT, or FINISHED.

Type annotations and code completion for boto3.client("cloudtrail").cancel_query method. boto3 documentation

# cancel_query method definition

def cancel_query(
    self,
    *,
    QueryId: str,
    EventDataStore: str = ...,
) -> CancelQueryResponseTypeDef:  # (1)
    ...
  1. See CancelQueryResponseTypeDef
# cancel_query method usage example with argument unpacking

kwargs: CancelQueryRequestRequestTypeDef = {  # (1)
    "QueryId": ...,
}

parent.cancel_query(**kwargs)
  1. See CancelQueryRequestRequestTypeDef

close#

Closes underlying endpoint connections.

Type annotations and code completion for boto3.client("cloudtrail").close method. boto3 documentation

# close method definition

def close(
    self,
) -> None:
    ...

create_channel#

Creates a channel for CloudTrail to ingest events from a partner or external source.

Type annotations and code completion for boto3.client("cloudtrail").create_channel method. boto3 documentation

# create_channel method definition

def create_channel(
    self,
    *,
    Name: str,
    Source: str,
    Destinations: Sequence[DestinationTypeDef],  # (1)
    Tags: Sequence[TagTypeDef] = ...,  # (2)
) -> CreateChannelResponseTypeDef:  # (3)
    ...
  1. See DestinationTypeDef
  2. See TagTypeDef
  3. See CreateChannelResponseTypeDef
# create_channel method usage example with argument unpacking

kwargs: CreateChannelRequestRequestTypeDef = {  # (1)
    "Name": ...,
    "Source": ...,
    "Destinations": ...,
}

parent.create_channel(**kwargs)
  1. See CreateChannelRequestRequestTypeDef

create_event_data_store#

Creates a new event data store.

Type annotations and code completion for boto3.client("cloudtrail").create_event_data_store method. boto3 documentation

# create_event_data_store method definition

def create_event_data_store(
    self,
    *,
    Name: str,
    AdvancedEventSelectors: Sequence[AdvancedEventSelectorTypeDef] = ...,  # (1)
    MultiRegionEnabled: bool = ...,
    OrganizationEnabled: bool = ...,
    RetentionPeriod: int = ...,
    TerminationProtectionEnabled: bool = ...,
    TagsList: Sequence[TagTypeDef] = ...,  # (2)
    KmsKeyId: str = ...,
    StartIngestion: bool = ...,
    BillingMode: BillingModeType = ...,  # (3)
) -> CreateEventDataStoreResponseTypeDef:  # (4)
    ...
  1. See AdvancedEventSelectorTypeDef
  2. See TagTypeDef
  3. See BillingModeType
  4. See CreateEventDataStoreResponseTypeDef
# create_event_data_store method usage example with argument unpacking

kwargs: CreateEventDataStoreRequestRequestTypeDef = {  # (1)
    "Name": ...,
}

parent.create_event_data_store(**kwargs)
  1. See CreateEventDataStoreRequestRequestTypeDef

create_trail#

Creates a trail that specifies the settings for delivery of log data to an Amazon S3 bucket.

Type annotations and code completion for boto3.client("cloudtrail").create_trail method. boto3 documentation

# create_trail method definition

def create_trail(
    self,
    *,
    Name: str,
    S3BucketName: str,
    S3KeyPrefix: str = ...,
    SnsTopicName: str = ...,
    IncludeGlobalServiceEvents: bool = ...,
    IsMultiRegionTrail: bool = ...,
    EnableLogFileValidation: bool = ...,
    CloudWatchLogsLogGroupArn: str = ...,
    CloudWatchLogsRoleArn: str = ...,
    KmsKeyId: str = ...,
    IsOrganizationTrail: bool = ...,
    TagsList: Sequence[TagTypeDef] = ...,  # (1)
) -> CreateTrailResponseTypeDef:  # (2)
    ...
  1. See TagTypeDef
  2. See CreateTrailResponseTypeDef
# create_trail method usage example with argument unpacking

kwargs: CreateTrailRequestRequestTypeDef = {  # (1)
    "Name": ...,
    "S3BucketName": ...,
}

parent.create_trail(**kwargs)
  1. See CreateTrailRequestRequestTypeDef

delete_channel#

Deletes a channel.

Type annotations and code completion for boto3.client("cloudtrail").delete_channel method. boto3 documentation

# delete_channel method definition

def delete_channel(
    self,
    *,
    Channel: str,
) -> Dict[str, Any]:
    ...
# delete_channel method usage example with argument unpacking

kwargs: DeleteChannelRequestRequestTypeDef = {  # (1)
    "Channel": ...,
}

parent.delete_channel(**kwargs)
  1. See DeleteChannelRequestRequestTypeDef

delete_event_data_store#

Disables the event data store specified by EventDataStore, which accepts an event data store ARN.

Type annotations and code completion for boto3.client("cloudtrail").delete_event_data_store method. boto3 documentation

# delete_event_data_store method definition

def delete_event_data_store(
    self,
    *,
    EventDataStore: str,
) -> Dict[str, Any]:
    ...
# delete_event_data_store method usage example with argument unpacking

kwargs: DeleteEventDataStoreRequestRequestTypeDef = {  # (1)
    "EventDataStore": ...,
}

parent.delete_event_data_store(**kwargs)
  1. See DeleteEventDataStoreRequestRequestTypeDef

delete_resource_policy#

Deletes the resource-based policy attached to the CloudTrail channel.

Type annotations and code completion for boto3.client("cloudtrail").delete_resource_policy method. boto3 documentation

# delete_resource_policy method definition

def delete_resource_policy(
    self,
    *,
    ResourceArn: str,
) -> Dict[str, Any]:
    ...
# delete_resource_policy method usage example with argument unpacking

kwargs: DeleteResourcePolicyRequestRequestTypeDef = {  # (1)
    "ResourceArn": ...,
}

parent.delete_resource_policy(**kwargs)
  1. See DeleteResourcePolicyRequestRequestTypeDef

delete_trail#

Deletes a trail.

Type annotations and code completion for boto3.client("cloudtrail").delete_trail method. boto3 documentation

# delete_trail method definition

def delete_trail(
    self,
    *,
    Name: str,
) -> Dict[str, Any]:
    ...
# delete_trail method usage example with argument unpacking

kwargs: DeleteTrailRequestRequestTypeDef = {  # (1)
    "Name": ...,
}

parent.delete_trail(**kwargs)
  1. See DeleteTrailRequestRequestTypeDef

deregister_organization_delegated_admin#

Removes CloudTrail delegated administrator permissions from a member account in an organization.

Type annotations and code completion for boto3.client("cloudtrail").deregister_organization_delegated_admin method. boto3 documentation

# deregister_organization_delegated_admin method definition

def deregister_organization_delegated_admin(
    self,
    *,
    DelegatedAdminAccountId: str,
) -> Dict[str, Any]:
    ...
# deregister_organization_delegated_admin method usage example with argument unpacking

kwargs: DeregisterOrganizationDelegatedAdminRequestRequestTypeDef = {  # (1)
    "DelegatedAdminAccountId": ...,
}

parent.deregister_organization_delegated_admin(**kwargs)
  1. See DeregisterOrganizationDelegatedAdminRequestRequestTypeDef

describe_query#

Returns metadata about a query, including query run time in milliseconds, number of events scanned and matched, and query status.

Type annotations and code completion for boto3.client("cloudtrail").describe_query method. boto3 documentation

# describe_query method definition

def describe_query(
    self,
    *,
    EventDataStore: str = ...,
    QueryId: str = ...,
    QueryAlias: str = ...,
) -> DescribeQueryResponseTypeDef:  # (1)
    ...
  1. See DescribeQueryResponseTypeDef
# describe_query method usage example with argument unpacking

kwargs: DescribeQueryRequestRequestTypeDef = {  # (1)
    "EventDataStore": ...,
}

parent.describe_query(**kwargs)
  1. See DescribeQueryRequestRequestTypeDef

describe_trails#

Retrieves settings for one or more trails associated with the current Region for your account.

Type annotations and code completion for boto3.client("cloudtrail").describe_trails method. boto3 documentation

# describe_trails method definition

def describe_trails(
    self,
    *,
    trailNameList: Sequence[str] = ...,
    includeShadowTrails: bool = ...,
) -> DescribeTrailsResponseTypeDef:  # (1)
    ...
  1. See DescribeTrailsResponseTypeDef
# describe_trails method usage example with argument unpacking

kwargs: DescribeTrailsRequestRequestTypeDef = {  # (1)
    "trailNameList": ...,
}

parent.describe_trails(**kwargs)
  1. See DescribeTrailsRequestRequestTypeDef

disable_federation#

Disables Lake query federation on the specified event data store.

Type annotations and code completion for boto3.client("cloudtrail").disable_federation method.