Working resolver integration with buildSelect3 exception
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,8 +4,8 @@ from .request import buildRequest
|
||||
|
||||
session = requests.Session()
|
||||
|
||||
def executeRequest(action, outputs):
|
||||
request, outputs = buildRequest(action, outputs)
|
||||
def executeRequest(action, outputs, resolved):
|
||||
request, outputs = buildRequest(action, outputs, resolved)
|
||||
|
||||
response = session.request(
|
||||
method=request["method"],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
def buildKey(key, outputs):
|
||||
def buildKey(key, outputs, resolved):
|
||||
value = key["keyvalue"]
|
||||
|
||||
if isinstance(value, dict) and "output" in value:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from .key import buildKey
|
||||
|
||||
def buildObject(keys, outputs):
|
||||
def buildObject(keys, outputs, resolved):
|
||||
object = {}
|
||||
|
||||
for key in keys:
|
||||
object.update(
|
||||
buildKey(key, outputs),
|
||||
buildKey(key, outputs, resolved),
|
||||
)
|
||||
|
||||
return object
|
||||
|
||||
+26
-4
@@ -1,4 +1,4 @@
|
||||
def buildPath(path, outputs):
|
||||
def buildPath(path, outputs, resolved):
|
||||
if isinstance(path, str):
|
||||
return path
|
||||
|
||||
@@ -6,9 +6,10 @@ def buildPath(path, outputs):
|
||||
|
||||
for part in path:
|
||||
if isinstance(part, dict):
|
||||
value = outputs[part["output"]][part["keys"]]
|
||||
|
||||
|
||||
for key, val in part.items():
|
||||
#value = outputs[part["output"]][part["keys"]]
|
||||
value = outputs[val]
|
||||
#print("DEBUG path", value)
|
||||
|
||||
#for key in part.get("keys", []):
|
||||
#value = value[key]
|
||||
@@ -16,5 +17,26 @@ def buildPath(path, outputs):
|
||||
result += str(value)
|
||||
else:
|
||||
result += part
|
||||
#print(result)
|
||||
return result
|
||||
|
||||
def buildPath2(path, outputs, resolved):
|
||||
if isinstance(path, str):
|
||||
return path
|
||||
|
||||
result = ""
|
||||
|
||||
for part in path:
|
||||
if isinstance(part, dict):
|
||||
#value = outputs[part["output"]][part["keys"]]
|
||||
value = outputs["path"]
|
||||
#print("DEBUG path", value)
|
||||
|
||||
#for key in part.get("keys", []):
|
||||
#value = value[key]
|
||||
|
||||
result += str(value)
|
||||
else:
|
||||
result += part
|
||||
#print(result)
|
||||
return result
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from .object import buildObject
|
||||
from .path import buildPath
|
||||
|
||||
def buildRequest(definition, outputs):
|
||||
path = buildPath(definition.path, outputs)
|
||||
def buildRequest(definition, outputs, resolved):
|
||||
path = buildPath(definition.path, outputs, resolved)
|
||||
|
||||
request = {
|
||||
"method": definition.method,
|
||||
@@ -10,7 +10,7 @@ def buildRequest(definition, outputs):
|
||||
}
|
||||
|
||||
if hasattr(definition, "keys"):
|
||||
request["object"] = buildObject(definition.keys, outputs)
|
||||
request["object"] = buildObject(definition.keys, outputs, resolved)
|
||||
|
||||
if hasattr(definition, "headers"):
|
||||
headers = {}
|
||||
|
||||
Binary file not shown.
@@ -3,16 +3,23 @@ from core.runtime.savedata import loadSave, buildSave
|
||||
from core.runtime.outputs import buildOutput
|
||||
from core.runtime.logs import buildLog
|
||||
from core.runtime.runtimecontract import buildRuntimeAttr
|
||||
from core.runtime.resolver import resolveItem
|
||||
|
||||
def buildAction (action, outputs):
|
||||
|
||||
#resolved ={}
|
||||
def buildAction (action, outputs):#, resolved):
|
||||
|
||||
if hasattr(action, "loaddata"):
|
||||
outputs = loadSave(outputs, action)
|
||||
|
||||
response, outputs = executeRequest(action, outputs)
|
||||
resolved = {}
|
||||
if hasattr(action, "resolve"):
|
||||
resolved = resolveItem(action, outputs)
|
||||
|
||||
response, outputs = executeRequest(action, outputs, resolved)
|
||||
|
||||
#print("DEBUG:", outputs)
|
||||
|
||||
#print(resolved)
|
||||
|
||||
outputs, response = buildRuntimeAttr(action, outputs, response)
|
||||
|
||||
return outputs, response
|
||||
|
||||
Binary file not shown.
@@ -6,32 +6,39 @@ from core.runtime.outputs import buildOutput
|
||||
from core.runtime.managefailure import manageFailure
|
||||
from core.execution.action.action import buildAction
|
||||
from .skipstep import skipStep
|
||||
from core.runtime.resolver import resolveItem
|
||||
from core.runtime.resolver import resolveItem2
|
||||
from core.apirequest import executeRequest
|
||||
|
||||
def buildOperation(definition):
|
||||
actions = definition.actions
|
||||
#print("DEBUG", actions)
|
||||
responses = []
|
||||
outputs = {}
|
||||
#resolved = {}
|
||||
|
||||
for action in actions:
|
||||
#try:
|
||||
if hasattr(definition, "skipstep"):
|
||||
if skipStep(definition, action, outputs):
|
||||
continue
|
||||
|
||||
#if hasattr(definition, "resolve"):
|
||||
#resolved = {}
|
||||
#if hasattr(action, "resolve"):
|
||||
#print(outputs)
|
||||
#resolved = resolveItem(action, outputs)
|
||||
#print(resolved)
|
||||
if hasattr(action, "recursive"):
|
||||
outputs[action.recursive["target"]] = {}
|
||||
#outputs[action.recursive["target"]] = {}
|
||||
for item in outputs[action.recursive["source"]]:
|
||||
resolved = resolveItem(action, item)
|
||||
print("Resolved value:", resolved)
|
||||
outputs = resolveItem2(action, item, outputs)#, resolved)
|
||||
#print("Resolved value:", outputs)
|
||||
#outputs[action.recursive["target"]] = outputs[action.recursive["source"]][][action.recursive["target"]]
|
||||
#print(outputs[action.recursive["target"]])
|
||||
outputs[action.recursive["target"]] = item
|
||||
print(outputs[action.recursive["target"]])
|
||||
#print(outputs[action.recursive["target"]])
|
||||
#target = outputs[action.recursive["source"]["target"]
|
||||
outputs, response = buildAction(action, outputs)
|
||||
#print(item)
|
||||
outputs, response = buildAction(action, outputs)#, resolved)
|
||||
#print(outputs)
|
||||
#return outputs
|
||||
else:
|
||||
outputs, response = buildAction(action, outputs)
|
||||
@@ -39,5 +46,5 @@ def buildOperation(definition):
|
||||
|
||||
#except Exception as error:
|
||||
#outputs = manageFailure(error, action, outputs)
|
||||
print(outputs["message"])
|
||||
#print(outputs["message"])
|
||||
return outputs
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,8 +2,9 @@ def resolveItem(action, item):
|
||||
resolved = {}
|
||||
label = action.resolve["label"]
|
||||
targetkeys = action.resolve["targetkeys"]
|
||||
|
||||
#print(item)
|
||||
target = item
|
||||
|
||||
for key in targetkeys:
|
||||
target = target[key]
|
||||
|
||||
@@ -20,3 +21,29 @@ def resolveItem(action, item):
|
||||
#print(resolved[label])
|
||||
|
||||
return resolved
|
||||
|
||||
def resolveItem2(action, item, outputs):
|
||||
#resolved = {}
|
||||
label = action.resolve["label"]
|
||||
targetkeys = action.resolve["targetkeys"]
|
||||
#print(item)
|
||||
target = item
|
||||
|
||||
for key in targetkeys:
|
||||
target = target[key]
|
||||
|
||||
#resolved[label] = target
|
||||
|
||||
#for label, keys in action.resolve.items():
|
||||
#target = item
|
||||
|
||||
#print(target)
|
||||
#for key in keys:
|
||||
#target = target[key]
|
||||
|
||||
#resolved[label] = target
|
||||
#print(resolved[label])
|
||||
|
||||
outputs[label] = target
|
||||
#print("Resolver DEBUG", target, outputs[label])
|
||||
return outputs
|
||||
|
||||
@@ -66,8 +66,41 @@ def buildSelect2(action, outputs):
|
||||
#select_data.append(item)
|
||||
|
||||
def buildSelect3(action, outputs):
|
||||
#print(outputs)
|
||||
try:
|
||||
select_data = []
|
||||
|
||||
target = outputs[action.select["source"]]
|
||||
includekey = action.select["include"]["key"]
|
||||
includevalue = action.select["include"]["value"]
|
||||
excludekey = action.select["exclude"]["key"]
|
||||
excludevalue = action.select["exclude"]["value"]
|
||||
|
||||
|
||||
for item in target:
|
||||
include_match = True
|
||||
exclude_match = True
|
||||
|
||||
if includekey:
|
||||
include_match = item[includekey] == includevalue
|
||||
|
||||
if excludekey:
|
||||
exclude_match = item[excludekey] != excludevalue
|
||||
|
||||
if include_match and exclude_match:
|
||||
select_data.append(item)
|
||||
|
||||
|
||||
outputs[action.select["source"]] = select_data
|
||||
print(select_data)
|
||||
return select_data, action, outputs
|
||||
except (KeyError, TypeError):
|
||||
return select_data, action, outputs
|
||||
|
||||
def buildSelect4(action, outputs):
|
||||
#print(outputs)
|
||||
select_data = []
|
||||
|
||||
target = outputs[action.select["source"]]
|
||||
#selectmethod = action.select["selectmethod"]
|
||||
includekey = action.select["include"]["key"]
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,5 @@
|
||||
import os
|
||||
|
||||
#getoutputs = {"emails": [0, "id"]}
|
||||
|
||||
name = "Get message"
|
||||
|
||||
@@ -12,12 +11,6 @@ showstatus = True
|
||||
|
||||
method = "GET"
|
||||
|
||||
#path = f"https://rentmasseur.com/api/v1/mailbox/{messageid}"
|
||||
#path = [
|
||||
# "https://rentmasseur.com/api/v1/mailbox/",
|
||||
# {"output": "[messageid][0].id"}
|
||||
#]
|
||||
|
||||
resolve = {
|
||||
"targetkeys": ["id"],
|
||||
"label": "path",
|
||||
@@ -25,11 +18,12 @@ resolve = {
|
||||
|
||||
path = [
|
||||
"https://rentmasseur.com/api/v1/mailbox/",
|
||||
{
|
||||
"output": "id",
|
||||
#"keys": [0, "id"]
|
||||
"keys": "id"
|
||||
}
|
||||
{"suffix": "path"}
|
||||
#{
|
||||
# "output": "id",
|
||||
# #"keys": [0, "id"]
|
||||
# "keys": "id"
|
||||
#}
|
||||
]
|
||||
|
||||
#path = os.path.join(baseurl.messageid)
|
||||
@@ -43,12 +37,14 @@ headers = {
|
||||
|
||||
recursive = {
|
||||
"source": "emails",
|
||||
#Transformation target. dynamic target to be resolved in each iteration
|
||||
"target": "id"
|
||||
}
|
||||
|
||||
|
||||
outputs = {
|
||||
"message": "messages"
|
||||
"message": "messages",
|
||||
"profile": "profileData",
|
||||
}
|
||||
|
||||
select = {
|
||||
|
||||
@@ -6,33 +6,3 @@ from core.execution.action import buildAction
|
||||
|
||||
outputs = buildOperation(rmass.operations.pullmessagelist)
|
||||
|
||||
#print(outputs)
|
||||
#print(messageid)
|
||||
#user_list = []
|
||||
#for item in outputs["message_list"]:
|
||||
# sender = item["userCard"]
|
||||
# user_list.append(sender["id"])
|
||||
#print(user_list)
|
||||
|
||||
#conversations = []
|
||||
#for item in outputs["message_list"]:
|
||||
# conversation = item["id"]
|
||||
# conversations.append(conversation)
|
||||
|
||||
#print(conversations)
|
||||
|
||||
#for messageid in conversations:
|
||||
#outputs = buildAction(rmass.actions.getmessage, outputs)
|
||||
|
||||
#print(outputs)
|
||||
|
||||
|
||||
#for messageid in user_list
|
||||
#outputs = buildOperation(rmass.operations.getmessage)
|
||||
#id_list = []
|
||||
#for user in user_list
|
||||
# id_list.append
|
||||
# print
|
||||
|
||||
|
||||
#ime.sleep(rmass.operations.setavailable.sleeptime)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTE5MDM5MDEsIm5iZiI6MTc5MTkwMzcyMSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTkwMzc4MX0.dwJ10VfIyUSANbKlG0UqzoRqWfZpU0vdUh44IoEbwKeaNPk6d_J6yvrLQy_uY18IfQR_3t4PEp7Qrwa9Eqtyig", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ0OTU3ODEsIm5iZiI6MTc5MTkwMzcyMSwianRpIjoiK3pMamtvVlhnN1ZhZmd1OGtib21CQkhxR0R5QmZVdVMxeTgzb0NmQWttcz0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvb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