mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-17 17:21:02 +02:00
Config service working through gateway
This commit is contained in:
parent
3f050669b2
commit
cc17998944
5 changed files with 251 additions and 46 deletions
174
test-api/test-config-api
Executable file
174
test-api/test-config-api
Executable file
|
|
@ -0,0 +1,174 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
|
||||
url = "http://localhost:8088/api/v1/"
|
||||
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"operation": "config"
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}config",
|
||||
json=input,
|
||||
)
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f"Status code: {resp.status_code}")
|
||||
|
||||
resp = resp.json()
|
||||
|
||||
if "error" in resp:
|
||||
print(f"Error: {resp['error']}")
|
||||
sys.exit(1)
|
||||
|
||||
print(json.dumps(resp, indent=4))
|
||||
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"operation": "put",
|
||||
"type": "test",
|
||||
"key": "key1",
|
||||
"value": "value1"
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}config",
|
||||
json=input,
|
||||
)
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f"Status code: {resp.status_code}")
|
||||
|
||||
resp = resp.json()
|
||||
|
||||
if "error" in resp:
|
||||
print(f"Error: {resp['error']}")
|
||||
sys.exit(1)
|
||||
|
||||
print(json.dumps(resp, indent=4))
|
||||
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"operation": "put",
|
||||
"type": "test",
|
||||
"key": "key2",
|
||||
"value": "testing 1 2 3"
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}config",
|
||||
json=input,
|
||||
)
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f"Status code: {resp.status_code}")
|
||||
|
||||
resp = resp.json()
|
||||
|
||||
if "error" in resp:
|
||||
print(f"Error: {resp['error']}")
|
||||
sys.exit(1)
|
||||
|
||||
print(json.dumps(resp, indent=4))
|
||||
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"operation": "get",
|
||||
"type": "test",
|
||||
"key": "key2",
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}config",
|
||||
json=input,
|
||||
)
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f"Status code: {resp.status_code}")
|
||||
|
||||
resp = resp.json()
|
||||
|
||||
if "error" in resp:
|
||||
print(f"Error: {resp['error']}")
|
||||
sys.exit(1)
|
||||
|
||||
print(json.dumps(resp, indent=4))
|
||||
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"operation": "config"
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}config",
|
||||
json=input,
|
||||
)
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f"Status code: {resp.status_code}")
|
||||
|
||||
resp = resp.json()
|
||||
|
||||
if "error" in resp:
|
||||
print(f"Error: {resp['error']}")
|
||||
sys.exit(1)
|
||||
|
||||
print(json.dumps(resp, indent=4))
|
||||
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"operation": "list",
|
||||
"type": "test"
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}config",
|
||||
json=input,
|
||||
)
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f"Status code: {resp.status_code}")
|
||||
|
||||
resp = resp.json()
|
||||
|
||||
if "error" in resp:
|
||||
print(f"Error: {resp['error']}")
|
||||
sys.exit(1)
|
||||
|
||||
print(json.dumps(resp, indent=4))
|
||||
|
||||
############################################################################
|
||||
|
||||
input = {
|
||||
"operation": "getall",
|
||||
"type": "test"
|
||||
}
|
||||
|
||||
resp = requests.post(
|
||||
f"{url}config",
|
||||
json=input,
|
||||
)
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f"Status code: {resp.status_code}")
|
||||
|
||||
resp = resp.json()
|
||||
|
||||
if "error" in resp:
|
||||
print(f"Error: {resp['error']}")
|
||||
sys.exit(1)
|
||||
|
||||
print(json.dumps(resp, indent=4))
|
||||
|
||||
############################################################################
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue