trendminer.sdk.context.field module¶
This module provides user-facing API’s for interacting with Context Field.
- class trendminer.sdk.context.field.ContextField(name: str, key: str, field_type: ContextFieldOptions, placeholder: str, options: list[str], identifier: str | None = None)¶
Bases:
ABC
A context field refers to a customizable attribute or parameter used to add structured metadata to context items within a system or platform. These fields can include various types of data, such as text, numbers or predefined states, and are typically used to provide additional information or categorization for context items.
- name¶
Context field name
- Type:
str
- key¶
Key that is used as the main identifier of the field. Needs to be unique
- Type:
str
- field_type¶
Context field type basically determines what type of values the field can take
- Type:
- placeholder¶
Field placeholder that is displayed to the user if the field is blank. This is NOT a default value, it is for the visual aid to the user
- Type:
str
- options¶
List of options for enumeration type field
- Type:
list of str
- identifier¶
Unique identifier for context field generated by TrendMiner
- Type:
str, optional, default None
Example
# Create an implementation of context field from trendminer.sdk.context import ContextFieldOptions field = client.context.field(name ="dummy_string_field", field_type=ContextFieldOptions.STRING, key="string_key")
- class trendminer.sdk.context.field.ContextFieldAPI¶
Bases:
ABC
ContextFieldAPI class for creating and retrieving context fields.
- abstract all() list[trendminer.sdk.context.field.ContextField] ¶
Retrieve all instances of context field from Trendminer.
- Returns:
List of all context fields retrieved from Trendminer
- Return type:
list
Example
# Retrieve all the context fields instance type fields = client.context.field.all()
- abstract get(ref: str) ContextField ¶
Retrieves a context field from Trendminer using different retrieval methods, these methods encompass querying by context field identifier, name or key.
Note
The value of ‘ref’ will be checked with identifier, name and then key. The first matching result will be returned based on this order
- Parameters:
ref (str) –
Reference by which a unique context field can be retrieved from Trendminer such as
identifier
name
context field key
- Returns:
The context field pointed by the given reference. Returns the provided input directly if it’s the correct type, None, or a LazyAttribute
- Return type:
Example
# Retrieving a context field using name field = client.context.field.get("context_field_name")
- abstract get_by_identifier(ref: str) ContextField ¶
Retrieve context field by its identifier.
- Parameters:
ref (str) – Context field unique identifier
- Returns:
The corresponding context field
- Return type:
Example
# Retrieving a context field by uuid field = client.context.field.get_by_identifier('01d335d1-43ef-4c7a-8c90-c529850216d0')
- abstract get_by_key(ref: str) ContextField ¶
Retrieve context field by its unique key.
- Parameters:
ref (str) – Context field key
- Returns:
A context field instance type with the given key
- Return type:
Example
# Retrieve a context field by it's unique key field = client.context.field.get_by_key("context_field_key")
- abstract get_by_name(ref: str) ContextField ¶
Retrieve context field by its name.
- Parameters:
ref (str) – Context field name
- Returns:
A context field instance type with the given name
- Return type:
Example
# Retrieve a context field by it's name field = client.context.field.get_by_name("context_field_name")
- abstract list(refs: list[str]) list[trendminer.sdk.context.field.ContextField] ¶
Retrieves a list of contex fields from Trendminer using different retrieval methods, these methods encompass querying by context field identifier, name or key.
Note
Each value of input list will be checked with identifier, name and then key, the first matching result will be returned based on this order
- Parameters:
refs (list[str]) –
List of references representing unique instances on Trendminer.
References by which a unique context field instance can be retrieved from Trendminer such as
identifier
name
context field key
- Returns:
List context fields instance type retrieved from given references
- Return type:
list
Example
# Retrieving a list of context fields fields = client.context.field.list(['context_field_name', '01d335d1-43ef-4c7a-8c90-c529850216d0'])
- abstract search(*args, **kwargs) list[trendminer.sdk.context.field.ContextField] ¶
Search context fields using various search Keywords. It executes search methods based on the provided Keywords and returns a collection of unique results. Duplicate instances are filtered out when multiple methods return overlapping instances.
Note
Atleast one of the below mentioned Keyword Arguments should be provided. Otherwise, an empty list will be returned. If multiple keywords are provided, they will be combined using an AND operation.
- Keyword Arguments:
name (str (optional)) – Name as referance
key (str (optional)) – Search query, can contain * as wildcard
- Returns:
List context field meeting the search criteria
- Return type:
list
Example
# Search performed using key of context field fields = client.context.field.search(key='custom_key') # Search performed using name of context field fields = client.context.field.search(name='context_field_name')
- class trendminer.sdk.context.field.ContextFieldOptions(value)¶
Bases:
Enum
Enum representing Context Field Types.
- ENUMERATION = 'ENUMERATION'¶
ENUMERATION Represents “ENUMERATION” Field Type
- NUMERIC = 'NUMERIC'¶
STRING Represents “NUMERIC” Field Type
- STRING = 'STRING'¶
STRING Represents “STRING” Field Type