Skip to content

Commit

Permalink
Add Server Metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mmohamed committed Mar 14, 2020
1 parent 0ccc60a commit 8914cd6
Show file tree
Hide file tree
Showing 12 changed files with 554 additions and 16 deletions.
55 changes: 55 additions & 0 deletions src/main/java/dev/medinvention/core/api/ExtendedCoreV1Api.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package dev.medinvention.core.api;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;

import dev.medinvention.core.api.type.V1Beta1NodeMetricsList;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.ApiResponse;
import io.kubernetes.client.openapi.Pair;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import okhttp3.Call;

public class ExtendedCoreV1Api extends CoreV1Api {

public V1Beta1NodeMetricsList clusterMetrics() throws ApiException {
Object localVarPostBody = null;

// path
String localVarPath = "/apis/metrics.k8s.io/v1beta1/nodes";

List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

final String[] localVarAccepts = {};
final String localVarAccept = this.getApiClient().selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}

final String[] localVarContentTypes = { "application/json" };
final String localVarContentType = this.getApiClient().selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);

String[] localVarAuthNames = new String[] { "BearerToken" };

Call call = this.getApiClient().buildCall(localVarPath, "GET", localVarQueryParams,
localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams,
localVarFormParams, localVarAuthNames, null);

Type localVarReturnType = new TypeToken<V1Beta1NodeMetricsList>() {
}.getType();

ApiResponse<V1Beta1NodeMetricsList> response = this.getApiClient().execute(call, localVarReturnType);

return response.getData();
}
}
122 changes: 122 additions & 0 deletions src/main/java/dev/medinvention/core/api/type/V1Beta1NodeMetrics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package dev.medinvention.core.api.type;

import java.util.Objects;

import org.joda.time.DateTime;

import com.google.gson.annotations.SerializedName;

import io.kubernetes.client.openapi.models.V1ObjectMeta;

public class V1Beta1NodeMetrics {

public static final String SERIALIZED_NAME_WINDOW = "window";
@SerializedName(SERIALIZED_NAME_WINDOW)
private String window;

public static final String SERIALIZED_NAME_METADATA = "metadata";
@SerializedName(SERIALIZED_NAME_METADATA)
private V1ObjectMeta metadata;

public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp";
@SerializedName(SERIALIZED_NAME_TIMESTAMP)
private DateTime timestamp;

public static final String SERIALIZED_NAME_USAGE = "usage";
@SerializedName(SERIALIZED_NAME_USAGE)
private V1Beta1NodeMetricsUsage usage;

public V1Beta1NodeMetricsUsage getUsage() {
return usage;
}

public void setUsage(V1Beta1NodeMetricsUsage usage) {
this.usage = usage;
}

public V1Beta1NodeMetrics usage(V1Beta1NodeMetricsUsage usage) {
this.usage = usage;
return this;
}

public V1Beta1NodeMetrics timestamp(DateTime timestamp) {
this.timestamp = timestamp;
return this;
}

public DateTime getTimestamp() {
return timestamp;
}

public void setTimestamp(DateTime timestamp) {
this.timestamp = timestamp;
}

public V1Beta1NodeMetrics window(String window) {
this.window = window;
return this;
}

public String getWindow() {
return window;
}

public void setWindow(String window) {
this.window = window;
}

public V1Beta1NodeMetrics metadata(V1ObjectMeta metadata) {
this.metadata = metadata;
return this;
}

@javax.annotation.Nullable
public V1ObjectMeta getMetadata() {
return metadata;
}

public void setMetadata(V1ObjectMeta metadata) {
this.metadata = metadata;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

V1Beta1NodeMetrics v1Beta1NodeMetrics = (V1Beta1NodeMetrics) o;

return Objects.equals(this.window, v1Beta1NodeMetrics.window)
&& Objects.equals(this.timestamp, v1Beta1NodeMetrics.timestamp)
&& Objects.equals(this.usage, v1Beta1NodeMetrics.usage)
&& Objects.equals(this.metadata, v1Beta1NodeMetrics.metadata);
}

@Override
public int hashCode() {
return Objects.hash(window, timestamp, usage, metadata);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class V1Beta1NodeMetrics {\n");
sb.append(" window: ").append(toIndentedString(window)).append("\n");
sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n");
sb.append(" usage: ").append(toIndentedString(usage)).append("\n");
sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
sb.append("}");
return sb.toString();
}

private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package dev.medinvention.core.api.type;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.google.gson.annotations.SerializedName;

import io.kubernetes.client.openapi.models.V1ListMeta;

public class V1Beta1NodeMetricsList {

public static final String SERIALIZED_NAME_API_VERSION = "apiVersion";
@SerializedName(SERIALIZED_NAME_API_VERSION)
private String apiVersion;

public static final String SERIALIZED_NAME_ITEMS = "items";
@SerializedName(SERIALIZED_NAME_ITEMS)
private List<V1Beta1NodeMetrics> items = new ArrayList<V1Beta1NodeMetrics>();

public static final String SERIALIZED_NAME_KIND = "kind";
@SerializedName(SERIALIZED_NAME_KIND)
private String kind;

public static final String SERIALIZED_NAME_METADATA = "metadata";
@SerializedName(SERIALIZED_NAME_METADATA)
private V1ListMeta metadata;

public V1Beta1NodeMetricsList apiVersion(String apiVersion) {
this.apiVersion = apiVersion;
return this;
}

@javax.annotation.Nullable
public String getApiVersion() {
return apiVersion;
}

public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}

public V1Beta1NodeMetricsList items(List<V1Beta1NodeMetrics> items) {
this.items = items;
return this;
}

public V1Beta1NodeMetricsList addItemsItem(V1Beta1NodeMetrics itemsItem) {
this.items.add(itemsItem);
return this;
}

public List<V1Beta1NodeMetrics> getItems() {
return items;
}

public void setItems(List<V1Beta1NodeMetrics> items) {
this.items = items;
}

public V1Beta1NodeMetricsList kind(String kind) {
this.kind = kind;
return this;
}

@javax.annotation.Nullable
public String getKind() {
return kind;
}

public void setKind(String kind) {
this.kind = kind;
}

public V1Beta1NodeMetricsList metadata(V1ListMeta metadata) {
this.metadata = metadata;
return this;
}

@javax.annotation.Nullable
public V1ListMeta getMetadata() {
return metadata;
}

public void setMetadata(V1ListMeta metadata) {
this.metadata = metadata;
}

@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

V1Beta1NodeMetricsList v1Beta1NodeMetricsList = (V1Beta1NodeMetricsList) o;

return Objects.equals(this.apiVersion, v1Beta1NodeMetricsList.apiVersion)
&& Objects.equals(this.items, v1Beta1NodeMetricsList.items)
&& Objects.equals(this.kind, v1Beta1NodeMetricsList.kind)
&& Objects.equals(this.metadata, v1Beta1NodeMetricsList.metadata);
}

@Override
public int hashCode() {
return Objects.hash(apiVersion, items, kind, metadata);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class V1Beta1NodeMetricsList {\n");
sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n");
sb.append(" items: ").append(toIndentedString(items)).append("\n");
sb.append(" kind: ").append(toIndentedString(kind)).append("\n");
sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
sb.append("}");
return sb.toString();
}

private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package dev.medinvention.core.api.type;

import java.util.Objects;

import com.google.gson.annotations.SerializedName;

import io.kubernetes.client.custom.Quantity;

public class V1Beta1NodeMetricsUsage {

public static final String SERIALIZED_NAME_CPU = "cpu";
@SerializedName(SERIALIZED_NAME_CPU)
private Quantity cpu;

public static final String SERIALIZED_NAME_MEMORY = "memory";
@SerializedName(SERIALIZED_NAME_MEMORY)
private Quantity memory;

public V1Beta1NodeMetricsUsage cpu(Quantity cpu) {
this.cpu = cpu;
return this;
}

public Quantity getCpu() {
return cpu;
}

public void setCpu(Quantity cpu) {
this.cpu = cpu;
}

public V1Beta1NodeMetricsUsage memory(Quantity memory) {
this.memory = memory;
return this;
}

public Quantity getMemory() {
return memory;
}

public void setMemory(Quantity memory) {
this.memory = memory;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

V1Beta1NodeMetricsUsage v1Beta1NodeMetricsUsage = (V1Beta1NodeMetricsUsage) o;

return Objects.equals(this.cpu, v1Beta1NodeMetricsUsage.cpu)
&& Objects.equals(this.memory, v1Beta1NodeMetricsUsage.memory);
}

@Override
public int hashCode() {
return Objects.hash(cpu, memory);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class V1Beta1NodeMetricsUsage {\n");
sb.append(" cpu: ").append(toIndentedString(cpu)).append("\n");
sb.append(" memory: ").append(toIndentedString(memory)).append("\n");
sb.append("}");
return sb.toString();
}

private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
Loading

0 comments on commit 8914cd6

Please sign in to comment.