Feature/library cli (#363)

* Major Python client API rework, break down API & colossal class

* Complete rest of library API

* Library CLI support
This commit is contained in:
cybermaggedon 2025-05-05 11:09:18 +01:00 committed by GitHub
parent 8146f0f2ff
commit 844547ab5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 1413 additions and 495 deletions

View file

@ -11,11 +11,11 @@ import json
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
def get_interface(api, i):
def get_interface(config_api, i):
key = ConfigKey("interface-descriptions", i)
value = api.config_get([key])[0].value
value = config_api.get([key])[0].value
return json.loads(value)
@ -49,15 +49,17 @@ def describe_interfaces(intdefs, flow):
def show_flows(url):
api = Api(url)
config_api = api.config()
flow_api = api.flow()
interface_names = api.config_list("interface-descriptions")
interface_names = config_api.list("interface-descriptions")
interface_defs = {
i: get_interface(api, i)
i: get_interface(config_api, i)
for i in interface_names
}
flow_ids = api.flow_list()
flow_ids = flow_api.list()
if len(flow_ids) == 0:
print("No flows.")
@ -67,7 +69,7 @@ def show_flows(url):
for id in flow_ids:
flow = api.flow_get(id)
flow = flow_api.get(id)
table = []
table.append(("id", id))