add get_service_with_docs_by_service_type()

Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: tischrei <tino.schreiber@t-systems.com>
Co-committed-by: tischrei <tino.schreiber@t-systems.com>
This commit is contained in:
Tino Schreiber 2023-02-21 10:44:51 +00:00 committed by zuul
parent e06e27d0e0
commit 8de5c8ba57

View File

@ -209,3 +209,22 @@ class Services(object):
doc_struct[srv["service_category"]].append(srv_res) doc_struct[srv["service_category"]].append(srv_res)
return dict(categories=doc_struct) return dict(categories=doc_struct)
def get_service_with_docs_by_service_type(self, service_type):
"""Retrieve service and service docs by service_type
:param str service_type: Filter by service_type
"""
res = dict()
res['service'] = {}
docs = []
services = self._service_data
for doc in services['documents']:
if doc['service_type'] == service_type:
docs.append(doc)
res['documents'] = docs
for service in services['services']:
if service['service_type'] == service_type:
res['service'] = service
break
return res