trendminer.sdk.asset.asset module¶
This module provides user-facing API’s for interacting with Assets and Attributes.
- class trendminer.sdk.asset.asset.Asset(name: str, description: str, identifier: str, source: dict, template: str | None = None, identifier_template: str | None = None, identifier_external: str | None = None, path_hex: str | None = None)¶
Bases:
ABC
An asset is a node in the asset framework that can be parent to attributes or other assets.
- name¶
Instance name. The name of asset
- Type:
str
- description¶
The description of the asset
- Type:
str
- identifier¶
Unique identifier to the asset object
- Type:
str
- source¶
A dictionary comprising essential details of the asset framework should include keys ‘name’ and ‘af_type’, denoting the name and type of the asset framework. The asset framework type, identified as ‘af_type’ can either be “CSV” or “DATASOURCE”
- Type:
dict
- template¶
The asset or attribute template when defined
- Type:
str, optional
- identifier_template¶
The template is identified differently depending on the asset structure type In a CSV asset structure, identifier_template corresponds to the template which is a straightforward string representing the template name
- Type:
str, optional
- identifier_external¶
The identifier of the asset within the external source differs depending on the type of asset framework. In the case of a CSV asset framework, it corresponds to the asset’s path within the structure
- Type:
str, optional
- path_hex¶
Hexadecimal identifiers used for internal referencing. e.g. “0000025e.0000025f.00000260”
- Type:
str, optional
- class trendminer.sdk.asset.asset.AssetAPI¶
Bases:
ABC
A class that provides user-friendly functions for interacting with Assets or Attributes.
- abstract get(ref: any) Asset | Attribute ¶
Retrieves an asset instance from the appliance using different retrieval methods. These methods encompass querying by identifier, path_hex or path.
Note
The value of ‘ref’ will be checked with identifier, path_hex and then path. The first matching result will be returned based on this order
- Parameters:
ref (Any) –
Reference by which a unique instance can be retrieved from the appliance such as:
identifier
path_hex
path
- Returns:
The instance pointed to by the given reference
- Return type:
Example
# Retriving asset with hex values asset_by_hex_path=client.asset.get("00000004")
- abstract get_by_identifier(ref: str) Asset | Attribute ¶
Retrieve an Asset or Attribute by its identifier.
- Parameters:
ref (str) – Asset or Attribute identifier
- Returns:
The corresponding asset or attribute instance type
- Return type:
Example
asset=client.asset.get_by_identifier('af390306-f9bf-46ee-8a93-fe29b6797719')
- abstract get_by_path(ref: str) Asset | Attribute ¶
Retrieve an Asset or Attribute on a given path.
- Parameters:
ref (str) – Asset or Attribute path
- Returns:
Asset or attribute on the given path
- Return type:
Example
asset=client.asset.get_by_path("MyNewAf112")
- abstract get_by_path_hex(ref: str) Asset | Attribute ¶
Retrieve an Asset or Attribute by path with hex values.
- Parameters:
ref (str) – Hexagonal path as string, e.g. “0000025e.0000025f.00000260”
- Returns:
The asset or attribute at the given Hexagonal path.
- Return type:
Example
asset_by_hex_path=client.asset.get_by_path_hex('00000001')
- abstract list(refs: list[any]) list[trendminer.sdk.asset.asset.Asset] | list[trendminer.sdk.asset.asset.Attribute] ¶
Retrieves a list of instances from the appliance using different retrieval methods. These methods encompass querying by identifier, path_hex or path.
Note
Each value of input list will be checked with identifier, path_hex and then path. The first matching result will be returned based on this order
- Parameters:
refs (list[Any]) –
List of references representing unique instances on the appliance. Reference by which a unique instance can be retrieved from the appliance such as:
identifier
path_hex
path
- Returns:
List of asset or attribute instances retrieved from given references
- Return type:
list
Example
# Retriving assets asset_list=client.asset.list(['MyNewAsset', 'MyAsset'])
- abstract search(*args, **kwargs) list[trendminer.sdk.asset.asset.Asset] | list[trendminer.sdk.asset.asset.Attribute] ¶
Search instances 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 reference for the asset
description (str (optional)) – Full description of description substring
template (str (optional)) – Full template or template substring
rsql (optional) – RSQL query, e.g. “name==my_asset”
- Returns:
List of instances meeting the search criteria.
- Return type:
list
Example
# asset should be present asset=client.asset.search(name="MyNewAf112")
- class trendminer.sdk.asset.asset.AssetIncludeOptions(value)¶
Bases:
Enum
Enum representing Asset.
- ANCESTORS = 'ANCESTORS'¶
ANCESTOR: Represents “ANCESTORS” asset
- DESCENDANTS = 'DESCENDANTS'¶
DESCENDANTS: Represents “DESCENDANTS” asset
- SELF = 'SELF'¶
SELF: Represents “SELF” asset
- class trendminer.sdk.asset.asset.Attribute(name: str, description: str, identifier: str, source: dict, tag: Tag, template: str | None = None, identifier_template: str | None = None, identifier_external: str | None = None, path_hex: str | None = None, color: Color | str | None = None, scale: list[float] | None = None, shift: timedelta | None = None, visible: bool | None = None)¶
Bases:
ABC
Attributes are the end nodes of an asset framework, linking to a tag. Attributes can be included in a TrendHub view directly.
- name¶
Instance name. The name of attribute
- Type:
str
- description¶
The description of the attribute
- Type:
str
- identifier¶
Unique identifier to the attribute object on the appliance
- Type:
str
- source¶
A dictionary comprising essential details of the asset framework should include keys ‘name’ and ‘af_type’, denoting the name and type of the asset framework. The asset framework type, identified as ‘af_type’ can either be “CSV” or “DATASOURCE”
- Type:
dict
- template¶
The asset or attribute template when defined
- Type:
str, optional
- identifier_template¶
The template is identified differently depending on the asset structure type. In a CSV asset structure, identifier_template corresponds to the template which is a straightforward string representing the template name
- Type:
str, optional
- identifier_external¶
The identifier of the asset within the external source differs depending on the type of asset framework. In the case of a CSV asset framework, it corresponds to the asset’s path within the structure
- Type:
str, optional
- path_hex¶
Hexadecimal identifiers used for internal referencing. e.g. “0000025e.0000025f.00000260”
- Type:
str, optional
- color¶
Chart display color. If no color is chosen, a random color is selected from a list of distinguishable colors. Supports the standard format of representation defined in color library.for string input provide 3 or 6 hex digit color code. For example, ‘#f0a3ff’ for Amethyst
- Type:
Color or str, optional
- scale¶
[min, max] scale on the chart if scale is set
- Type:
list of float or None
- shift¶
Impacts all data operations
- Type:
timedelta, optional
- visible¶
Whether object visible on the chart or hidden
- Type:
bool, optional
- abstract property interpolation_type: str¶
Underlying tag interpolation type.
- Returns:
“LINEAR” or “STEPPED”
- Return type:
str
- abstract isnumeric() bool ¶
Checks if the underlying tag is numeric (i.e: analog or discrete, rather than digital or string).
- Returns:
Whether the underlying tag is numeric
- Return type:
bool