Commit 0f7bfca8 authored by Manuel Herold's avatar Manuel Herold

[traceRetrieval] implemented enum parsing

parent b38aa85f
{
"ApplicationType": "debug",
"docType": "pizza",
"id": 1,
"dough": {
"type": "wheat",
"spinach": false
},
"toppings": [
{
"name": "cheese",
"price": 0.99
}
],
"name": "Margherita"
}
\ No newline at end of file
......@@ -64,6 +64,7 @@ def main(use_case: str):
{
"UniqueID": "id",
"name": "name",
"nameIndex": "enum(name)",
"doughType": "dough//type",
"hasSpinach": "dough//spinach",
"firstTopping": "toppings[0]//name",
......@@ -81,10 +82,11 @@ def main(use_case: str):
"name": "Price_Layer",
"properties": [
"UniqueID",
"firstToppingPrice"
"firstToppingPrice",
"nameIndex"
],
"cluster_properties": [
"firstToppingPrice"
"firstToppingPrice",
]
},
{
......
......@@ -2,9 +2,33 @@ from security.token_manager import TokenManager
import network_constants
from typing import List
import json, requests
import json
import requests
class RestFetcher:
def fetch_enum_value(self, use_case: str, table: str, enum_name: str, enum_value: str) -> int:
jwt_token = TokenManager.getInstance().getToken()
url = f'https://{network_constants.BUSINESS_LOGIC_HOSTNAME}:{network_constants.BUSINESS_LOGIC_REST_PORT}/api/use-cases/{use_case}/tables/{table}/enum/{enum_name}?value={enum_value}'
print(f"calling {url}")
# query tables for use-case
url = url
response = requests.put(
url,
verify=False,
proxies={"http": None, "https": None},
headers={"Authorization": f"Bearer {jwt_token}"},
)
if response.status_code != 200:
raise ValueError(
f"Error while retrieving Enum information.\tStatus-code:{response.status_code}")
enum = json.loads(response.text)
return enum["index"]
def fetch_schema_information(self, use_case: str) -> List:
jwt_token = TokenManager.getInstance().getToken()
......@@ -12,13 +36,14 @@ class RestFetcher:
url = f'https://{network_constants.BUSINESS_LOGIC_HOSTNAME}:{network_constants.BUSINESS_LOGIC_REST_PORT}/api/use-cases/{use_case}/tables'
response = requests.get(
url,
verify = False,
proxies = { "http":None, "https":None },
headers = { "Authorization": f"Bearer {jwt_token}"}
verify=False,
proxies={"http": None, "https": None},
headers={"Authorization": f"Bearer {jwt_token}"}
)
if response.status_code != 200:
raise ValueError(f"Error while retrieving schema information.\tStatus-code:{response.status_code}")
raise ValueError(
f"Error while retrieving schema information.\tStatus-code:{response.status_code}")
tables = json.loads(response.text)
return tables
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment