[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: implement nexus admin /subscribers cal
From: |
gnunet |
Subject: |
[libeufin] branch master updated: implement nexus admin /subscribers call |
Date: |
Fri, 08 Nov 2019 14:01:48 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new eb13868 implement nexus admin /subscribers call
eb13868 is described below
commit eb13868f603dc2701bd31561f7c2f82b4385d4d7
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Nov 8 14:01:27 2019 +0100
implement nexus admin /subscribers call
---
nexus/src/main/kotlin/JSON.kt | 7 +++++++
nexus/src/main/kotlin/Main.kt | 19 +++++++++++++++++++
sandbox/src/main/python/libeufin-cli | 33 +++++++++++++++++++++++++++------
3 files changed, 53 insertions(+), 6 deletions(-)
diff --git a/nexus/src/main/kotlin/JSON.kt b/nexus/src/main/kotlin/JSON.kt
index 712404d..090838e 100644
--- a/nexus/src/main/kotlin/JSON.kt
+++ b/nexus/src/main/kotlin/JSON.kt
@@ -24,6 +24,13 @@ data class EbicsSubscriberInfoResponse(
val systemID: String?
)
+/**
+ * Admin call that tells all the subscribers managed by Nexus.
+ */
+data class EbicsSubscribersResponse(
+ val ebicsSubscribers: List<EbicsSubscriberInfoResponse>
+)
+
/**
* Error message.
*/
diff --git a/nexus/src/main/kotlin/Main.kt b/nexus/src/main/kotlin/Main.kt
index f9fade8..6683112 100644
--- a/nexus/src/main/kotlin/Main.kt
+++ b/nexus/src/main/kotlin/Main.kt
@@ -217,6 +217,23 @@ fun main() {
return@get
}
+ get("/ebics/subscribers") {
+
+ val ebicsSubscribers = transaction {
+ EbicsSubscriberEntity.all().map {
+ EbicsSubscriberInfoResponse(
+ accountID = it.id.value,
+ hostID = it.hostID,
+ partnerID = it.partnerID,
+ systemID = it.systemID,
+ ebicsURL = it.ebicsURL,
+ userID = it.userID
+ )
+ }
+ }
+ call.respond(EbicsSubscribersResponse(ebicsSubscribers))
+ }
+
get("/ebics/subscribers/{id}") {
val id = expectId(call.parameters["id"])
val response = transaction {
@@ -235,6 +252,8 @@ fun main() {
}
post("/ebics/subscribers") {
+
+ // FIXME: parsed object is not enforced!
val body = try {
call.receive<EbicsSubscriberInfoRequest>()
} catch (e: Exception) {
diff --git a/sandbox/src/main/python/libeufin-cli
b/sandbox/src/main/python/libeufin-cli
index f6b96f8..69ffd51 100755
--- a/sandbox/src/main/python/libeufin-cli
+++ b/sandbox/src/main/python/libeufin-cli
@@ -77,23 +77,35 @@ def sync(obj, customer_id):
print(resp.content.decode("utf-8"))
+@ebics.command(help="retrieve all subscribers in the system")
+@click.pass_obj
+def subscribers(obj):
+
+ url = urljoin(obj["base_url"], "/ebics/subscribers")
+ try:
+ resp = get(url)
+ except Exception:
+ print("Could not reach the bank")
+ return
+
+ print(resp.content.decode("utf-8"))
+
@ebics.command(help="insert new subscriber into Nexus")
@click.pass_obj
@click.option(
"--ebics-url",
help="URL of the EBICS server (defaults to http://localhost:5001/)",
- required=False,
- default="http://localhost:5001"
+ required=False
)
@click.option(
"--user-id",
help="ID of the user to add in the system" ,
- required=True
+ required=False
)
@click.option(
"--partner-id",
help="ID of the partner associated with the user" ,
- required=True
+ required=False
)
@click.option(
"--system-id",
@@ -103,13 +115,22 @@ def sync(obj, customer_id):
@click.option(
"--host-id",
help="ID of the EBICS server" ,
- required=True
+ required=False,
+ default="host01"
)
def new(obj, user_id, partner_id, system_id, host_id, ebics_url):
+ import random
+ salt = random.randrange(0, 1000000000)
+ if not user_id:
+ user_id = "USER{}".format(salt)
+
+ if not partner_id:
+ partner_id = "PARTNER{}".format(salt)
+
url = urljoin(obj["base_url"], "/ebics/subscribers")
body = json=dict(
- ebicsURL=ebics_url,
+ ebicsURL=obj["base_url"],
userID=user_id,
partnerID=partner_id,
hostID=host_id
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: implement nexus admin /subscribers call,
gnunet <=