Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Siyu Wang <[email protected]>
  • Loading branch information
FillZpp committed Jul 2, 2019
1 parent b81837a commit edcdb53
Show file tree
Hide file tree
Showing 72 changed files with 11,503 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# build files
**/target
target
.gradle
build

.idea/
166 changes: 166 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# client-java

## Requirements

Building the API client library requires [Maven](https://maven.apache.org/) to be installed.

## Installation

To install the API client library to your local Maven repository, simply execute:

```shell
mvn install
```

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

```shell
mvn deploy
```

Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.

### Maven users

Add this dependency to your project's POM:

```xml
<dependency>
<groupId>io.openkruise</groupId>
<artifactId>client-java</artifactId>
<version>0.1.1</version>
<scope>compile</scope>
</dependency>
```

### Gradle users

Add this dependency to your project's build file:

```groovy
compile "io.openkruise:client-java:0.1.1"
```

### Others

At first generate the JAR by executing:

mvn package

Then manually install the following JARs:

* target/client-java-1.0-SNAPSHOT.jar
* target/lib/*.jar

## Getting Started

It is suggested that you should use ApiClient and CustomObjectsApi from `io.kubernetes:client-java` instead of `io.openkruise:client-java`.
The only thing you should import from `io.openkruise:client-java` is `io.openkruise.client.models.*`.

```java
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.apis.CustomObjectsApi;

import io.openkruise.client.models.*;

public class MyExample {

// generate this client from a kubeconfig file or something else
ApiClient apiClient;

public void createStatefulSet(String namespace, KruiseAppsV1alpha1StatefulSet statefulSet) throws ApiException {
CustomObjectsApi customObjectsApi = new CustomObjectsApi(apiClient);
customObjectsApi.createNamespacedCustomObject(
KruiseAppsV1alpha1StatefulSet.group,
KruiseAppsV1alpha1StatefulSet.version,
namespace,
KruiseAppsV1alpha1StatefulSet.plural,
statefulSet,
"true"
);
}

public KruiseAppsV1alpha1StatefulSet getStatefulSet(String namespace, String name) throws Exception {
CustomObjectsApi customObjectsApi = new CustomObjectsApi(apiClient);
Object obj = customObjectsApi.getNamespacedCustomObject(
KruiseAppsV1alpha1StatefulSet.group,
KruiseAppsV1alpha1StatefulSet.version,
namespace,
KruiseAppsV1alpha1StatefulSet.plural,
name
);
Gson gson = new JSON().getGson();
return gson.fromJson(gson.toJsonTree(obj).getAsJsonObject(), KruiseAppsV1alpha1StatefulSet.class);
}

public void patchStatefulSet(String namespace, String name, String patchBody) throws ApiException {
CustomObjectsApi customObjectsApi = new CustomObjectsApi(apiClient);
customObjectsApi.patchNamespacedCustomObject(
KruiseAppsV1alpha1StatefulSet.group,
KruiseAppsV1alpha1StatefulSet.version,
namespace,
KruiseAppsV1alpha1StatefulSet.plural,
name,
patchBody
);
}
}

```

## Documentation for API Endpoints

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

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*CustomObjectsApi* | [**createClusterCustomObject**](docs/CustomObjectsApi.md#createClusterCustomObject) | **POST** /apis/{group}/{version}/{plural} |
*CustomObjectsApi* | [**createNamespacedCustomObject**](docs/CustomObjectsApi.md#createNamespacedCustomObject) | **POST** /apis/{group}/{version}/namespaces/{namespace}/{plural} |
*CustomObjectsApi* | [**deleteClusterCustomObject**](docs/CustomObjectsApi.md#deleteClusterCustomObject) | **DELETE** /apis/{group}/{version}/{plural}/{name} |
*CustomObjectsApi* | [**deleteNamespacedCustomObject**](docs/CustomObjectsApi.md#deleteNamespacedCustomObject) | **DELETE** /apis/{group}/{version}/namespaces/{namespace}/{plural}/{name} |
*CustomObjectsApi* | [**getClusterCustomObject**](docs/CustomObjectsApi.md#getClusterCustomObject) | **GET** /apis/{group}/{version}/{plural}/{name} |
*CustomObjectsApi* | [**getNamespacedCustomObject**](docs/CustomObjectsApi.md#getNamespacedCustomObject) | **GET** /apis/{group}/{version}/namespaces/{namespace}/{plural}/{name} |
*CustomObjectsApi* | [**listClusterCustomObject**](docs/CustomObjectsApi.md#listClusterCustomObject) | **GET** /apis/{group}/{version}/{plural} |
*CustomObjectsApi* | [**listNamespacedCustomObject**](docs/CustomObjectsApi.md#listNamespacedCustomObject) | **GET** /apis/{group}/{version}/namespaces/{namespace}/{plural} |
*CustomObjectsApi* | [**patchClusterCustomObject**](docs/CustomObjectsApi.md#patchClusterCustomObject) | **PATCH** /apis/{group}/{version}/{plural}/{name} |
*CustomObjectsApi* | [**patchNamespacedCustomObject**](docs/CustomObjectsApi.md#patchNamespacedCustomObject) | **PATCH** /apis/{group}/{version}/namespaces/{namespace}/{plural}/{name} |
*CustomObjectsApi* | [**replaceClusterCustomObject**](docs/CustomObjectsApi.md#replaceClusterCustomObject) | **PUT** /apis/{group}/{version}/{plural}/{name} |
*CustomObjectsApi* | [**replaceNamespacedCustomObject**](docs/CustomObjectsApi.md#replaceNamespacedCustomObject) | **PUT** /apis/{group}/{version}/namespaces/{namespace}/{plural}/{name} |


## Documentation for Models

- [IoOpenkruiseAppsV1alpha1BroadcastJob](docs/IoOpenkruiseAppsV1alpha1BroadcastJob.md)
- [IoOpenkruiseAppsV1alpha1BroadcastJobList](docs/IoOpenkruiseAppsV1alpha1BroadcastJobList.md)
- [IoOpenkruiseAppsV1alpha1BroadcastJobSpec](docs/IoOpenkruiseAppsV1alpha1BroadcastJobSpec.md)
- [IoOpenkruiseAppsV1alpha1BroadcastJobStatus](docs/IoOpenkruiseAppsV1alpha1BroadcastJobStatus.md)
- [IoOpenkruiseAppsV1alpha1CompletionPolicy](docs/IoOpenkruiseAppsV1alpha1CompletionPolicy.md)
- [IoOpenkruiseAppsV1alpha1InPlaceUpdateContainerStatus](docs/IoOpenkruiseAppsV1alpha1InPlaceUpdateContainerStatus.md)
- [IoOpenkruiseAppsV1alpha1InPlaceUpdateState](docs/IoOpenkruiseAppsV1alpha1InPlaceUpdateState.md)
- [IoOpenkruiseAppsV1alpha1JobCondition](docs/IoOpenkruiseAppsV1alpha1JobCondition.md)
- [IoOpenkruiseAppsV1alpha1RollingUpdateStatefulSetStrategy](docs/IoOpenkruiseAppsV1alpha1RollingUpdateStatefulSetStrategy.md)
- [IoOpenkruiseAppsV1alpha1SidecarContainer](docs/IoOpenkruiseAppsV1alpha1SidecarContainer.md)
- [IoOpenkruiseAppsV1alpha1SidecarSet](docs/IoOpenkruiseAppsV1alpha1SidecarSet.md)
- [IoOpenkruiseAppsV1alpha1SidecarSetList](docs/IoOpenkruiseAppsV1alpha1SidecarSetList.md)
- [IoOpenkruiseAppsV1alpha1SidecarSetSpec](docs/IoOpenkruiseAppsV1alpha1SidecarSetSpec.md)
- [IoOpenkruiseAppsV1alpha1SidecarSetStatus](docs/IoOpenkruiseAppsV1alpha1SidecarSetStatus.md)
- [IoOpenkruiseAppsV1alpha1StatefulSet](docs/IoOpenkruiseAppsV1alpha1StatefulSet.md)
- [IoOpenkruiseAppsV1alpha1StatefulSetList](docs/IoOpenkruiseAppsV1alpha1StatefulSetList.md)
- [IoOpenkruiseAppsV1alpha1StatefulSetSpec](docs/IoOpenkruiseAppsV1alpha1StatefulSetSpec.md)
- [IoOpenkruiseAppsV1alpha1StatefulSetStatus](docs/IoOpenkruiseAppsV1alpha1StatefulSetStatus.md)
- [IoOpenkruiseAppsV1alpha1StatefulSetUpdateStrategy](docs/IoOpenkruiseAppsV1alpha1StatefulSetUpdateStrategy.md)


## Documentation for Authorization

All endpoints do not require authorization.
Authentication schemes defined for the API:

## Recommendation

It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.

## Author



103 changes: 103 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
apply plugin: 'idea'
apply plugin: 'eclipse'

group = 'io.openkruise'
version = '0.1.1'

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}

repositories {
jcenter()
}


if(hasProperty('target') && target == 'android') {

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}

dependencies {
provided 'javax.annotation:jsr250-api:1.0'
}
}

afterEvaluate {
android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
task.description = "Create jar artifact for ${variant.name}"
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task);
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

artifacts {
archives sourcesJar
}

} else {

apply plugin: 'java'
apply plugin: 'maven'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

install {
repositories.mavenInstaller {
pom.artifactId = 'client-java'
}
}

task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}

dependencies {
compile 'io.swagger:swagger-annotations:1.5.15'
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
compile 'com.google.code.gson:gson:2.8.1'
compile 'joda-time:joda-time:2.9.9'
testCompile 'junit:junit:4.12'
}
20 changes: 20 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
lazy val root = (project in file(".")).
settings(
organization := "io.openkruise",
name := "client-java",
version := "0.1.1",
scalaVersion := "2.11.4",
scalacOptions ++= Seq("-feature"),
javacOptions in compile ++= Seq("-Xlint:deprecation"),
publishArtifact in (Compile, packageDoc) := false,
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.5.15",
"com.squareup.okhttp" % "okhttp" % "2.7.5",
"com.squareup.okhttp" % "logging-interceptor" % "2.7.5",
"com.google.code.gson" % "gson" % "2.8.1",
"joda-time" % "joda-time" % "2.9.9" % "compile",
"junit" % "junit" % "4.12" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
)
)
46 changes: 46 additions & 0 deletions client-java.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: io.kubernetes:client-java:5.0.0" level="project" />
<orderEntry type="library" name="Maven: io.kubernetes:client-java-api:5.0.0" level="project" />
<orderEntry type="library" name="Maven: io.sundr:builder-annotations:0.18.0" level="project" />
<orderEntry type="library" name="Maven: io.sundr:sundr-core:0.18.0" level="project" />
<orderEntry type="library" name="Maven: io.sundr:sundr-codegen:0.18.0" level="project" />
<orderEntry type="library" name="Maven: io.sundr:resourcecify-annotations:0.18.0" level="project" />
<orderEntry type="library" name="Maven: org.joda:joda-convert:1.2" level="project" />
<orderEntry type="library" name="Maven: io.kubernetes:client-java-proto:5.0.0" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.18" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp:okhttp-ws:2.7.5" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:25.1-jre" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.0.0" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.1.3" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-ext-jdk15on:1.61" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.61" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.61" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.4.0" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.15" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp:okhttp:2.7.5" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.6.0" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp:logging-interceptor:2.7.5" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.1" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.9" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
Loading

0 comments on commit edcdb53

Please sign in to comment.