mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Feature/config service (#332)
Configuration service provides an API to change configuration. Complete configuration is pushed down a config queue so that users have a complete copy of config object.
This commit is contained in:
parent
21bda863a7
commit
fa09dc319e
17 changed files with 1002 additions and 5 deletions
248
test-api/test-config-api
Executable file
248
test-api/test-config-api
Executable file
|
|
@ -0,0 +1,248 @@
|
|||
#!/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",
|
||||
"values": [
|
||||
{
|
||||
"type": "test",
|
||||
"key": "key1",
|
||||
"value": "value1"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"key": "key2",
|
||||
"value": "value2"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
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",
|
||||
"values": [
|
||||
{
|
||||
"type": "test",
|
||||
"key": "key3",
|
||||
"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",
|
||||
"keys": [
|
||||
{
|
||||
"type": "test",
|
||||
"key": "key2"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"key": "key3"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
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": "getvalues",
|
||||
"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": "delete",
|
||||
"keys": [
|
||||
{
|
||||
"type": "test",
|
||||
"key": "key1"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"key": "key3"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
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))
|
||||
|
||||
############################################################################
|
||||
Loading…
Add table
Add a link
Reference in a new issue