Custom Facts
Note
Sample custom facts definitions csv can be downloaded from here csv
- create_custom_facts_definitions(self, csvFilePath, type_name: str = None, section_name: str = None, overwrite=True)
Utility to add custom facts attribute properties of model or model usecase.
- Parameters:
csvFilePath (str) – File path of csv having the asset properties.
type_name (str) – Asset type user needs to add/update. Current options are modelfacts_user,`model_entry_user`. Default is set to modelfacts_user.
section_name (str) – Custom name to show for custom attribute section. Applies only to model_entry_user type.
overwrite (bool) – (Optional) Merge or replace current properties. Default is True.
A way you might use me is:
>>> client.assets.create_custom_facts_definitions("Asset_type_definition.csv") # uses default type `modelfacts_user` type >>> client.assets.create_custom_facts_definitions("Asset_type_definition.csv",type_name="model_entry_user", localized_name=<custom name for attributes section>,overwrite=False)
- get_facts_definitions(self, type_name: str, container_type: str = None, container_id: str = None) Dict
Get all facts definitions
- Parameters:
type_name (str) – Asset fact type. Current options are modelfacts_user and model_entry_user.
container_type (str) – (Optional) Asset container type. Options are project, space or catalog. Default to container type used when initiating client.
container_id (str) – (Optional) Asset container id. Default to container id when initiating client
- Return type:
dict
A way you might use me is:
>>> client.assets.get_facts_definitions(type_name=<fact type>) # uses container type and id used initializing facts client >>> client.assets.get_facts_definitions(type_name=<fact type>,container_type=<container type>,container_id=<container id>)
- set_custom_fact(self, fact_id: str, value: Any) None
Set custom fact by given id.
- Parameters:
fact_id (str) – Custom fact id.
value (any) – Value of custom fact. It can be string, integer, date. if custom fact definition attribute is_array is set to True, value can be a string or list of strings.
A way you might use me is:
>>> model.set_custom_fact(fact_id="custom_int",value=50) >>> model.set_custom_fact(fact_id="custom_string",value="test") >>> model.set_custom_fact(fact_id="custom_string",value=["test","test2"]) # allowed if attribute property `is_array` is true.
- set_custom_facts(self, facts_dict: Dict[str, Any]) None
Set multiple custom facts.
- Parameters:
facts_dict (dict) – Multiple custom facts. Example: {id: value, id1: value1, …}
A way you might use me is:
>>> model.set_custom_facts({"fact_1": 2, "fact_2": "test", "fact_3":["data1","data2"]})
- get_custom_facts(self) Dict
Get all defined custom facts for modelfacts_user fact type.
- Return type:
dict
A way you might use me is:
>>> model.get_custom_facts()
- get_all_facts(self) Dict
Get all facts related to asset.
- Return type:
dict
A way you might use me is:
>>> model.get_all_facts()
- get_facts_by_type(self, facts_type: str = None) Dict
Get custom facts by asset type.
- Parameters:
facts_type (str) – (Optional) Custom facts asset type. Default to modelfacts_user type. For Openpages facts, use modelfacts_user_op.
- Return type:
dict
A way you might use me is:
>>> model.get_facts_by_type(facts_type=<type name>)
- get_custom_fact_by_id(self, fact_id: str)
Get custom fact value/s by id
- Parameters:
fact_id (str) – Custom fact id to retrieve.
A way you might use me is:
>>> model.get_custom_fact_by_id(fact_id="fact_id")
- remove_custom_fact(self, fact_id: str) None
Remove custom fact by id
- Parameters:
fact_id (str) – Custom fact id value/s to remove.
A way you might use me is:
>>> model.remove_custom_fact(fact_id=<fact_id>)
- remove_custom_facts(self, fact_ids: List[str]) None
Remove multiple custom facts
- Parameters:
fact_ids (list) – Custom fact ids to remove.
A way you might use me is:
>>> model.remove_custom_facts(fact_ids=["id1","id2"])
- reset_custom_facts_definitions(self, type_name: str = None)
Utility to remove custom facts attribute properties of model or model usecase.
- Parameters:
type_name (str) – Asset type user needs to add/update. Current options are modelfacts_user,`model_entry_user`. Default is set to modelfacts_user.
A way you might use me is,:
client.assets.reset_custom_facts_definitions(type_name="model_entry_user")