Skip to content

Commit

Permalink
feat(connector-corda): support corda 5 RC via TS/HTTP (no JVM)
Browse files Browse the repository at this point in the history
Fixes hyperledger-cacti#1480
Signed-off-by: adrian.batuto <[email protected]>
  • Loading branch information
johnhomantaring authored and adrianbatuto committed Oct 20, 2023
1 parent 5ad0ebf commit 5a30cba
Show file tree
Hide file tree
Showing 73 changed files with 4,796 additions and 109 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.openapi-generator-ignore
README.md
models/health_check_response_pb.proto
models/memory_usage_pb.proto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/Spri
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/api/ApiPluginLedgerConnectorCordaController.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/api/ApiPluginLedgerConnectorCordaService.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/api/ApiUtil.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/CPIIDV5.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/CPIV5Response.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/CPIV5ResponseCpisInner.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/CPIV5ResponseCpisInnerCpksInner.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/ClearMonitorTransactionsV1Request.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/ClearMonitorTransactionsV1Response.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/CordaNodeSshCredentials.kt
Expand All @@ -19,6 +23,10 @@ src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/mode
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/DiagnoseNodeV1Request.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/DiagnoseNodeV1Response.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/FlowInvocationType.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/FlowStatusV5Response.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/FlowStatusV5Responses.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/FlowStatusV5ResponsesFlowStatusResponsesInner.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/FlowV5Error.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/GetMonitorTransactionsV1Request.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/GetMonitorTransactionsV1Response.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/GetMonitorTransactionsV1ResponseTxInner.kt
Expand All @@ -36,6 +44,8 @@ src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/mode
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/Party.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/PublicKey.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/SHA256.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/StartFlowV5Request.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/StartFlowV5RequestRequestBody.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/StartMonitorV1Request.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/StartMonitorV1Response.kt
src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/StopMonitorV1Request.kt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package org.hyperledger.cactus.plugin.ledger.connector.corda.server.api

import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.CPIV5Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.ClearMonitorTransactionsV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.ClearMonitorTransactionsV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DeployContractJarsBadRequestV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DeployContractJarsSuccessV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DeployContractJarsV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DiagnoseNodeV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DiagnoseNodeV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.FlowStatusV5Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.FlowStatusV5Responses
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.GetMonitorTransactionsV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.GetMonitorTransactionsV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.InvokeContractV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.InvokeContractV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.ListFlowsV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.ListFlowsV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.NodeInfo
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.StartFlowV5Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.StartMonitorV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.StartMonitorV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.StopMonitorV1Request
Expand Down Expand Up @@ -102,6 +106,58 @@ class ApiPluginLedgerConnectorCordaController(@Autowired(required = true) val se
return ResponseEntity(service.diagnoseNodeV1(diagnoseNodeV1Request), HttpStatus.valueOf(200))
}

@Operation(
summary = "This method gets the current status of the specified flow instance.",
operationId = "flowStatusResponse",
description = """""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(schema = Schema(implementation = FlowStatusV5Response::class))]),
ApiResponse(responseCode = "401", description = "Unauthorized"),
ApiResponse(responseCode = "403", description = "Forbidden") ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/flow/{holdingIDShortHash}/{clientRequestID}"],
produces = ["text/plain"]
)
fun flowStatusResponse(@Parameter(description = "Holding identity short hash", required = true) @PathVariable("holdingIDShortHash") holdingIDShortHash: kotlin.String,@Parameter(description = "Client request ID", required = true) @PathVariable("clientRequestID") clientRequestID: kotlin.String): ResponseEntity<FlowStatusV5Response> {
return ResponseEntity(service.flowStatusResponse(holdingIDShortHash, clientRequestID), HttpStatus.valueOf(200))
}

@Operation(
summary = "This method returns an array containing the statuses of all flows running for a specified holding identity. An empty array is returned if there are no flows running.",
operationId = "flowStatusResponses",
description = """""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(schema = Schema(implementation = FlowStatusV5Responses::class))]),
ApiResponse(responseCode = "401", description = "Unauthorized"),
ApiResponse(responseCode = "403", description = "Forbidden") ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/flow/{holdingIDShortHash}"],
produces = ["text/plain"]
)
fun flowStatusResponses(@Parameter(description = "Holding identity short hash", required = true) @PathVariable("holdingIDShortHash") holdingIDShortHash: kotlin.String): ResponseEntity<FlowStatusV5Responses> {
return ResponseEntity(service.flowStatusResponses(holdingIDShortHash), HttpStatus.valueOf(200))
}

@Operation(
summary = "List all CPIs uploaded to the cluster",
operationId = "getCPIResponse",
description = """""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(schema = Schema(implementation = CPIV5Response::class))]) ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/cpi"],
produces = ["application/json"]
)
fun getCPIResponse(): ResponseEntity<CPIV5Response> {
return ResponseEntity(service.getCPIResponse(), HttpStatus.valueOf(200))
}

@Operation(
summary = "Get transactions for monitored state classes.",
operationId = "getMonitorTransactionsV1",
Expand Down Expand Up @@ -186,6 +242,23 @@ class ApiPluginLedgerConnectorCordaController(@Autowired(required = true) val se
return ResponseEntity(service.networkMapV1(body), HttpStatus.valueOf(200))
}

@Operation(
summary = "This method starts a new instance for the specified flow for the specified holding identity.",
operationId = "startFlowParameters",
description = """""",
responses = [
ApiResponse(responseCode = "200", description = "OK", content = [Content(schema = Schema(implementation = FlowStatusV5Response::class))]) ]
)
@RequestMapping(
method = [RequestMethod.POST],
value = ["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/flow/{holdingIDShortHash}"],
produces = ["application/json"],
consumes = ["application/json"]
)
fun startFlowParameters(@Parameter(description = "Holding identity short hash", required = true) @PathVariable("holdingIDShortHash") holdingIDShortHash: kotlin.String,@Parameter(description = "Request body for starting a flow", required = true) @Valid @RequestBody startFlowV5Request: StartFlowV5Request): ResponseEntity<FlowStatusV5Response> {
return ResponseEntity(service.startFlowParameters(holdingIDShortHash, startFlowV5Request), HttpStatus.valueOf(200))
}

@Operation(
summary = "Start monitoring corda changes (transactions) of given state class",
operationId = "startMonitorV1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package org.hyperledger.cactus.plugin.ledger.connector.corda.server.api

import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.CPIV5Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.ClearMonitorTransactionsV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.ClearMonitorTransactionsV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DeployContractJarsBadRequestV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DeployContractJarsSuccessV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DeployContractJarsV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DiagnoseNodeV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.DiagnoseNodeV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.FlowStatusV5Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.FlowStatusV5Responses
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.GetMonitorTransactionsV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.GetMonitorTransactionsV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.InvokeContractV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.InvokeContractV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.ListFlowsV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.ListFlowsV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.NodeInfo
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.StartFlowV5Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.StartMonitorV1Request
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.StartMonitorV1Response
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.StopMonitorV1Request
Expand Down Expand Up @@ -50,6 +54,37 @@ interface ApiPluginLedgerConnectorCordaService {
*/
fun diagnoseNodeV1(diagnoseNodeV1Request: DiagnoseNodeV1Request?): DiagnoseNodeV1Response

/**
* GET /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/flow/{holdingIDShortHash}/{clientRequestID} : This method gets the current status of the specified flow instance.
*
* @param holdingIDShortHash Holding identity short hash (required)
* @param clientRequestID Client request ID (required)
* @return OK (status code 200)
* or Unauthorized (status code 401)
* or Forbidden (status code 403)
* @see ApiPluginLedgerConnectorCorda#flowStatusResponse
*/
fun flowStatusResponse(holdingIDShortHash: kotlin.String, clientRequestID: kotlin.String): FlowStatusV5Response

/**
* GET /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/flow/{holdingIDShortHash} : This method returns an array containing the statuses of all flows running for a specified holding identity. An empty array is returned if there are no flows running.
*
* @param holdingIDShortHash Holding identity short hash (required)
* @return OK (status code 200)
* or Unauthorized (status code 401)
* or Forbidden (status code 403)
* @see ApiPluginLedgerConnectorCorda#flowStatusResponses
*/
fun flowStatusResponses(holdingIDShortHash: kotlin.String): FlowStatusV5Responses

/**
* GET /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/cpi : List all CPIs uploaded to the cluster
*
* @return OK (status code 200)
* @see ApiPluginLedgerConnectorCorda#getCPIResponse
*/
fun getCPIResponse(): CPIV5Response

/**
* GET /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/get-monitor-transactions : Get transactions for monitored state classes.
*
Expand Down Expand Up @@ -96,6 +131,16 @@ interface ApiPluginLedgerConnectorCordaService {
*/
fun networkMapV1(body: kotlin.Any?): List<NodeInfo>

/**
* POST /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/flow/{holdingIDShortHash} : This method starts a new instance for the specified flow for the specified holding identity.
*
* @param holdingIDShortHash Holding identity short hash (required)
* @param startFlowV5Request Request body for starting a flow (required)
* @return OK (status code 200)
* @see ApiPluginLedgerConnectorCorda#startFlowParameters
*/
fun startFlowParameters(holdingIDShortHash: kotlin.String, startFlowV5Request: StartFlowV5Request): FlowStatusV5Response

/**
* POST /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/start-monitor : Start monitoring corda changes (transactions) of given state class
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.hyperledger.cactus.plugin.ledger.connector.corda.server.model

import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Email
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.v3.oas.annotations.media.Schema

/**
*
* @param name
* @param version
* @param signerSummaryHash
*/
data class CPIIDV5(

@Schema(example = "string", required = true, description = "")
@get:JsonProperty("name", required = true) val name: kotlin.String,

@Schema(example = "string", required = true, description = "")
@get:JsonProperty("version", required = true) val version: kotlin.String,

@Schema(example = "string", description = "")
@get:JsonProperty("signerSummaryHash") val signerSummaryHash: kotlin.String? = null
) {

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.hyperledger.cactus.plugin.ledger.connector.corda.server.model

import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.CPIV5ResponseCpisInner
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Email
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.v3.oas.annotations.media.Schema

/**
*
* @param cpis
*/
data class CPIV5Response(

@field:Valid
@Schema(example = "null", description = "")
@get:JsonProperty("cpis") val cpis: kotlin.collections.List<CPIV5ResponseCpisInner>? = null
) {

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.hyperledger.cactus.plugin.ledger.connector.corda.server.model

import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.CPIIDV5
import org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.CPIV5ResponseCpks
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid

/**
*
* @param cpiFileChecksum
* @param cpiFileFullChecksum
* @param cpks
* @param groupPolicy
* @param id
* @param timestamp
*/
data class CPIV5ResponseCpis(

@field:JsonProperty("cpiFileChecksum") val cpiFileChecksum: kotlin.String? = null,

@field:JsonProperty("cpiFileFullChecksum") val cpiFileFullChecksum: kotlin.String? = null,

@field:Valid
@field:JsonProperty("cpks") val cpks: kotlin.collections.List<CPIV5ResponseCpks>? = null,

@field:JsonProperty("groupPolicy") val groupPolicy: kotlin.String? = null,

@field:Valid
@field:JsonProperty("id") val id: CPIIDV5? = null,

@field:JsonProperty("timestamp") val timestamp: java.time.OffsetDateTime? = null
) {

}

Loading

0 comments on commit 5a30cba

Please sign in to comment.