Skip to content

Commit

Permalink
Merge pull request #406 from hashmapinc/tempus-395-kubeless-client
Browse files Browse the repository at this point in the history
Tempus 395 kubeless client
  • Loading branch information
cherrera2001 authored Jun 6, 2018
2 parents 7f9a499 + e196344 commit a6443b8
Show file tree
Hide file tree
Showing 25 changed files with 1,658 additions and 2 deletions.
46 changes: 46 additions & 0 deletions clients/kubeless-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
Copyright © 2017-2018 Hashmap, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>clients</artifactId>
<groupId>com.hashmapinc</groupId>
<version>1.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.hashmapinc.clients</groupId>
<artifactId>kubeless-client</artifactId>
<packaging>jar</packaging>

<name>Tempus Server Kubeless client</name>
<url>https://hashmapinc.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.dir>${basedir}/../..</main.dir>
</properties>

<dependencies>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Copyright © 2017-2018 Hashmap, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hashmapinc.kubeless.apis;

import com.google.common.collect.ImmutableMap;
import com.hashmapinc.kubeless.models.triggers.V1beta1CronJobTrigger;
import com.squareup.okhttp.Call;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;

import java.util.Map;

public class KubelessV1beta1CronTriggerApi {

private ApiClient apiClient;
private final String kubelessCronTriggerUri;
private final Map<String, String> headers;
private String[] authNames = new String[] { "BearerToken" };

public KubelessV1beta1CronTriggerApi(ApiClient client, String namespace){
this.apiClient = client;
this.kubelessCronTriggerUri = "/apis/kubeless.io/v1beta1/namespaces/"+ namespace +"/crontriggers/";
this.headers = ImmutableMap.of("Accept", "application/json", "Content-type", "application/json");
}

public KubelessV1beta1CronTriggerApi(String namespace){
this(Configuration.getDefaultApiClient(), namespace);
}

public ApiClient getApiClient() {
return apiClient;
}

public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}

public Call listCronTriggerCall() throws ApiException {
return apiClient.buildCall(kubelessCronTriggerUri, "GET", null, null, null,
headers, null, authNames, null);
}

public Call getCronTriggerCall(String triggerName) throws ApiException {
return apiClient.buildCall(kubelessCronTriggerUri + triggerName, "GET", null, null, null,
headers, null, authNames, null);
}

public Call createCronTriggerCall(V1beta1CronJobTrigger trigger) throws ApiException {
return apiClient.buildCall(kubelessCronTriggerUri, "POST", null, null, trigger,
headers, null, authNames, null);
}

public Call patchCronTriggerCall(V1beta1CronJobTrigger trigger) throws ApiException {
String name = trigger.getMetadata().getName();
return apiClient.buildCall(kubelessCronTriggerUri + name, "PUT", null, null, trigger,
headers, null, authNames, null);
}

public Call deleteCronTriggerCall(String triggerName) throws ApiException {
return apiClient.buildCall(kubelessCronTriggerUri + triggerName, "DELETE", null, null, null,
headers, null, authNames, null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Copyright © 2017-2018 Hashmap, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hashmapinc.kubeless.apis;

import com.google.common.collect.ImmutableMap;
import com.hashmapinc.kubeless.models.V1beta1Function;
import com.squareup.okhttp.Call;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;

import java.util.Map;

public class KubelessV1beta1FunctionApi {
private ApiClient apiClient;
private final String kubelessFunctionsUri;
private final String namespace;
private final Map<String, String> headers;
private String[] authNames = new String[] { "BearerToken" };

public KubelessV1beta1FunctionApi(ApiClient client, String namespace){
this.apiClient = client;
this.namespace = namespace;
this.kubelessFunctionsUri = "/apis/kubeless.io/v1beta1/namespaces/"+ namespace +"/functions/";
this.headers = ImmutableMap.of("Accept", "application/json", "Content-type", "application/json");
}

public KubelessV1beta1FunctionApi(String namespace){
this(Configuration.getDefaultApiClient(), namespace);
}

public ApiClient getApiClient() {
return apiClient;
}

public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}

public Call listFunctionsCall() throws ApiException {
return apiClient.buildCall(kubelessFunctionsUri, "GET", null, null, null,
headers, null, authNames, null);
}

public Call getFunctionCall(String functionName) throws ApiException {
return apiClient.buildCall(kubelessFunctionsUri + functionName, "GET", null, null, null,
headers, null, authNames, null);
}

public Call createFunctionCall(V1beta1Function function) throws ApiException {
String namespace = function.getMetadata().getNamespace();
if(!this.namespace.equals(namespace)){
function.getMetadata().namespace(this.namespace);
}
return apiClient.buildCall(kubelessFunctionsUri, "POST", null, null, function,
headers, null, authNames, null);
}

public Call patchFunctionCall(V1beta1Function function) throws ApiException {
String name = function.getMetadata().getName();
return apiClient.buildCall(kubelessFunctionsUri + name, "PUT", null, null, function,
headers, null, authNames, null);
}

public Call deleteFunctionCall(String functionName) throws ApiException {
return apiClient.buildCall(kubelessFunctionsUri + functionName, "DELETE", null, null, null,
headers, null, authNames, null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Copyright © 2017-2018 Hashmap, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hashmapinc.kubeless.apis;

import com.google.common.collect.ImmutableMap;
import com.hashmapinc.kubeless.models.triggers.V1beta1HttpTrigger;
import com.squareup.okhttp.Call;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;

import java.util.Map;

public class KubelessV1beta1HTTPTriggerApi {

private ApiClient apiClient;
private final String kubelessHTTPTriggerUri;
private final Map<String, String> headers;
private String[] authNames = new String[] { "BearerToken" };

public KubelessV1beta1HTTPTriggerApi(ApiClient client, String namespace){
this.apiClient = client;
this.kubelessHTTPTriggerUri = "/apis/kubeless.io/v1beta1/namespaces/"+ namespace +"/httptriggers/";
this.headers = ImmutableMap.of("Accept", "application/json", "Content-type", "application/json");
}

public KubelessV1beta1HTTPTriggerApi(String namespace){
this(Configuration.getDefaultApiClient(), namespace);
}

public ApiClient getApiClient() {
return apiClient;
}

public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}

public Call listHTTPTriggerCall() throws ApiException {
return apiClient.buildCall(kubelessHTTPTriggerUri, "GET", null, null, null,
headers, null, authNames, null);
}

public Call getHTTPTriggerCall(String triggerName) throws ApiException {
return apiClient.buildCall(kubelessHTTPTriggerUri + triggerName, "GET", null, null, null,
headers, null, authNames, null);
}

public Call createHTTPTriggerCall(V1beta1HttpTrigger trigger) throws ApiException {
return apiClient.buildCall(kubelessHTTPTriggerUri, "POST", null, null, trigger,
headers, null, authNames, null);
}

public Call patchHTTPTriggerCall(V1beta1HttpTrigger trigger) throws ApiException {
String name = trigger.getMetadata().getName();
return apiClient.buildCall(kubelessHTTPTriggerUri + name, "PUT", null, null, trigger,
headers, null, authNames, null);
}

public Call deleteHTTPTriggerCall(String triggerName) throws ApiException {
return apiClient.buildCall(kubelessHTTPTriggerUri + triggerName, "DELETE", null, null, null,
headers, null, authNames, null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Copyright © 2017-2018 Hashmap, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hashmapinc.kubeless.apis;

import com.google.common.collect.ImmutableMap;
import com.hashmapinc.kubeless.models.triggers.V1beta1KafkaTrigger;
import com.squareup.okhttp.Call;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;

import java.util.Map;

public class KubelessV1beta1KafkaTriggerApi {

private ApiClient apiClient;
private final String kubelessKafkaTriggerUri;
private final Map<String, String> headers;
private String[] authNames = new String[] { "BearerToken" };

public KubelessV1beta1KafkaTriggerApi(ApiClient client, String namespace){
this.apiClient = client;
this.kubelessKafkaTriggerUri = "/apis/kubeless.io/v1beta1/namespaces/"+ namespace +"/kafkatriggers/";
this.headers = ImmutableMap.of("Accept", "application/json", "Content-type", "application/json");
}

public KubelessV1beta1KafkaTriggerApi(String namespace){
this(Configuration.getDefaultApiClient(), namespace);
}

public ApiClient getApiClient() {
return apiClient;
}

public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}

public Call listKafkaTriggerCall() throws ApiException {
return apiClient.buildCall(kubelessKafkaTriggerUri, "GET", null, null, null,
headers, null, authNames, null);
}

public Call getKafkaTriggerCall(String triggerName) throws ApiException {
return apiClient.buildCall(kubelessKafkaTriggerUri + triggerName, "GET", null, null, null,
headers, null, authNames, null);
}

public Call createKafkaTriggerCall(V1beta1KafkaTrigger trigger) throws ApiException {
return apiClient.buildCall(kubelessKafkaTriggerUri, "POST", null, null, trigger,
headers, null, authNames, null);
}

public Call patchKafkaTriggerCall(V1beta1KafkaTrigger trigger) throws ApiException {
String name = trigger.getMetadata().getName();
return apiClient.buildCall(kubelessKafkaTriggerUri + name, "PUT", null, null, trigger,
headers, null, authNames, null);
}

public Call deleteKafkaTriggerCall(String triggerName) throws ApiException {
return apiClient.buildCall(kubelessKafkaTriggerUri + triggerName, "DELETE", null, null, null,
headers, null, authNames, null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright © 2017-2018 Hashmap, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hashmapinc.kubeless.models;

public interface Spec {
}
Loading

0 comments on commit a6443b8

Please sign in to comment.