Skip to content

Commit

Permalink
#62 Updated api endpoint to new version, changed placement of class.
Browse files Browse the repository at this point in the history
  • Loading branch information
banko-marton committed Nov 4, 2021
1 parent f34932c commit af58a70
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 36 deletions.
42 changes: 6 additions & 36 deletions source/incqueryserver-jupyter/iqs_jupyter/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,42 +56,12 @@ def __init__(
self.jupyter_tools = ext_point.IQSJupyterTools(self)

# Acquiring Model Viewer base link from host through internal API
req = requests.get(f"http://{root_configuration.host}/api/web-console-config")

# Creating ModelViwer url holder to persist link
self.mv_url = ModelViewerUrlProvider(self, req.json()["modelViewerBaseURL"])

# Url provider registering, a function to provide Model Viewer links
ext_point.url_providers.append(self.mv_url.as_url_provider())
ext_point.url_providers.append(ModelViewerUrlProvider(self, req.json()["modelViewerBaseURL"]))

class ModelViewerUrlProvider:
def __init__(self, iqs, mv_address=None):
self.mv_address = mv_address
self.iqs = iqs

def __call__(self, element):
if "compartmentURI" in element and "relativeElementID" in element:
# Creating ModelViewer Link
compURI = element['compartmentURI']
relElementID = element['relativeElementID']
return f"{self.mv_address}?compartmentURI={compURI}&elementId={relElementID}"
else:
return None

def as_url_provider(self):
def url_provider(element_descriptor):
return self.element_api_link(element_descriptor)
return url_provider

def element_api_link(self, element):
if "compartmentURI" in element and "relativeElementID" in element:
# Creating ModelViewer Link
compURI = element['compartmentURI']
relElementID = element['relativeElementID']
return f"{self.mv_address}?compartmentURI={compURI}&elementId={relElementID}"
else:
return None
req = requests.get(f"http://{root_configuration.host}/internal-api/solution-configuration")

# Registering MV URL provider, providing links to MV link received from API call above
ext_point.url_providers.append(ext_point.ModelViewerUrlProvider(self, req.json()["modelViewerBaseURL"]))



class IQSConnectorWidget:
def __init__(
Expand Down
13 changes: 13 additions & 0 deletions source/incqueryserver-jupyter/iqs_jupyter/tool_extension_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,16 @@ def __init__(

url_providers: List[Callable[[Any], Optional[Any]]] = []

class ModelViewerUrlProvider:
def __init__(self, iqs, mv_address=None):
self.mv_address = mv_address
self.iqs = iqs

def __call__(self, element):
if "compartmentURI" in element and "relativeElementID" in element:
# Creating ModelViewer Link
compURI = element['compartmentURI']
relElementID = element['relativeElementID']
return f"{self.mv_address}?compartmentURI={compURI}&elementId={relElementID}"
else:
return None

0 comments on commit af58a70

Please sign in to comment.