trendminer.sdk.context.filter module¶
This module provides user-facing API’s for interacting with Context Filter.
- class trendminer.sdk.context.filter.ApprovalFilter(approved: bool)¶
Bases:
ABC
Context filter on item approval.
- approved¶
Item approval status
- Type:
bool
Example
# Create an approval filter # Retrieve the created filter with unnaproved context item filter = client.context.filter.approval(approved = False) # Retrieve the created filter with approved context item filter = client.context.filter.approval(approved = True)
- class trendminer.sdk.context.filter.ComponentFilter(components: list[tuple[str, trendminer.sdk.asset.asset.AssetIncludeOptions]] | list[str] | list[trendminer.sdk.context.filter.ComponentQuery], mode: ContextFilterModes | None = None)¶
Bases:
ABC
Filter on set of components. Components can be tags, attributes or assets.
- components¶
Components (tags, assets, attributes) to which the context filter is applied. Component queries contain the component, but also whether ancestors or children need to be included. This can be specified with help of enum AssetIncludeOptions. Although it is only applicable for Asset or Attribute. A component queries can be represented in this format, eg : [(MyAsset, AssetIncludeOptions.DESCENDANTS), (MyAttribute, AssetIncludeOptions.ANCESTORS)]
- Type:
list of ComponentQuery or list of tuples or list of str
- mode¶
Mode to represent EMPTY or NON-EMPTY
- Type:
ContextFilterModes, optional
Note
Components and mode is mutually exclusive, provide only one of the parameters
Example
from trendminer.sdk.context import ContextFilterModes # Create a component filter by providing mode as a param filter = client.context.filter.components(mode=ContextFilterModes.EMPTY) # Create a component filter by providing a component filter = client.context.filter.components(components=["tag"]) # Create a component filter by to include asset ancestors as part of the filter criteria filter = client.context.filter.components(components = [("asset", AssetIncludeOptions.ANCESTORS)])
- class trendminer.sdk.context.filter.ComponentQuery(component: Tag | Asset | Attribute | str, include: AssetIncludeOptions | None = None)¶
Bases:
ABC
Query for filtering components in component context filter.
- include¶
Only applicable to assets and attributes. Descendants only possible for assets, default AssetIncludeOptions.SELF
- Type:
AssetIncludeOptions, optional
- class trendminer.sdk.context.filter.ContextDateOperators(value)¶
Bases:
Enum
Enum representing Context Date Operators for created_date filter.
- GREATER_THAN = 'GREATER_THAN'¶
GREATER_THAN Represents a time “LATER” than the selected date
- GREATER_THAN_OR_EQUAL = 'GREATER_THAN_OR_EQUAL'¶
GREATER_THAN_OR_EQUAL Represents a time “LATER” or “EQUALS” to the selected date
- LESS_THAN = 'LESS_THAN'¶
LESS_THAN Represents a time “EARLIER” than the selected date
- LESS_THAN_OR_EQUAL = 'LESS_THAN_OR_EQUAL'¶
LESS_THAN_OR_EQUAL Represents a time “EARLIER” or “EQUALS” to the selected date
- class trendminer.sdk.context.filter.ContextFilterAPI¶
Bases:
object
Router for Context Filter based API’s.
- abstract property approval: any¶
Property for creating an
ApprovalFilter
.- Returns:
A helper instance for creating an
ApprovalFilter
- Return type:
any
Example
# Retrieve approval filter API approval_filter_api = client.context.filter.approval # Create an approval filter # Retrieve the created filter with unnaproved context item filter = approval_filter_api(approved = False) # Retrieve the created filter with approved context item filter = client.context.filter.approval(approved = True)
- abstract property components: any¶
Property for creating a
ComponentFilter
.- Returns:
A helper instance for creating
ComponentFilter
- Return type:
any
Example
from trendminer.sdk.context import ContextFilterModes # Retrieve component filter API filter_api = client.context.filter.components # Create a component filter by providing mode as a param filter = filter_api(mode=ContextFilterModes.EMPTY) # Create a component filter by providing a component filter = client.context.filter.components(components="TM-BP2-TEMP.1")
- abstract property context_types: any¶
Property for creating a
TypeFilter
.- Returns:
A helper instance for creating a
TypeFilter
- Return type:
any
Example
# Retrieve context type filter API filter_api = client.context.filter.context_types # Create a context types filter # Retrieve the created filter of anomaly context type filter = filter_api(["ANOMALY"]) # Retrieve the created filter of information context type filter = client.context.filter.context_types(["INFORMATION"])
- abstract property created_date: any¶
Property for creating a
CreatedDateFilter
.- Returns:
A helper instance for creating
CreatedDateFilter
- Return type:
any
Example
from trendminer.sdk.context import ContextDateOperators filter_api = client.context.filter.created_date # Create a created_date filter for time earlier than provided date filter = filter_api(condition = {"value" : "2023-11-01 12:00:00", "operator" : ContextDateOperators.LESS_THAN}) # Create a created_date filter for time later or the same time than provided date client.context.filter.created_date(condition = {"value" : "2024-03-22 12:00:00", "operator" : ContextDateOperators.GREATER_THAN_OR_EQUAL})
- abstract property description: any¶
Property for creating a
DescriptionFilter
.- Returns:
A helper instance for creating
DescriptionFilter
- Return type:
any
Example
from trendminer.sdk.context import ContextFilterModes # Retrieve description filter API filter_api = client.context.filter.description # Create a description filter by providing mode as a param filter = filter_api(mode=ContextFilterModes.NON_EMPTY) # Create a description filter by providing description values client.context.filter.description(values=["extreme high temp", "hello"])
- abstract property duration: any¶
Property for creating a
DurationFilter
.- Returns:
A helper instance for creating
DurationFilter
- Return type:
any
Example
from trendminer.sdk.context import ContextOperators # Retrieve user filter API filter_api = client.context.filter.duration # Create a duration filter with equality condition filter = filter_api([{"value" : "5h", "operator" : ContextOperators.EQUAL}]) # Create a duration filter with greater than or eauals condition filter = client.context.filter.duration(conditions= [{"value" : "5h", "operator" : ContextOperators.GREATER_THAN_OR_EQUAL}])
- abstract property field: any¶
Property for creating a
ApprovalFilter
.- Returns:
A helper instance for creating
ApprovalFilter
- Return type:
any
Example
from trendminer.sdk.context import ContextFilterModes # Retrieve field filter API filter_api = client.context.filter.field # Create a text field filter by providing mode as a param filter = filter_api(field = "text_field", mode=ContextFilterModes.EMPTY) # Create a enum field filter by providing enum values client.context.filter.field(field = "enum_field", values=["danger", "alert"]) #Create a numeric field filter by providing values client.context.filter.field(field = "numericfield", values=[{'operator': ContextOperators.LESS_THAN_OR_EQUAL, 'value': 11}])
- abstract property interval: any¶
Property for creating a
IntervalFilter
.- Returns:
A helper instance for creating
IntervalFilter
- Return type:
any
Example
# Retrieve interval filter API filter_api = client.context.filter.interval # Create a interval filter on event time filter = filter_api(interval = ("2023-11-01 12:00:00", "2024-03-24 23:59:00")) # Create a interval filter on creation time filter = client.context.filter.interval(interval = ("2023-11-01 12:00:00", "2024-03-24 23:59:00"),created_date = True)
- abstract property keywords: any¶
Property for creating a
KeywordFilter
.- Returns:
A helper instance for creating
KeywordFilter
- Return type:
any
Example
from trendminer.sdk.context import ContextFilterModes # Retrieve keywords filter API filter_api = client.context.filter.keywords # Create a component filter by providing mode as a param filter = filter_api(mode=ContextFilterModes.EMPTY) # Create a keywords filter by providing keywords client.context.filter.keywords(keywords =["bad", "danger"])
- abstract property period: any¶
Property for creating a
PeriodFilter
.- Returns:
A helper instance for creating
PeriodFilter
- Return type:
any
Example
# Retrieve period filter API filter_api = client.context.filter.period # Create a period filter filter = filter_api(period = "10H", live = False) # Create a period filter for live period filter = client.context.filter.period(period = "6M", live = True)
- abstract property property: any¶
Property for creating a
PropertyFieldFilter
.- Returns:
A helper instance for creating
PropertyFieldFilter
- Return type:
any
Example
# Retrieve property filter API filter_api = client.context.filter.property # Create a property filter filter = filter_api(key = "key", values=["value"])
- abstract property states: any¶
Property for creating a
CurrentStateFilter
.- Returns:
A helper instance for creating
CurrentStateFilter
- Return type:
any
Example
from trendminer.sdk.context import ContextFilterStatesModes # Retrieve states filter API filter_api = client.context.filter.states # Create a states filter by providing a state mode as a param filter = filter_api(mode=ContextFilterStatesModes.OPEN_ONLY) # Create a states filter by providing states values client.context.filter.states(states=["Ended"])
- abstract property users: any¶
Property for creating a
CreatedByFilter
.- Returns:
A helper instance for creating
CreatedByFilter
- Return type:
any
Example
# Retrieve user filter API filter_api = client.context.filter.users # Create a user Created By filter # Retrieve the created filter with user name filter = filter_api('username')
- class trendminer.sdk.context.filter.ContextFilterModes(value)¶
Bases:
Enum
Enum representing Context Filter Modes for Description and Keywords.
- EMPTY = 'EMPTY'¶
EMPTY Represents “EMPTY” Status
- NON_EMPTY = 'NON_EMPTY'¶
NON_EMPTY Represents “NON_EMPTY” Status
- class trendminer.sdk.context.filter.ContextFilterStatesModes(value)¶
Bases:
Enum
Enum representing Context Filter for State Modes.
- CLOSED_ONLY = 'CLOSED_ONLY'¶
CLOSED_ONLY Represents “CLOSED_ONLY” State
- OPEN_ONLY = 'OPEN_ONLY'¶
OPEN_ONLY Represents “OPEN_ONLY” State
- class trendminer.sdk.context.filter.ContextOperators(value)¶
Bases:
Enum
Enum representing Context Operators.
- EQUAL = 'EQUAL'¶
EQUAL Represents “EQUAL” Operator
- GREATER_THAN = 'GREATER_THAN'¶
GREATER_THAN Represents “GREATER_THAN” Operator
- GREATER_THAN_OR_EQUAL = 'GREATER_THAN_OR_EQUAL'¶
GREATER_THAN_OR_EQUAL Represents “GREATER_THAN_OR_EQUAL” Operator
- LESS_THAN = 'LESS_THAN'¶
LESS_THAN Represents “LESS_THAN” Operator
- LESS_THAN_OR_EQUAL = 'LESS_THAN_OR_EQUAL'¶
LESS_THAN_OR_EQUAL Represents “LESS_THAN_OR_EQUAL” Operator
- NOT_EQUAL = 'NOT_EQUAL'¶
NOT_EQUAL Represents “NOT_EQUAL” Operator
- class trendminer.sdk.context.filter.CreatedByFilter(users: list[str] | list[trendminer.sdk.commons.user.User])¶
Bases:
ABC
Filter on context item created by a user.
Example
# Create a Created By filter # Retrieve the created filter with user name filter = client.context.filter.users('username')
- class trendminer.sdk.context.filter.CreatedDateFilter(condition: dict | CreatedDateQuery)¶
Bases:
ABC
Context item creation date filter.
- condition¶
Query based on the context item creation date
- Type:
dict or CreatedDateQuery
Example
from trendminer.sdk.context import ContextDateOperators # Create a created_date filter for time earlier than provided date filter = client.context.filter.created_date(condition = {"value" : "2023-11-01 12:00:00", "operator" : ContextDateOperators.LESS_THAN}) # Create a created_date filter for time later or the same time than provided date client.context.filter.created_date(condition = {"value" : "2024-03-22 12:00:00", "operator" : ContextDateOperators.GREATER_THAN_OR_EQUAL})
- class trendminer.sdk.context.filter.CreatedDateQuery(operator: ContextDateOperators, value: datetime | str)¶
Bases:
ABC
Creation date query for creation date context filters.
- value¶
Creation timestamp criterion
- Type:
datetime or str
- operator¶
Operator for context item creation date
- Type:
- class trendminer.sdk.context.filter.CurrentStateFilter(states: list[str], mode: ContextFilterStatesModes | None = None)¶
Bases:
ABC
Filter on context field states.
- states¶
List of (reference to) ContextState
- Type:
list of str
- mode¶
Context Status mode
- Type:
ContextFilterStatesModes Enum, optional
Note
States and mode is mutually exclusive, provide only one of the parameters.
Example
from trendminer.sdk.context import ContextFilterStatesModes # Create a states filter by providing a state mode as a param filter = client.context.filter.states(mode=ContextFilterStatesModes.OPEN_ONLY) # Create a states filter by providing states values client.context.filter.states(states=['Ended'])
- class trendminer.sdk.context.filter.DescriptionFilter(values: list[str], mode: ContextFilterModes | None = None)¶
Bases:
ABC
Filter on context item description.
- values¶
Values on which to filter the description. Can take ‘*’ as wildcard character
- Type:
list of str
- mode¶
Context Filter modes representing ‘EMPTY’ and ‘NON_EMPTY’
- Type:
ContextFilterModes, optional
Note
Values and mode is mutually exclusive, provide only one of the parameters
Example
from trendminer.sdk.context import ContextFilterModes # Create a description filter by providing mode as a param filter = client.context.filter.description(mode=ContextFilterModes.NON_EMPTY) # Create a description filter by providing description values client.context.filter.description(values=["extreme high temp", "hello"])
- property values: list[str]¶
Description values.
- Returns:
String queries to filter on the description
- Return type:
list
- class trendminer.sdk.context.filter.DurationFilter(conditions: list[dict] | list[trendminer.sdk.context.filter.DurationQuery])¶
Bases:
ABC
Filter on context item duration.
- conditions¶
List of entries convertible to DurationQuery, int and float values are considered to be in seconds
- Type:
list of dict or list of DurationQuery
Example
from trendminer.sdk.context import ContextOperators # Create a duration filter with equality condition filter = client.context.filter.duration([{'value': '5h', 'operator': ContextOperators.EQUAL}]) # Create a duration filter with greater than or equals condition filter = client.context.filter.duration(conditions= [{'value': '5h', 'operator': ContextOperators.GREATER_THAN_OR_EQUAL}])
- class trendminer.sdk.context.filter.DurationQuery(operator: ContextOperators, value: timedelta | str)¶
Bases:
ABC
Query based on context item duration.
- operator¶
Context item duration criterion operator
- Type:
- value¶
Context item duration criterion
- Type:
timedelta or str
- class trendminer.sdk.context.filter.EnumerationFieldFilter(field: str, values: list[str], mode: ContextFilterModes | None = None)¶
Bases:
ABC
Context filter on enumeration fields.
- field¶
Name of the context field
- Type:
str
- values¶
Enum values for context field
- Type:
list of str
- mode¶
EMPTY or NON-EMPTY mode for filter
- Type:
ContextFilterModes, optional
Note
Values and mode is mutually exclusive, provide only one of the parameters
Example
from trendminer.sdk.context import ContextFilterModes # Create a field filter by providing mode as a param client.context.filter.field(field = "enum_field", mode=ContextFilterModes.NON_EMPTY) # Create a enum field filter by providing enum values client.context.filter.field(field = "enum_field", values=["danger", "alert"])
- property values: list[str]¶
Filter values
- Returns:
List of values to filter on. Must be values allowed by the field type
- Return type:
list
- class trendminer.sdk.context.filter.IntervalFilter(interval: Interval | tuple[str, ...], created_date: bool)¶
Bases:
ABC
Filter on context item event or creation time through fixed interval.
- created_date¶
Whether we need to filter on creation time rather than event time, default Falses
- Type:
bool
Example
# Create a interval filter on event time filter = client.context.filter.interval(interval = ("2023-11-01 12:00:00", "2024-03-24 23:59:00")) # Create a interval filter on creation time filter = client.context.filter.interval(interval = ("2023-11-01 12:00:00", "2024-03-24 23:59:00"),created_date = True)
- class trendminer.sdk.context.filter.KeywordFilter(keywords: list[str], mode: ContextFilterModes | None = None)¶
Bases:
ABC
Filter on context item keywords.
- keywords¶
Keywords which must be present on the context items
- Type:
list of str
- mode¶
Mode to represent EMPTY or NON-EMPTY.
- Type:
ContextFilterModes, optional
Note
Keywords and mode is mutually exclusive, provide only one of the parameters.
Example
from trendminer.sdk.context import ContextFilterModes # Create a component filter by providing mode as a param filter = client.context.filter.keywords(mode=ContextFilterModes.EMPTY) # Create a keywords filter by providing keywords client.context.filter.keywords(keywords =["bad", "danger"])
- property keywords: list[str]¶
Context item keywords.
- Returns:
Keywords which must be present on the context items
- Return type:
list
- class trendminer.sdk.context.filter.NumericFieldFilter(field: str | ContextField, values: list[dict] | list[trendminer.sdk.context.filter.NumericQuery], mode: ContextFilterModes | None = None)¶
Bases:
ABC
Context filter on numeric fields.
- field¶
Name of the context field
- Type:
str or ContextField
- values¶
List of (entries convertible to) NumericQuery
- Type:
list of dict or list of NumericQuery, optional
- mode¶
EMPTY or NON-EMPTY mode for filter
- Type:
ContextFilterModes, optional
Note
Values and mode is mutually exclusive, provide only one of the parameters
Example
from trendminer.sdk.context import ContextFilterModes #Create a numeric field filter by providing mode as a param client.context.filter.field(field = "numericfield", mode=ContextFilterModes.NON_EMPTY) #Create a numeric field filter by providing values client.context.filter.field(field = "numericfield", values=[{'operator': ContextOperators.LESS_THAN_OR_EQUAL, 'value': 11}])
- class trendminer.sdk.context.filter.NumericQuery(operator: ContextOperators, value: int | float)¶
Bases:
ABC
Filter on context field (in)equality to give value.
- operator¶
Operation to perform
- Type:
- value¶
The value to perform the comparison
- Type:
int or float
- property value: float¶
Filter value
- Returns:
Numeric value to filter on
- Return type:
float
- class trendminer.sdk.context.filter.PeriodFilter(period: Period | str, live: bool)¶
Bases:
ABC
Filter on context item event time with dynamic period.
- live¶
Whether the ContexHubView having this filter needs to update live
- Type:
bool
Example
# Create a period filter filter = client.context.filter.period(period = "10H", live = False) # Create a period filter for live period filter = client.context.filter.period(period = "6M", live = True)
- class trendminer.sdk.context.filter.PropertyFieldFilter(key: str, values: list[str])¶
Bases:
ABC
Filter on other property of context items. Other properties key-value pairs of the context item fields attribute which are not covered by an actual ContextField.
- key¶
Other property key
- Type:
str
- values¶
The corresponding value for the key
- Type:
list of str
Example
# Create a property filter filter = filter_api(key = "key", values=["value"])
- property values: list[str]¶
Filter values
- Returns:
List of values on which to filter
- Return type:
lis
- class trendminer.sdk.context.filter.StringFieldFilter(field: str, values: list[str], mode: ContextFilterModes | None = None)¶
Bases:
ABC
Context filter on string fields.
- field¶
Name of the context field
- Type:
str
- values¶
Text values for context field
- Type:
list of str
- mode¶
EMPTY or NON-EMPTY mode for filter
- Type:
ContextFilterModes, optional
Note
Values and mode is mutually exclusive, provide only one of the parameters
Example
from trendminer.sdk.context import ContextFilterModes # Create a field string filter by providing mode as a param client.context.filter.field(field = "string_field", mode=ContextFilterModes.NON_EMPTY) # Create a field string filter by providing values client.context.filter.field(field = "enum_field", values=["danger", "alert"])
- property values: list[str]¶
Filter values
- Returns:
List of values to filter on. Must be values allowed by the field type.
- Return type:
list
- class trendminer.sdk.context.filter.TypeFilter(context_types: list[str] | list[trendminer.sdk.context.type.ContextType])¶
Bases:
ABC
Filter on context types.
- context_types¶
List of (reference to) ContextType
- Type:
list of ContextType or list of str
Example
# Create a context types filter # Retrieve the created filter of anomaly context type filter = client.context.filter.context_types(["ANOMALY"]) # Retrieve the created filter of information context type filter = client.context.filter.context_types(["INFORMATION"])