gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: Retrieving facade details from other t


From: gnunet
Subject: [libeufin] branch master updated: Retrieving facade details from other table
Date: Wed, 13 Jan 2021 10:44:38 +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 1610d8a  Retrieving facade details from other table
1610d8a is described below

commit 1610d8ada82608f70b3e821d5519639bdc0f42c5
Author: MS <ms@taler.net>
AuthorDate: Wed Jan 13 10:44:28 2021 +0100

    Retrieving facade details from other table
---
 .../main/kotlin/tech/libeufin/nexus/server/JSON.kt |  4 +--
 .../tech/libeufin/nexus/server/NexusServer.kt      | 39 +++++++++++++++++++++-
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
index e57ea7c..c0e2a77 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
@@ -322,7 +322,8 @@ data class BankMessageInfo(
 data class FacadeShowInfo(
     val name: String,
     val type: String,
-    val baseUrl: String
+    val baseUrl: String,
+    val config: JsonNode
 )
 
 data class FacadeInfo(
@@ -364,7 +365,6 @@ data class AccountTask(
     val prevScheduledExecutionSec: Long? // human-readable time (= Epoch when 
this value doesn't exist in DB)
 )
 
-
 data class CreateAccountTaskRequest(
     val name: String,
     val cronspec: String,
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 20eb16a..ff64723 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -69,6 +69,25 @@ import java.net.URLEncoder
 import java.nio.file.Paths
 import java.util.zip.InflaterInputStream
 
+// Return facade state depending on the type.
+fun getFacadeState(type: String, facade: FacadeEntity): JsonNode {
+    return transaction {
+        when (type) {
+            "taler-wire-gateway" -> {
+                val state = TalerFacadeStateEntity.find {
+                    TalerFacadeStateTable.facade eq facade.id
+                }.firstOrNull()
+                if (state == null) throw 
NexusError(HttpStatusCode.NotFound,"State of facade ${facade.id} not found")
+                val node = jacksonObjectMapper().createObjectNode()
+                node.put("bankConnection", state.bankConnection)
+                node.put("bankAccount", state.bankAccount)
+                node
+            }
+            else -> throw NexusError(HttpStatusCode.NotFound,"Facade type 
${type} not supported")
+        }
+    }
+}
+
 
 fun ensureNonNull(param: String?): String {
     return param ?: throw NexusError(
@@ -854,6 +873,23 @@ fun serverMain(dbName: String, host: String, port: Int) {
                 call.respondBytes(ret.msgContent, ContentType("application", 
"xml"))
             }
 
+            get("/facades/{fcid}") {
+                val fcid = ensureNonNull(call.parameters["fcid"])
+                val ret = transaction {
+                    val f = FacadeEntity.findById(fcid) ?: throw NexusError(
+                        HttpStatusCode.NotFound, "Facade ${fcid} does not 
exist"
+                    )
+                    FacadeShowInfo(
+                        name = f.id.value,
+                        type = f.type,
+                        baseUrl = 
"http://${host}/facades/${f.id.value}/${f.type}/";,
+                        config = getFacadeState(f.type, f)
+                    )
+                }
+                call.respond(ret)
+                return@get
+            }
+
             get("/facades") {
                 val ret = object { val facades = 
mutableListOf<FacadeShowInfo>() }
                 transaction {
@@ -865,7 +901,8 @@ fun serverMain(dbName: String, host: String, port: Int) {
                             FacadeShowInfo(
                                 name = it.id.value,
                                 type = it.type,
-                                baseUrl = 
"http://${host}/facades/${it.id.value}/${it.type}/";
+                                baseUrl = 
"http://${host}/facades/${it.id.value}/${it.type}/";,
+                                config = getFacadeState(it.type, it)
                             )
                         )
                     }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]