[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Fix tasks submission by CLI.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Fix tasks submission by CLI. |
Date: |
Fri, 18 Dec 2020 14:41:43 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 10bd6dc Fix tasks submission by CLI.
10bd6dc is described below
commit 10bd6dcf9994d13e6fe64a14765bef4d62c976ad
Author: MS <ms@taler.net>
AuthorDate: Fri Dec 18 00:24:42 2020 +0100
Fix tasks submission by CLI.
---
cli/libeufin-cli | 29 ++++++++++++----
integration-tests/tests.py | 7 +++-
.../tech/libeufin/nexus/server/NexusServer.kt | 39 ++++------------------
3 files changed, 36 insertions(+), 39 deletions(-)
diff --git a/cli/libeufin-cli b/cli/libeufin-cli
index 8779c20..d6d7ca7 100755
--- a/cli/libeufin-cli
+++ b/cli/libeufin-cli
@@ -229,21 +229,38 @@ def list_offered_bank_accounts(obj, connection_name):
@accounts.command(help="Schedules a new task")
@click.argument("account-name")
@click.option("--task-name", help="Name of the task", required=True)
-@click.option("--cronspec", help="Cronspec string", required=True)
+@click.option("--task-cronspec", help="Cronspec string", required=True)
@click.option(
"--task-type",
help="'fetch' (downloads transactions histories) or 'submit' (uploads
payments instructions)",
required=True
)
@click.option(
- "--task-params",
- help="valid values: 'REPORT', 'STATEMENT', 'ALL' (only applicable to the
'fetch' type)",
- required=True
+ "--task-param-rangeType",
+ help="Only needed for 'fetch'. (FIXME: link to documentation here!)",
+ required=False
+)
+@click.option(
+ "--task-param-level",
+ help="Only needed for 'fetch'. (FIXME: link to documentation here!)",
+ required=False
)
@click.pass_obj
-def task_schedule(obj, account_name, task_name, cronspec , task_type,
task_params):
+def task_schedule(
+ obj, account_name, task_name, task_cronspec,
+ task_type, task_param_rangetype, task_param_level):
+
url = urljoin(obj.nexus_base_url,
"/bank-accounts/{}/schedule".format(account_name))
- body = dict(name=task_name, type=task_type, params=task_params)
+ body = dict(
+ name=task_name,
+ cronspec=task_cronspec,
+ type=task_type
+ )
+ if task_type == "fetch" and not (task_param_rangetype or task_param_level):
+ print("'fetch' type requires --task-param-rangeType and
--task-param-level")
+ return
+
+ body.update(dict(params=dict(rangeType=task_param_rangetype,
level=task_param_level)))
try:
resp = post(url, json=body, auth=auth.HTTPBasicAuth(obj.username,
obj.password))
except Exception:
diff --git a/integration-tests/tests.py b/integration-tests/tests.py
index 1748528..fd08f7e 100755
--- a/integration-tests/tests.py
+++ b/integration-tests/tests.py
@@ -125,7 +125,12 @@ def teardown_function():
dropNexusTables(DB)
def test_env():
- print("Nexus and Sandbox are up and running!")
+ print("Nexus and Sandbox are up and running!\n")
+ print(f"Nexus URL: {NEXUS_URL}")
+ print(f"Sandbox URL: {SANDBOX_URL}")
+ print(f"Username/password active at Nexus:
{PERSONA.nexus.username}/{PERSONA.nexus.password}")
+ print(f"Bank connection name: {PERSONA.nexus.bank_connection}")
+ print(f"Imported bank account label: {PERSONA.nexus.bank_label}")
try:
input("\npress enter to stop LibEuFin test environment ...")
except:
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index df5a3d2..84ce00d 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -403,9 +403,7 @@ fun serverMain(dbName: String, host: String) {
resp.set<JsonNode>("schedule", ops)
transaction {
val bankAccount =
NexusBankAccountEntity.findById(accountId)
- if (bankAccount == null) {
- throw NexusError(HttpStatusCode.NotFound, "unknown
bank account")
- }
+ ?: throw NexusError(HttpStatusCode.NotFound, "unknown
bank account")
NexusScheduledTaskEntity.find {
(NexusScheduledTasksTable.resourceType eq
"bank-account") and
(NexusScheduledTasksTable.resourceId eq
accountId)
@@ -420,28 +418,6 @@ fun serverMain(dbName: String, host: String) {
Unit
}
call.respond(resp)
- }
-
- // Get all the scheduled jobs to the requester.
- get("/bank-accounts/{accountid}/schedule") {
- val ret = mutableListOf<AccountTask>()
- transaction {
- NexusScheduledTaskEntity.all().forEach {
- ret.add(
- AccountTask(
- resourceType = it.resourceType,
- resourceId = it.resourceId,
- taskName = it.taskName,
- taskType = it.taskType,
- taskCronspec = it.taskCronspec,
- taskParams = it.taskParams,
- nextScheduledExecutionSec =
it.nextScheduledExecutionSec,
- prevScheduledExecutionSec =
it.prevScheduledExecutionSec
- )
- )
- }
- }
- call.respond(ret)
return@get
}
@@ -451,9 +427,7 @@ fun serverMain(dbName: String, host: String) {
transaction {
authenticateRequest(call.request)
val bankAccount =
NexusBankAccountEntity.findById(accountId)
- if (bankAccount == null) {
- throw NexusError(HttpStatusCode.NotFound, "unknown
bank account")
- }
+ ?: throw NexusError(HttpStatusCode.NotFound, "unknown
bank account")
try {
NexusCron.parser.parse(schedSpec.cronspec)
} catch (e: IllegalArgumentException) {
@@ -463,9 +437,7 @@ fun serverMain(dbName: String, host: String) {
when (schedSpec.type) {
"fetch" -> {
val fetchSpec =
jacksonObjectMapper().treeToValue(schedSpec.params, FetchSpecJson::class.java)
- if (fetchSpec == null) {
- throw NexusError(HttpStatusCode.BadRequest,
"bad fetch spec")
- }
+ ?: throw NexusError(HttpStatusCode.BadRequest,
"bad fetch spec")
}
"submit" -> {}
else -> throw NexusError(HttpStatusCode.BadRequest,
"unsupported task type")
@@ -490,11 +462,14 @@ fun serverMain(dbName: String, host: String) {
}
}
call.respond(object { })
+ return@post
}
get("/bank-accounts/{accountId}/schedule/{taskId}") {
val task = transaction {
-
NexusScheduledTaskEntity.findById(ensureInt(call.parameters["taskId"]))
+ NexusScheduledTaskEntity.find {
+ NexusScheduledTasksTable.taskName eq
ensureNonNull(call.parameters["taskId"])
+ }.firstOrNull()
}
call.respond(
if (task != null) {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Fix tasks submission by CLI.,
gnunet <=