Skip to content

Commit

Permalink
build(api-client): generate java, go clients
Browse files Browse the repository at this point in the history
    Primary Changes
    ---------------
    1. Updated package.json of packages to include the new
       codegen scripts
    2. Added a new workflow to create and upload the jars from
       the newly added code

   Changes required to incorporate 1)
   ---------------------------------
   3. Added replace package to assist the codegen scripts
      written in package.json

Fixes #393

Signed-off-by: jagpreetsinghsasan <[email protected]>
  • Loading branch information
jagpreetsinghsasan committed Jan 11, 2024
1 parent 1fb2551 commit f31112a
Show file tree
Hide file tree
Showing 2,701 changed files with 497,475 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/.dast-nuclei-cmd-api-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ jobs:
# - name: GitHub Security Dashboard Alerts update
# uses: github/codeql-action/upload-sarif@v1
# with:
# sarif_file: ~/nuclei.sarif
# sarif_file: ~/nuclei.sarif
197 changes: 197 additions & 0 deletions .github/workflows/ghpkg-all-java-api-clients-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: ghpkg-all-java-api-clients-publish

on:
push:
branches: [main, dev]

pull_request:
branches: [main, dev]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
publish:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/[email protected]
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/[email protected]
with:
distribution: 'adopt'
java-version: '8'

- name: Setup maven for packaging jars
uses: s4u/[email protected]
with:
maven-version: 3.9.4

- name: Set up NodeJS v16.14.2
uses: actions/[email protected]
with:
node-version: v16.14.2

- run: yarn && yarn configure

- name: build-cactus-cmd-api-server-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-cmd-api-server/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-cmd-api-server-java-client
uses: actions/[email protected]
with:
name: cactus-cmd-api-server-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-cmd-api-server/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-keychain-aws-sm-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-keychain-aws-sm/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-keychain-aws-sm-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-keychain-aws-sm-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-keychain-aws-sm/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-keychain-azure-kv-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-keychain-azure-kv/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-keychain-azure-kv-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-keychain-azure-kv-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-keychain-azure-kv/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-keychain-google-sm-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-keychain-google-sm/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-keychain-google-sm-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-keychain-google-sm-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-keychain-google-sm/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-keychain-memory-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-keychain-memory/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-keychain-memory-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-keychain-memory-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-keychain-memory/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-keychain-memory-wasm-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-keychain-memory-wasm/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-keychain-memory-wasm-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-keychain-memory-wasm-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-keychain-memory-wasm/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-keychain-vault-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-keychain-vault/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-keychain-vault-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-keychain-vault-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-keychain-vault/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-ledger-connector-corda-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-ledger-connector-corda/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-ledger-connector-corda-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-ledger-connector-corda-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-ledger-connector-corda/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-ledger-connector-fabric-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-ledger-connector-fabric/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-ledger-connector-fabric-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-ledger-connector-fabric-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-ledger-connector-fabric/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-ledger-connector-sawtooth-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-ledger-connector-sawtooth/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-ledger-connector-sawtooth-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-ledger-connector-sawtooth-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-ledger-connector-sawtooth/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-ledger-connector-ubiquity-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-ledger-connector-ubiquity/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-ledger-connector-ubiquity-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-ledger-connector-ubiquity-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-ledger-connector-ubiquity/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-odap-hermes-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-odap-hermes/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-odap-hermes-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-odap-hermes-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-odap-hermes/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-persistence-ethereum-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-persistence-ethereum/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-persistence-ethereum-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-persistence-ethereum-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-persistence-ethereum/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

- name: build-cactus-plugin-persistence-fabric-java-client
run: |
WDIR=`pwd`
cd ${WDIR}/packages/cactus-plugin-persistence-fabric/src/main/java/generated/openapi/java-client
mvn clean package
- name: publish-cactus-plugin-persistence-fabric-java-client
uses: actions/[email protected]
with:
name: cactus-plugin-persistence-fabric-java-client-${{ env.GITVERSION }}.jar
path: packages/cactus-plugin-persistence-fabric/src/main/java/generated/openapi/java-client/target/openapi-java-client-1.jar

4 changes: 3 additions & 1 deletion extensions/cactus-plugin-htlc-coordinator-besu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
"codegen": "run-p 'codegen:*'",
"codegen:openapi": "run-p generate-sdk",
"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/ --ignore-file-override ../../openapi-generator-ignore",
"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/ --ignore-file-override=../../openapi-generator-ignore",
"generate-sdk:go": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g go -o ./src/main/go/generated/openapi/go-client/ --git-user-id hyperledger --git-repo-id $(echo $npm_package_name | replace @hyperledger/ \"\" -z)/src/main/go/generated/openapi/go-client --package-name $(echo $npm_package_name | replace @hyperledger/ \"\" -z) --ignore-file-override=../../openapi-generator-ignore",
"generate-sdk:java": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g java -o ./src/main/java/generated/openapi/java-client/ --reserved-words-mappings protected=protected --additional-properties hideGenerationTimestamp=true,artifactVersion=1 --ignore-file-override ../../openapi-generator-ignore",
"watch": "npm-watch",
"webpack": "npm-run-all webpack:dev webpack:prod",
"webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.travis.yml
README.md
api/openapi.yaml
api_default.go
client.go
configuration.go
go.mod
go.sum
model_counterparty_htlc_request.go
model_htlc_package.go
model_own_htlc_request.go
model_web3_signing_credential.go
model_web3_signing_credential_cactus_keychain_ref.go
model_web3_signing_credential_none.go
model_web3_signing_credential_private_key_hex.go
model_web3_signing_credential_type.go
model_withdraw_counterparty_request.go
response.go
test/api_default_test.go
utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.6.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: go

install:
- go get -d -v .

script:
- go build -v ./

Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Go API client for cactus-plugin-htlc-coordinator-besu

Can exchange assets between networks

## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.

- API version: v2.0.0-alpha.2
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen

## Installation

Install the following dependencies:

```shell
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
```

Put the package under your project folder and add the following in import:

```golang
import cactus-plugin-htlc-coordinator-besu "github.com/hyperledger/cactus-plugin-htlc-coordinator-besu/src/main/go/generated/openapi/go-client"
```

To use a proxy, set the environment variable `HTTP_PROXY`:

```golang
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
```

## Configuration of Server URL

Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.

### Select Server Configuration

For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.

```golang
ctx := context.WithValue(context.Background(), cactus-plugin-htlc-coordinator-besu.ContextServerIndex, 1)
```

### Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.

```golang
ctx := context.WithValue(context.Background(), cactus-plugin-htlc-coordinator-besu.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```

Note, enum values are always validated and all unused variables are silently ignored.

### URLs Configuration per Operation

Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.

```golang
ctx := context.WithValue(context.Background(), cactus-plugin-htlc-coordinator-besu.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), cactus-plugin-htlc-coordinator-besu.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
```

## Documentation for API Endpoints

All URIs are relative to *https://www.cactus.stream*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**CounterpartyHtlcV1**](docs/DefaultApi.md#counterpartyhtlcv1) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-htlc-coordinator-besu/counterparty-htlc | Create an instance to interact with the counterparty HTLC
*DefaultApi* | [**OwnHtlcV1**](docs/DefaultApi.md#ownhtlcv1) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-htlc-coordinator-besu/own-htlc | Create an instance to interact with the own HTLC.
*DefaultApi* | [**WithdrawCounterpartyV1**](docs/DefaultApi.md#withdrawcounterpartyv1) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-htlc-coordinator-besu/withdraw-counterparty | Withdraw funds of the counterparty HTLC


## Documentation For Models

- [CounterpartyHTLCRequest](docs/CounterpartyHTLCRequest.md)
- [HtlcPackage](docs/HtlcPackage.md)
- [OwnHTLCRequest](docs/OwnHTLCRequest.md)
- [Web3SigningCredential](docs/Web3SigningCredential.md)
- [Web3SigningCredentialCactusKeychainRef](docs/Web3SigningCredentialCactusKeychainRef.md)
- [Web3SigningCredentialNone](docs/Web3SigningCredentialNone.md)
- [Web3SigningCredentialPrivateKeyHex](docs/Web3SigningCredentialPrivateKeyHex.md)
- [Web3SigningCredentialType](docs/Web3SigningCredentialType.md)
- [WithdrawCounterpartyRequest](docs/WithdrawCounterpartyRequest.md)


## Documentation For Authorization

Endpoints do not require authorization.


## Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains
a number of utility functions to easily obtain pointers to values of basic types.
Each of these functions takes a value of the given basic type and returns a pointer to it:

* `PtrBool`
* `PtrInt`
* `PtrInt32`
* `PtrInt64`
* `PtrFloat`
* `PtrFloat32`
* `PtrFloat64`
* `PtrString`
* `PtrTime`

## Author



Loading

0 comments on commit f31112a

Please sign in to comment.