Skip to content

Commit

Permalink
feat: Bring Java client into core. (argoproj#7026)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
alexec committed Oct 25, 2021
1 parent 65ff89a commit 56ee941
Show file tree
Hide file tree
Showing 409 changed files with 12,115 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ jobs:
with:
title: 'docs: updated CHANGELOG.md'
commit-message: 'docs: updated CHANGELOG.md'
branch: create-pull-request/changelog
signoff: true
29 changes: 29 additions & 0 deletions .github/workflows/sdks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: SDKs
on:
push:
tags:
- v*
- 'v3.2.*'
- 'v3.1.*'
branches:
- dev-*
jobs:
sdk:
if: github.repository == 'argoproj/argo-workflows'
runs-on: ubuntu-latest
name: Publish SDK
strategy:
matrix:
name:
- java
steps:
- uses: actions/checkout@v2
- run: make --directory sdks/${{matrix.name}} publish -B
env:
JAVA_SDK_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- uses: peter-evans/create-pull-request@v3
with:
title: 'chore: updated ${{matrix.name}} SDK'
commit-message: 'chore: updated ${{matrix.name}} SDK'
branch: create-pull-request/sdk/${{matrix.name}}
signoff: true
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ scan-%:

.PHONY: codegen
codegen: types swagger docs manifests
make --directory sdks/java generate

.PHONY: types
types: pkg/apis/workflow/v1alpha1/generated.proto pkg/apis/workflow/v1alpha1/openapi_generated.go pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ Argo is a [Cloud Native Computing Foundation (CNCF)](https://cncf.io/) hosted pr
[SQLFlow](https://github.com/sql-machine-learning/sqlflow)


## SDKs
## Client Libraries

Check out our [Java, Golang and Python SDKs](https://github.com/argoproj-labs/argo-client-gen).
Check out our [Java, Golang and Python clients](docs/client-libraries.md).

## Quickstart

Expand Down
27 changes: 27 additions & 0 deletions docs/client-libraries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Client Libraries

This page contains an overview of the client libraries for using the Argo API from various programming languages.

To write applications using the REST API, you do not need to implement the API calls and request/response types
yourself. You can use a client library for the programming language you are using.

Client libraries often handle common tasks such as authentication for you.

## Officially-supported client libraries

The following client libraries are officially maintained by the Argo team.

| Language | Client Library | Examples/Docs |
|----------|----------------|---------------|
| Golang | [apiclient.go](https://github.com/argoproj/argo-workflows/blob/master/pkg/apiclient/apiclient.go) | [Example](https://github.com/argoproj/argo-workflows/blob/master/cmd/argo/commands/submit.go)
| Java | [java](https://github.com/argoproj/argo-workflows/blob/master/sdks/java) | |
| Python | [python](python) | TBC |

## Community-maintained client libraries

The following client libraries are provided and maintained by their authors, not the Argo team.

| Language | Client Library | Info |
|----------|----------------|---------------|
| Python | [Couler](https://github.com/couler-proj/couler) | Multi-workflow engine support Python SDK |
| Python | Hera | TBC |
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ nav:
- swagger.md
- rest-api.md
- rest-examples.md
- client-libraries.md
- events.md
- webhooks.md
- submit-workflow-via-automation.md
Expand Down
16 changes: 16 additions & 0 deletions sdks/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Contributing an SDK

Make it contributor friendly:

* Make it fast, because engineers will have to generate SDKs for every PR.
* Make it dependency free, engineers will not be a be able to install anything. You can use Docker.
* Generate the minimal amount of code possible, so other engineers don't have to commit lots of files too.
* Provide a [`Makefile`](java/Makefile) with the following:
* A `generate` target to generate the code using `openapi-generator` into `client` directory.
* A `publish` target to publish the generated code for use.
* Committed code must be stable, it must not change based on Git tags.

Make it user friendly:

* Commit enough for users to learn how to use it. Use `.gitignore` to exclude files.
* Add a [README.md](java/README.md) to help users get started.
8 changes: 8 additions & 0 deletions sdks/java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/client/.openapi-generator/
/client/api/
/client/src/
/client/gradle/
/client/.gitignore
/client/.openapi-generator-ignore
/client/gradlew
/client/*.*
72 changes: 72 additions & 0 deletions sdks/java/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
GIT_TAG := $(shell git describe --exact-match --tags --abbrev=0 2> /dev/null || echo untagged)
ifeq ($(GIT_TAG),untagged)
# "SNAPSHOT" is "latest" for Java
VERSION := 0.0.0-SNAPSHOT
else
# remove the "v" prefix, not allowed
VERSION := $(GIT_TAG:v=)
endif

# work dir
WD := $(shell echo "`pwd`/client")

DOCKER = docker run --rm -v $(WD):/wd --workdir /wd
MVN = $(DOCKER) -v $(HOME)/.m2:/root/.m2 -e JAVA_SDK_MAVEN_PASSWORD=${JAVA_SDK_MAVEN_PASSWORD} maven:3-openjdk-8 mvn -s settings.xml
CHOWN = chown -R $(shell id -u):$(shell id -g)

publish: generate
# https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-apache-maven-for-use-with-github-packages
$(MVN) deploy -DskipTests -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/argoproj/argo-workflows

generate:
rm -Rf $(WD)
mkdir -p $(WD)
cp settings.xml $(WD)/settings.xml
cat ../../api/openapi-spec/swagger.json | \
sed 's/io.k8s.api.core.v1.//' | \
sed 's/io.k8s.apimachinery.pkg.apis.meta.v1.//' \
> $(WD)/swagger.json
$(DOCKER) openapitools/openapi-generator-cli:v5.2.1 \
generate \
-i /wd/swagger.json \
-g java \
-o /wd \
-p hideGenerationTimestamp=true \
-p dateLibrary=java8 \
--api-package io.argoproj.workflow.apis \
--invoker-package io.argoproj.workflow \
--model-package io.argoproj.workflow.models \
--skip-validate-spec \
--group-id io.argoproj.workflow \
--artifact-id argo-client-java \
--import-mappings Time=java.time.Instant \
--import-mappings Affinity=io.kubernetes.client.openapi.models.V1Affinity \
--import-mappings ConfigMapKeySelector=io.kubernetes.client.openapi.models.V1ConfigMapKeySelector \
--import-mappings Container=io.kubernetes.client.openapi.models.V1Container \
--import-mappings ContainerPort=io.kubernetes.client.openapi.models.V1ContainerPort \
--import-mappings EnvFromSource=io.kubernetes.client.openapi.models.V1EnvFromSource \
--import-mappings EnvVar=io.kubernetes.client.openapi.models.V1EnvVar \
--import-mappings HostAlias=io.kubernetes.client.openapi.models.V1HostAlias \
--import-mappings Lifecycle=io.kubernetes.client.openapi.models.V1Lifecycle \
--import-mappings ListMeta=io.kubernetes.client.openapi.models.V1ListMeta \
--import-mappings LocalObjectReference=io.kubernetes.client.openapi.models.V1LocalObjectReference \
--import-mappings ObjectMeta=io.kubernetes.client.openapi.models.V1ObjectMeta \
--import-mappings ObjectReference=io.kubernetes.client.openapi.models.V1ObjectReference \
--import-mappings PersistentVolumeClaim=io.kubernetes.client.openapi.models.V1PersistentVolumeClaim \
--import-mappings PodDisruptionBudgetSpec=io.kubernetes.client.openapi.models.V1beta1PodDisruptionBudgetSpec \
--import-mappings PodDNSConfig=io.kubernetes.client.openapi.models.V1PodDNSConfig \
--import-mappings PodSecurityContext=io.kubernetes.client.openapi.models.V1PodSecurityContext \
--import-mappings Probe=io.kubernetes.client.openapi.models.V1Probe \
--import-mappings ResourceRequirements=io.kubernetes.client.openapi.models.V1ResourceRequirements \
--import-mappings SecretKeySelector=io.kubernetes.client.openapi.models.V1SecretKeySelector \
--import-mappings SecurityContext=io.kubernetes.client.openapi.models.V1SecurityContext \
--import-mappings Toleration=io.kubernetes.client.openapi.models.V1Toleration \
--import-mappings Volume=io.kubernetes.client.openapi.models.V1Volume \
--import-mappings VolumeDevice=io.kubernetes.client.openapi.models.V1VolumeDevice \
--import-mappings VolumeMount=io.kubernetes.client.openapi.models.V1VolumeMount \
--generate-alias-as-model
# https://vsupalov.com/docker-shared-permissions/#set-the-docker-user-when-running-your-container
$(CHOWN) $(WD) || sudo $(CHOWN) $(WD)
# replace the generated pom.xml, because that has too many dependencies
sed 's/0.0.0-VERSION/$(VERSION)/' pom.xml > $(WD)/pom.xml

45 changes: 45 additions & 0 deletions sdks/java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Java SDK

## Download

## Client Library

This provides model and APIs for accessing the Argo Server API rather.

If you wish to access the Kubernetes APIs, you can use the models to do this. You'll need to write your own code to speak to the API.

⚠️ The Java SDK is published to Github packages, not Maven Central. You must update your Maven settings.xml
file: [how to do that](https://github.com/argoproj/argo-workflows/packages).

Recommended:

```xml
<dependency>
<groupId>io.argoproj.workflow</groupId>
<artifactId>argo-client-java</artifactId>
<version>3.3.0</version>
</dependency>
```

The very latest version:

```xml
<dependency>
<groupId>io.argoproj.workflow</groupId>
<artifactId>argo-client-java</artifactId>
<version>0.0.0-SNAPSHOT</version>
</dependency>
```

## Examples

* [Example.java](examples/client)

## Docs

* [Event service](client/docs/EventServiceApi.md)
* [Sensor service](client/docs/SensorServiceApi.md)
* [Event source service](client/docs/EventSourceServiceApi.md)
* [Info service](client/docs/InfoServiceApi.md )
* [Pipeline service](client/docs/PipelineServiceApi.md)
* [Workflow service](client/docs/WorkflowServiceApi.md)
17 changes: 17 additions & 0 deletions sdks/java/client/docs/AWSElasticBlockStoreVolumeSource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@


# AWSElasticBlockStoreVolumeSource

Represents a Persistent Disk resource in AWS. An AWS EBS disk must exist before mounting to a container. The disk must also be in the same AWS zone as the kubelet. An AWS EBS disk can only be mounted as read/write once. AWS EBS volumes support ownership management and SELinux relabeling.

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**fsType** | **String** | Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \&quot;ext4\&quot;, \&quot;xfs\&quot;, \&quot;ntfs\&quot;. Implicitly inferred to be \&quot;ext4\&quot; if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore | [optional]
**partition** | **Integer** | The partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \&quot;1\&quot;. Similarly, the volume partition for /dev/sda is \&quot;0\&quot; (or you can leave the property empty). | [optional]
**readOnly** | **Boolean** | Specify \&quot;true\&quot; to force and set the ReadOnly property in VolumeMounts to \&quot;true\&quot;. If omitted, the default is \&quot;false\&quot;. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore | [optional]
**volumeID** | **String** | Unique ID of the persistent disk resource in AWS (Amazon EBS volume). More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore |



Loading

0 comments on commit 56ee941

Please sign in to comment.