Skip to content

CloudTrail

The CloudTrail resource provides access to AWS CloudTrail trails.

Usage

from cmq.aws.session import profile

# List all CloudTrail trails
profile().cloudtrail().list()

CloudTrail

Bases: AWSResource


              flowchart TD
              cmq.aws.resource.cloudtrail.cloudtrail[cloudtrail]
              cmq.aws.aws.AWSResource[AWSResource]
              cmq.aws.aws.TagResourceInterface[TagResourceInterface]
              cmq.aws.aws.DescribeResourceInterface[DescribeResourceInterface]
              cmq.aws.aws.MetricResourceInterface[MetricResourceInterface]
              cmq.aws.aws.AWSClientInterface[AWSClientInterface]
              cmq.base.Resource[Resource]
              cmq.base.PagedResourceInterface[PagedResourceInterface]
              cmq.base.ResourceInterface[ResourceInterface]
              cmq.base.NodeInterface[NodeInterface]
              cmq.plugin.ResourcePlugin[ResourcePlugin]
              cmq.plugin.ResourceLoader[ResourceLoader]

                              cmq.aws.aws.AWSResource --> cmq.aws.resource.cloudtrail.cloudtrail
                                cmq.aws.aws.TagResourceInterface --> cmq.aws.aws.AWSResource
                
                cmq.aws.aws.DescribeResourceInterface --> cmq.aws.aws.AWSResource
                
                cmq.aws.aws.MetricResourceInterface --> cmq.aws.aws.AWSResource
                
                cmq.aws.aws.AWSClientInterface --> cmq.aws.aws.AWSResource
                
                cmq.base.Resource --> cmq.aws.aws.AWSResource
                                cmq.base.PagedResourceInterface --> cmq.base.Resource
                                cmq.base.ResourceInterface --> cmq.base.PagedResourceInterface
                                cmq.base.NodeInterface --> cmq.base.ResourceInterface
                


                cmq.plugin.ResourcePlugin --> cmq.base.Resource
                                cmq.plugin.ResourceLoader --> cmq.plugin.ResourcePlugin
                





              click cmq.aws.resource.cloudtrail.cloudtrail href "" "cmq.aws.resource.cloudtrail.cloudtrail"
              click cmq.aws.aws.AWSResource href "" "cmq.aws.aws.AWSResource"
              click cmq.aws.aws.TagResourceInterface href "" "cmq.aws.aws.TagResourceInterface"
              click cmq.aws.aws.DescribeResourceInterface href "" "cmq.aws.aws.DescribeResourceInterface"
              click cmq.aws.aws.MetricResourceInterface href "" "cmq.aws.aws.MetricResourceInterface"
              click cmq.aws.aws.AWSClientInterface href "" "cmq.aws.aws.AWSClientInterface"
              click cmq.base.Resource href "" "cmq.base.Resource"
              click cmq.base.PagedResourceInterface href "" "cmq.base.PagedResourceInterface"
              click cmq.base.ResourceInterface href "" "cmq.base.ResourceInterface"
              click cmq.base.NodeInterface href "" "cmq.base.NodeInterface"
              click cmq.plugin.ResourcePlugin href "" "cmq.plugin.ResourcePlugin"
              click cmq.plugin.ResourceLoader href "" "cmq.plugin.ResourceLoader"
            

access_key(access_key)

Sets the access key for filtering events.

Parameters:

Name Type Description Default
access_key str

The access key to filter by.

required

Returns:

Name Type Description
cloudtrail cloudtrail

The cloudtrail object for method chaining.

event_name(event_name)

Sets the event name for filtering events.

Parameters:

Name Type Description Default
event_name str

The event name to filter by.

required

Returns:

Name Type Description
cloudtrail cloudtrail

The cloudtrail object for method chaining.

event_source(event_source)

Sets the event source for filtering events.

Parameters:

Name Type Description Default
event_source str

The event source to filter by.

required

Returns:

Name Type Description
cloudtrail cloudtrail

The cloudtrail object for method chaining.

event_time(start_time, end_time)

Sets the event time range for filtering events.

Parameters:

Name Type Description Default
start_time datetime

The start time of the event range.

required
end_time datetime

The end time of the event range.

required

Returns:

Name Type Description
cloudtrail cloudtrail

The cloudtrail object for method chaining.

last(**kwargs)

Sets the number of events to retrieve.

Parameters:

Name Type Description Default
**kwargs dict[str, int]

The keyword arguments for the timedelta.

{}

Returns:

Name Type Description
cloudtrail cloudtrail

The cloudtrail object for method chaining.

resource_name(resource_name)

Sets the resource name for filtering events.

Parameters:

Name Type Description Default
resource_name str

The resource name to filter by.

required

Returns:

Name Type Description
cloudtrail cloudtrail

The cloudtrail object for method chaining.

user_name(user_name)

Sets the user name for filtering events.

Parameters:

Name Type Description Default
user_name str

The user name to filter by.

required

Returns:

Name Type Description
cloudtrail cloudtrail

The cloudtrail object for method chaining.

Inherited from ResourceInterface

Bases: NodeInterface


              flowchart TD
              cmq.base.ResourceInterface[ResourceInterface]
              cmq.base.NodeInterface[NodeInterface]

                              cmq.base.NodeInterface --> cmq.base.ResourceInterface
                


              click cmq.base.ResourceInterface href "" "cmq.base.ResourceInterface"
              click cmq.base.NodeInterface href "" "cmq.base.NodeInterface"
            

attr(*args)

Adds a selection operation to the pipeline that will select the specified attributes.

Parameters:

Name Type Description Default
*args list[str]

The attributes to be selected.

()

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

calculate(key, func)

Adds a calculation operation to the pipeline that will calculate a new attribute.

Parameters:

Name Type Description Default
key str

The new key of the attribute.

required
func callable

The calculation function to be used.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

contains(key, value)

Adds a "contains" filter to the resource.

Parameters:

Name Type Description Default
key str

The key of the attribute to compare.

required
value Any

The value to check for containment.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

ends_with(key, value)

Adds an "ends with" filter to the resource.

Parameters:

Name Type Description Default
key str

The key of the attribute to compare.

required
value str

The value to check for ending with.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

eq(key, value)

Adds an equality filter to the resource.

Parameters:

Name Type Description Default
key str

The key of the attribute to compare.

required
value Any

The value to compare against.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

filter(func)

Adds a filter operation to the pipeline that will filter resources based on the given function.

Parameters:

Name Type Description Default
func callable

The filter function to be added.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

gt(key, value)

Adds a "greater than" filter to the resource.

Parameters:

Name Type Description Default
key str

The key of the attribute to compare.

required
value Any

The value to compare against.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

in_(key, value)

Adds an "in" filter to the resource.

Parameters:

Name Type Description Default
key str

The key of the attribute to compare.

required
value list

The list of values to check for inclusion.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

lt(key, value)

Adds a "less than" filter to the resource.

Parameters:

Name Type Description Default
key str

The key of the attribute to compare.

required
value Any

The value to compare against.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

ne(key, value)

Adds a not-equal filter to the resource.

Parameters:

Name Type Description Default
key str

The key of the attribute to compare.

required
value Any

The value to compare against.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

not_contains(key, value)

Adds a "not contains" filter to the resource.

Parameters:

Name Type Description Default
key str

The key of the attribute to compare.

required
value Any

The value to check for non-containment.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

starts_with(key, value)

Adds a "starts with" filter to the resource.

Parameters:

Name Type Description Default
key str

The key of the attribute to compare.

required
value str

The value to check for starting with.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

transform(key, func)

Adds a transformation operation to the pipeline that will transform the specified attribute.

Parameters:

Name Type Description Default
key str

The key of the attribute to transform.

required
func callable

The transformation function to be added.

required

Returns:

Name Type Description
ResourceInterface Resource

The updated resource object.

Inherited from Resource

Bases: PagedResourceInterface, ResourcePlugin


              flowchart TD
              cmq.base.Resource[Resource]
              cmq.base.PagedResourceInterface[PagedResourceInterface]
              cmq.base.ResourceInterface[ResourceInterface]
              cmq.base.NodeInterface[NodeInterface]
              cmq.plugin.ResourcePlugin[ResourcePlugin]
              cmq.plugin.ResourceLoader[ResourceLoader]

                              cmq.base.PagedResourceInterface --> cmq.base.Resource
                                cmq.base.ResourceInterface --> cmq.base.PagedResourceInterface
                                cmq.base.NodeInterface --> cmq.base.ResourceInterface
                


                cmq.plugin.ResourcePlugin --> cmq.base.Resource
                                cmq.plugin.ResourceLoader --> cmq.plugin.ResourcePlugin
                



              click cmq.base.Resource href "" "cmq.base.Resource"
              click cmq.base.PagedResourceInterface href "" "cmq.base.PagedResourceInterface"
              click cmq.base.ResourceInterface href "" "cmq.base.ResourceInterface"
              click cmq.base.NodeInterface href "" "cmq.base.NodeInterface"
              click cmq.plugin.ResourcePlugin href "" "cmq.plugin.ResourcePlugin"
              click cmq.plugin.ResourceLoader href "" "cmq.plugin.ResourceLoader"
            

csv(flat=False)

Retrieves a list of resources based on the applied filters and returns them in CSV format.

Parameters:

Name Type Description Default
flat bool

Specifies whether the dictionaries should be flattened or not. Defaults to False.

False

Returns:

Name Type Description
str str

List of resources in CSV format.

dict()

Retrieves a dictionary of resources based on the applied filters.

Returns:

Name Type Description
dict dict

A dictionary of resource objects.

do(action)

Performs a custom action on the resources.

Parameters:

Name Type Description Default
action callable

The action to be performed.

required

list()

Retrieves a list of resources based on the applied filters.

Returns:

Name Type Description
list list

A list of resource objects.