Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions python-lib/osisoft_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,14 +758,15 @@ def search_attributes(self, database_webid, **kwargs):
else:
json_response = None

def search_elements(self, database_webid, name=None, description=None, category=None, template=None, full_search=True):
def search_elements(self, database, name=None, description=None, category=None, template=None, full_search=True):
headers = self.get_requests_headers()
tempo_maxcount = OSIsoftConstants.DEFAULT_MAXCOUNT
params = {
"maxCount": tempo_maxcount,
"associations": "Paths",
}
url = self.endpoint.get_base_url() + "/assetdatabases/{}/elements".format(database_webid)
# url = self.endpoint.get_base_url() + "/assetdatabases/{}/elements".format(database_webid)
url = "{}/elements".format(database)
if name:
params["nameFilter"] = name
if description:
Expand Down
29 changes: 29 additions & 0 deletions resource/browse_af_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def do(payload, config, plugin_config, inputs):
)

method = payload.get("method")
logger.info("Running do for method '{}'".format(method))
if method == "get_query_catalogs":
return get_query_catalogs(None, config)
if method == "get_children_from_db":
Expand Down Expand Up @@ -107,6 +108,34 @@ def do(payload, config, plugin_config, inputs):
"get_element_categories_from_db",
lambda: get_items_from_db(client, parent, "ElementCategories", database_name=database_name)
)
if method == "get_elements_for_template":
database_name = config.get("database_name")
template_name = config.get("template", None)
elements = []
for element in client.search_elements(database_name, name=None, description=None, category=None, template=template_name, full_search=True):
elements.append(get_item_details(element))
return {"choices": [], "elements": elements}
if method=="get_attribute_for_template":
database_name = config.get("database_name")
template_name = config.get("template", None)
if template_name is None:
return {"choices": [], "attributes": []}
# when searching for template : attribute_name=None, element_category=None, attribute_category=None
elements_max_count, attributes_max_count = get_max_counts(config)
attributes = []
for result in client.batched_search(
database_name, None, None,
None, None, template_name, [],
elements_max_count=elements_max_count, attributes_max_count=attributes_max_count
):
attributes.append(result)
attributes = split_real_from_linked_paths(attributes)
items = []
for attribute in attributes:
item = get_item_details(attribute)
items.append(item)
items = expand_items_by_paths(items)
return {"choices": [], "attributes": items}
if method == "do_search":
template_name = config.get("template", None)
category_name = config.get("element_category", None)
Expand Down