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): ...@@ -64,6 +64,7 @@ def main(use_case: str):
{ {
"UniqueID": "id", "UniqueID": "id",
"name": "name", "name": "name",
"nameIndex": "enum(name)",
"doughType": "dough//type", "doughType": "dough//type",
"hasSpinach": "dough//spinach", "hasSpinach": "dough//spinach",
"firstTopping": "toppings[0]//name", "firstTopping": "toppings[0]//name",
...@@ -81,10 +82,11 @@ def main(use_case: str): ...@@ -81,10 +82,11 @@ def main(use_case: str):
"name": "Price_Layer", "name": "Price_Layer",
"properties": [ "properties": [
"UniqueID", "UniqueID",
"firstToppingPrice" "firstToppingPrice",
"nameIndex"
], ],
"cluster_properties": [ "cluster_properties": [
"firstToppingPrice" "firstToppingPrice",
] ]
}, },
{ {
......
...@@ -2,23 +2,48 @@ from security.token_manager import TokenManager ...@@ -2,23 +2,48 @@ from security.token_manager import TokenManager
import network_constants import network_constants
from typing import List from typing import List
import json, requests import json
import requests
class RestFetcher: 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: def fetch_schema_information(self, use_case: str) -> List:
jwt_token = TokenManager.getInstance().getToken() jwt_token = TokenManager.getInstance().getToken()
# query tables for use-case # query tables for use-case
url = f'https://{network_constants.BUSINESS_LOGIC_HOSTNAME}:{network_constants.BUSINESS_LOGIC_REST_PORT}/api/use-cases/{use_case}/tables' url = f'https://{network_constants.BUSINESS_LOGIC_HOSTNAME}:{network_constants.BUSINESS_LOGIC_REST_PORT}/api/use-cases/{use_case}/tables'
response = requests.get( response = requests.get(
url, url,
verify = False, verify=False,
proxies = { "http":None, "https":None }, proxies={"http": None, "https": None},
headers = { "Authorization": f"Bearer {jwt_token}"} headers={"Authorization": f"Bearer {jwt_token}"}
) )
if response.status_code != 200: 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) tables = json.loads(response.text)
return tables 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