v1 server and lifecycle manager working. execution contract added
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from .execute import executeRequest
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
import requests
|
||||
|
||||
from .request import buildRequest
|
||||
|
||||
session = requests.Session()
|
||||
|
||||
def executeRequest(definition, outputs):
|
||||
request = buildRequest(definition, outputs)
|
||||
|
||||
response = session.request(
|
||||
method=request["method"],
|
||||
url=request["path"],
|
||||
json=request.get("object"),
|
||||
headers=request.get("headers")
|
||||
)
|
||||
|
||||
# if definition hasattr(cookies):
|
||||
# sessioncookies = {}
|
||||
|
||||
# for cookie_name, cookie_key in cookies:
|
||||
|
||||
# session.cookies.set(
|
||||
# sessioncookies[cookie_name] = response[cookie_key],
|
||||
|
||||
|
||||
return response
|
||||
@@ -0,0 +1,9 @@
|
||||
def buildKey(key, outputs):
|
||||
value = key["keyvalue"]
|
||||
|
||||
if isinstance(value, dict) and "output" in value:
|
||||
value = outputs[value["output"]]
|
||||
|
||||
return {
|
||||
key["keytitle"]: value,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
from .key import buildKey
|
||||
|
||||
def buildObject(keys, outputs):
|
||||
object = {}
|
||||
|
||||
for key in keys:
|
||||
object.update(
|
||||
buildKey(key, outputs),
|
||||
)
|
||||
|
||||
return object
|
||||
@@ -0,0 +1,28 @@
|
||||
from .object import buildObject
|
||||
|
||||
def buildRequest(definition, outputs):
|
||||
request = {
|
||||
"method": definition.method,
|
||||
"path": definition.path,
|
||||
}
|
||||
|
||||
if hasattr(definition, "keys"):
|
||||
request["object"] = buildObject(definition.keys, outputs)
|
||||
|
||||
if hasattr(definition, "headers"):
|
||||
headers = {}
|
||||
|
||||
for header_name, header_value in definition.headers.items():
|
||||
value = header_value
|
||||
|
||||
if isinstance(value, dict) and "output" in header_value:
|
||||
value = outputs[value["output"]]
|
||||
|
||||
if isinstance(header_value, dict) and "prefix" in header_value:
|
||||
value = header_value["prefix"] + value
|
||||
|
||||
headers[header_name] = value
|
||||
|
||||
request["headers"] = headers
|
||||
|
||||
return request
|
||||
Reference in New Issue
Block a user