36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from .object import buildObject
|
|
from .path import buildPath
|
|
import os
|
|
|
|
def buildRequest(definition, outputs, resolved):
|
|
path = buildPath(definition.path, outputs, resolved)
|
|
|
|
request = {
|
|
"method": definition.method,
|
|
"path": path,
|
|
}
|
|
|
|
if hasattr(definition, "keys"):
|
|
request["object"] = buildObject(definition.keys, outputs, resolved)
|
|
|
|
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(value, dict) and "os" in header_value:
|
|
#value = os.environ[definition.headers[header_name]["os"]]
|
|
value = os.environ["AS_TOKEN"]
|
|
|
|
if isinstance(header_value, dict) and "prefix" in header_value:
|
|
value = header_value["prefix"] + value
|
|
|
|
headers[header_name] = value
|
|
|
|
request["headers"] = headers
|
|
|
|
return request, outputs
|