Skip to content

Commit

Permalink
build(openapi): generate kotlin client
Browse files Browse the repository at this point in the history
    Primary Changes
    ---------------
    1. Updated the cactus-plugin-ledger-connector-corda
       package.json file to incorporate generate-client script
    2. Created a git action workflow to generate version-tagged
       client artifacts

Fixes #2000

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
  • Loading branch information
jagpreetsinghsasan authored and petermetz committed Jan 4, 2023
1 parent 6dbe6b5 commit 25f2f54
Show file tree
Hide file tree
Showing 101 changed files with 4,317 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
## Handle line endings automatically for files detected as
## text and leave all files detected as binary untouched.
## This will handle all files NOT defined below.
* text=auto
* text=auto eol=lf

## SOURCE CODE
*.bat text eol=crlf
# *.bat text eol=crlf
*.coffee text
*.css text
*.htm text diff=html
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/ghpkg-all-kotlin-api-clients-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: ghpkg-all-kotlin-api-clients-publish

on:
push:
branches: [main, dev]

pull_request:
branches: [main, dev]

jobs:
publish:
runs-on: ubuntu-20.04
steps:
- name: Install Indy SDK
run: >
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 \
&& sudo add-apt-repository "deb https://repo.sovrin.org/sdk/deb bionic stable" \
&& sudo apt-get update \
&& sudo apt-get install -y \
libindy \
libnullpay \
libvcx \
indy-cli \
&& sudo rm -f /etc/apt/sources.list.d/sovrin.list*
- name: Checkout
uses: actions/checkout@v3.1.0
with:
fetch-depth: 0

- name: Get the latest release version
run: |
export GITVERSION=$(git describe --tags | awk -F'.' '{print $$1}')
echo "GITVERSION=$GITVERSION" >> $GITHUB_ENV
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'

- name: Set up NodeJS v16.9.1
uses: actions/setup-node@v2.1.2
with:
node-version: v16.9.1

- run: yarn configure

- name: build-cactus-plugin-ledger-connector-corda-kotlin-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-ledger-connector-corda/src/main/kotlin/generated/openapi/kotlin-client
chmod +x gradlew
./gradlew clean
./gradlew build
- name: publish-cactus-plugin-ledger-connector-corda-kotlin-client
uses: actions/upload-artifact@v3.0.0
with:
name: cactus-plugin-ledger-connector-corda-kotlin-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-ledger-connector-corda/src/main/kotlin/generated/openapi/kotlin-client/build/libs/kotlin-client-1.0.0.jar
4 changes: 3 additions & 1 deletion packages/cactus-plugin-ledger-connector-corda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"scripts": {
"codegen": "run-p 'codegen:*'",
"codegen:openapi": "run-p generate-sdk generate-server",
"generate-sdk": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/",
"generate-sdk": "run-p generate-sdk:*",
"generate-sdk:typescript-axios": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/",
"generate-sdk:kotlin": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g kotlin -o ./src/main/kotlin/generated/openapi/kotlin-client/ --reserved-words-mappings protected=protected",
"generate-server": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g kotlin-spring -o ./src/main-server/kotlin/gen/kotlin-spring/ -c ./src/main-server/openapi-generator-config.yaml",
"watch": "npm-watch",
"webpack": "npm-run-all webpack:dev",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
README.md
build.gradle
docs/ClearMonitorTransactionsV1Request.md
docs/ClearMonitorTransactionsV1Response.md
docs/CordaNodeSshCredentials.md
docs/CordaRpcCredentials.md
docs/CordaX500Name.md
docs/CordappDeploymentConfig.md
docs/CordappInfo.md
docs/DefaultApi.md
docs/DeployContractJarsBadRequestV1Response.md
docs/DeployContractJarsSuccessV1Response.md
docs/DeployContractJarsV1Request.md
docs/DiagnoseNodeV1Request.md
docs/DiagnoseNodeV1Response.md
docs/FlowInvocationType.md
docs/GetMonitorTransactionsV1Request.md
docs/GetMonitorTransactionsV1Response.md
docs/GetMonitorTransactionsV1ResponseTx.md
docs/InvokeContractV1Request.md
docs/InvokeContractV1Response.md
docs/JarFile.md
docs/JvmObject.md
docs/JvmType.md
docs/JvmTypeKind.md
docs/ListFlowsV1Request.md
docs/ListFlowsV1Response.md
docs/NetworkHostAndPort.md
docs/NodeDiagnosticInfo.md
docs/NodeInfo.md
docs/Party.md
docs/PublicKey.md
docs/SHA256.md
docs/StartMonitorV1Request.md
docs/StartMonitorV1Response.md
docs/StopMonitorV1Request.md
docs/StopMonitorV1Response.md
docs/X500Principal.md
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
settings.gradle
src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiInfrastructureResponse.kt
src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt
src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
src/main/kotlin/org/openapitools/client/infrastructure/URIAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt
src/main/kotlin/org/openapitools/client/models/ClearMonitorTransactionsV1Request.kt
src/main/kotlin/org/openapitools/client/models/ClearMonitorTransactionsV1Response.kt
src/main/kotlin/org/openapitools/client/models/CordaNodeSshCredentials.kt
src/main/kotlin/org/openapitools/client/models/CordaRpcCredentials.kt
src/main/kotlin/org/openapitools/client/models/CordaX500Name.kt
src/main/kotlin/org/openapitools/client/models/CordappDeploymentConfig.kt
src/main/kotlin/org/openapitools/client/models/CordappInfo.kt
src/main/kotlin/org/openapitools/client/models/DeployContractJarsBadRequestV1Response.kt
src/main/kotlin/org/openapitools/client/models/DeployContractJarsSuccessV1Response.kt
src/main/kotlin/org/openapitools/client/models/DeployContractJarsV1Request.kt
src/main/kotlin/org/openapitools/client/models/DiagnoseNodeV1Request.kt
src/main/kotlin/org/openapitools/client/models/DiagnoseNodeV1Response.kt
src/main/kotlin/org/openapitools/client/models/FlowInvocationType.kt
src/main/kotlin/org/openapitools/client/models/GetMonitorTransactionsV1Request.kt
src/main/kotlin/org/openapitools/client/models/GetMonitorTransactionsV1Response.kt
src/main/kotlin/org/openapitools/client/models/GetMonitorTransactionsV1ResponseTx.kt
src/main/kotlin/org/openapitools/client/models/InvokeContractV1Request.kt
src/main/kotlin/org/openapitools/client/models/InvokeContractV1Response.kt
src/main/kotlin/org/openapitools/client/models/JarFile.kt
src/main/kotlin/org/openapitools/client/models/JvmObject.kt
src/main/kotlin/org/openapitools/client/models/JvmType.kt
src/main/kotlin/org/openapitools/client/models/JvmTypeKind.kt
src/main/kotlin/org/openapitools/client/models/ListFlowsV1Request.kt
src/main/kotlin/org/openapitools/client/models/ListFlowsV1Response.kt
src/main/kotlin/org/openapitools/client/models/NetworkHostAndPort.kt
src/main/kotlin/org/openapitools/client/models/NodeDiagnosticInfo.kt
src/main/kotlin/org/openapitools/client/models/NodeInfo.kt
src/main/kotlin/org/openapitools/client/models/Party.kt
src/main/kotlin/org/openapitools/client/models/PublicKey.kt
src/main/kotlin/org/openapitools/client/models/SHA256.kt
src/main/kotlin/org/openapitools/client/models/StartMonitorV1Request.kt
src/main/kotlin/org/openapitools/client/models/StartMonitorV1Response.kt
src/main/kotlin/org/openapitools/client/models/StopMonitorV1Request.kt
src/main/kotlin/org/openapitools/client/models/StopMonitorV1Response.kt
src/main/kotlin/org/openapitools/client/models/X500Principal.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.2.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# org.openapitools.client - Kotlin client library for Hyperledger Cactus Plugin - Connector Corda

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3

## Build

First, create the gradle wrapper script:

```
gradle wrapper
```

Then, run:

```
./gradlew check assemble
```

This runs all tests and packages the library.

## Features/Implementation Notes

* Supports JSON inputs/outputs, File inputs, and Form inputs.
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets.

<a name="documentation-for-api-endpoints"></a>
## Documentation for API Endpoints

All URIs are relative to *http://localhost*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**clearMonitorTransactionsV1**](docs/DefaultApi.md#clearmonitortransactionsv1) | **DELETE** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/clear-monitor-transactions | Clear transactions from internal store so they'll not be available by GetMonitorTransactionsV1 anymore.
*DefaultApi* | [**deployContractJarsV1**](docs/DefaultApi.md#deploycontractjarsv1) | **POST** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/deploy-contract-jars | Deploys a set of jar files (Cordapps, e.g. the contracts in Corda speak).
*DefaultApi* | [**diagnoseNodeV1**](docs/DefaultApi.md#diagnosenodev1) | **POST** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/diagnose-node |
*DefaultApi* | [**getMonitorTransactionsV1**](docs/DefaultApi.md#getmonitortransactionsv1) | **GET** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/get-monitor-transactions | Get transactions for monitored state classes.
*DefaultApi* | [**getPrometheusMetricsV1**](docs/DefaultApi.md#getprometheusmetricsv1) | **GET** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/get-prometheus-exporter-metrics | Get the Prometheus Metrics
*DefaultApi* | [**invokeContractV1**](docs/DefaultApi.md#invokecontractv1) | **POST** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/invoke-contract | Invokes a contract on a Corda ledger (e.g. a flow)
*DefaultApi* | [**listFlowsV1**](docs/DefaultApi.md#listflowsv1) | **POST** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/list-flows |
*DefaultApi* | [**networkMapV1**](docs/DefaultApi.md#networkmapv1) | **POST** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/network-map |
*DefaultApi* | [**startMonitorV1**](docs/DefaultApi.md#startmonitorv1) | **POST** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/start-monitor | Start monitoring corda changes (transactions) of given state class
*DefaultApi* | [**stopMonitorV1**](docs/DefaultApi.md#stopmonitorv1) | **DELETE** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-corda/stop-monitor | Stop monitoring corda changes (transactions) of given state class


<a name="documentation-for-models"></a>
## Documentation for Models

- [org.openapitools.client.models.ClearMonitorTransactionsV1Request](docs/ClearMonitorTransactionsV1Request.md)
- [org.openapitools.client.models.ClearMonitorTransactionsV1Response](docs/ClearMonitorTransactionsV1Response.md)
- [org.openapitools.client.models.CordaNodeSshCredentials](docs/CordaNodeSshCredentials.md)
- [org.openapitools.client.models.CordaRpcCredentials](docs/CordaRpcCredentials.md)
- [org.openapitools.client.models.CordaX500Name](docs/CordaX500Name.md)
- [org.openapitools.client.models.CordappDeploymentConfig](docs/CordappDeploymentConfig.md)
- [org.openapitools.client.models.CordappInfo](docs/CordappInfo.md)
- [org.openapitools.client.models.DeployContractJarsBadRequestV1Response](docs/DeployContractJarsBadRequestV1Response.md)
- [org.openapitools.client.models.DeployContractJarsSuccessV1Response](docs/DeployContractJarsSuccessV1Response.md)
- [org.openapitools.client.models.DeployContractJarsV1Request](docs/DeployContractJarsV1Request.md)
- [org.openapitools.client.models.DiagnoseNodeV1Request](docs/DiagnoseNodeV1Request.md)
- [org.openapitools.client.models.DiagnoseNodeV1Response](docs/DiagnoseNodeV1Response.md)
- [org.openapitools.client.models.FlowInvocationType](docs/FlowInvocationType.md)
- [org.openapitools.client.models.GetMonitorTransactionsV1Request](docs/GetMonitorTransactionsV1Request.md)
- [org.openapitools.client.models.GetMonitorTransactionsV1Response](docs/GetMonitorTransactionsV1Response.md)
- [org.openapitools.client.models.GetMonitorTransactionsV1ResponseTx](docs/GetMonitorTransactionsV1ResponseTx.md)
- [org.openapitools.client.models.InvokeContractV1Request](docs/InvokeContractV1Request.md)
- [org.openapitools.client.models.InvokeContractV1Response](docs/InvokeContractV1Response.md)
- [org.openapitools.client.models.JarFile](docs/JarFile.md)
- [org.openapitools.client.models.JvmObject](docs/JvmObject.md)
- [org.openapitools.client.models.JvmType](docs/JvmType.md)
- [org.openapitools.client.models.JvmTypeKind](docs/JvmTypeKind.md)
- [org.openapitools.client.models.ListFlowsV1Request](docs/ListFlowsV1Request.md)
- [org.openapitools.client.models.ListFlowsV1Response](docs/ListFlowsV1Response.md)
- [org.openapitools.client.models.NetworkHostAndPort](docs/NetworkHostAndPort.md)
- [org.openapitools.client.models.NodeDiagnosticInfo](docs/NodeDiagnosticInfo.md)
- [org.openapitools.client.models.NodeInfo](docs/NodeInfo.md)
- [org.openapitools.client.models.Party](docs/Party.md)
- [org.openapitools.client.models.PublicKey](docs/PublicKey.md)
- [org.openapitools.client.models.SHA256](docs/SHA256.md)
- [org.openapitools.client.models.StartMonitorV1Request](docs/StartMonitorV1Request.md)
- [org.openapitools.client.models.StartMonitorV1Response](docs/StartMonitorV1Response.md)
- [org.openapitools.client.models.StopMonitorV1Request](docs/StopMonitorV1Request.md)
- [org.openapitools.client.models.StopMonitorV1Response](docs/StopMonitorV1Response.md)
- [org.openapitools.client.models.X500Principal](docs/X500Principal.md)


<a name="documentation-for-authorization"></a>
## Documentation for Authorization

All endpoints do not require authorization.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
group 'org.openapitools'
version '1.0.0'

wrapper {
gradleVersion = '6.8.3'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}

buildscript {
ext.kotlin_version = '1.5.10'

repositories {
maven { url "https://repo1.maven.org/maven2" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

apply plugin: 'kotlin'

repositories {
maven { url "https://repo1.maven.org/maven2" }
}

test {
useJUnitPlatform()
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
implementation "com.squareup.moshi:moshi-adapters:1.12.0"
implementation "com.squareup.okhttp3:okhttp:4.9.1"
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# ClearMonitorTransactionsV1Request

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**clientAppId** | **kotlin.String** | ID of a client application that wants to monitor the state changes |
**stateFullClassName** | **kotlin.String** | The fully qualified name of the Corda state to monitor |
**txIndexes** | **kotlin.collections.List&lt;kotlin.String&gt;** | |



Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# ClearMonitorTransactionsV1Response

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**success** | **kotlin.Boolean** | Flag set to true if operation completed correctly. |
**msg** | **kotlin.String** | Message describing operation status or any errors that occurred. |



Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# CordaNodeSshCredentials

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**hostKeyEntry** | **kotlin.String** | |
**username** | **kotlin.String** | |
**password** | **kotlin.String** | |
**hostname** | **kotlin.String** | |
**port** | **kotlin.Int** | |



Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# CordaRpcCredentials

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**hostname** | **kotlin.String** | |
**port** | **kotlin.Int** | |
**username** | **kotlin.String** | |
**password** | **kotlin.String** | |



Loading

0 comments on commit 25f2f54

Please sign in to comment.