io.dataspray.stream.control.client.model.DeployRequest Maven / Gradle / Ivy
The newest version!
/*
* DataSpray API
* DataSpray API documentation for controlling and development.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.dataspray.stream.control.client.model;
import java.util.Objects;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.dataspray.stream.control.client.model.DeployRequestDynamoState;
import io.dataspray.stream.control.client.model.DeployRequestEndpoint;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import io.dataspray.stream.control.client.JSON;
/**
* DeployRequest
*/
public class DeployRequest {
public static final String SERIALIZED_NAME_CODE_URL = "codeUrl";
@SerializedName(SERIALIZED_NAME_CODE_URL)
private String codeUrl;
public static final String SERIALIZED_NAME_HANDLER = "handler";
@SerializedName(SERIALIZED_NAME_HANDLER)
private String handler;
public static final String SERIALIZED_NAME_INPUT_QUEUE_NAMES = "inputQueueNames";
@SerializedName(SERIALIZED_NAME_INPUT_QUEUE_NAMES)
private List inputQueueNames = new ArrayList<>();
public static final String SERIALIZED_NAME_OUTPUT_QUEUE_NAMES = "outputQueueNames";
@SerializedName(SERIALIZED_NAME_OUTPUT_QUEUE_NAMES)
private List outputQueueNames = new ArrayList<>();
/**
* Gets or Sets runtime
*/
@JsonAdapter(RuntimeEnum.Adapter.class)
public enum RuntimeEnum {
JAVA21("JAVA21"),
NODEJS20_X("NODEJS20_X");
private String value;
RuntimeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static RuntimeEnum fromValue(String value) {
for (RuntimeEnum b : RuntimeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final RuntimeEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public RuntimeEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return RuntimeEnum.fromValue(value);
}
}
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
String value = jsonElement.getAsString();
RuntimeEnum.fromValue(value);
}
}
public static final String SERIALIZED_NAME_RUNTIME = "runtime";
@SerializedName(SERIALIZED_NAME_RUNTIME)
private RuntimeEnum runtime;
public static final String SERIALIZED_NAME_ENDPOINT = "endpoint";
@SerializedName(SERIALIZED_NAME_ENDPOINT)
private DeployRequestEndpoint endpoint;
public static final String SERIALIZED_NAME_DYNAMO_STATE = "dynamoState";
@SerializedName(SERIALIZED_NAME_DYNAMO_STATE)
private DeployRequestDynamoState dynamoState;
public static final String SERIALIZED_NAME_SWITCH_TO_NOW = "switchToNow";
@SerializedName(SERIALIZED_NAME_SWITCH_TO_NOW)
private Boolean switchToNow;
public DeployRequest() {
}
public DeployRequest codeUrl(String codeUrl) {
this.codeUrl = codeUrl;
return this;
}
/**
* Get codeUrl
* @return codeUrl
**/
@jakarta.annotation.Nonnull
public String getCodeUrl() {
return codeUrl;
}
public void setCodeUrl(String codeUrl) {
this.codeUrl = codeUrl;
}
public DeployRequest handler(String handler) {
this.handler = handler;
return this;
}
/**
* Get handler
* @return handler
**/
@jakarta.annotation.Nonnull
public String getHandler() {
return handler;
}
public void setHandler(String handler) {
this.handler = handler;
}
public DeployRequest inputQueueNames(List inputQueueNames) {
this.inputQueueNames = inputQueueNames;
return this;
}
public DeployRequest addInputQueueNamesItem(String inputQueueNamesItem) {
if (this.inputQueueNames == null) {
this.inputQueueNames = new ArrayList<>();
}
this.inputQueueNames.add(inputQueueNamesItem);
return this;
}
/**
* Get inputQueueNames
* @return inputQueueNames
**/
@jakarta.annotation.Nonnull
public List getInputQueueNames() {
return inputQueueNames;
}
public void setInputQueueNames(List inputQueueNames) {
this.inputQueueNames = inputQueueNames;
}
public DeployRequest outputQueueNames(List outputQueueNames) {
this.outputQueueNames = outputQueueNames;
return this;
}
public DeployRequest addOutputQueueNamesItem(String outputQueueNamesItem) {
if (this.outputQueueNames == null) {
this.outputQueueNames = new ArrayList<>();
}
this.outputQueueNames.add(outputQueueNamesItem);
return this;
}
/**
* Get outputQueueNames
* @return outputQueueNames
**/
@jakarta.annotation.Nonnull
public List getOutputQueueNames() {
return outputQueueNames;
}
public void setOutputQueueNames(List outputQueueNames) {
this.outputQueueNames = outputQueueNames;
}
public DeployRequest runtime(RuntimeEnum runtime) {
this.runtime = runtime;
return this;
}
/**
* Get runtime
* @return runtime
**/
@jakarta.annotation.Nullable
public RuntimeEnum getRuntime() {
return runtime;
}
public void setRuntime(RuntimeEnum runtime) {
this.runtime = runtime;
}
public DeployRequest endpoint(DeployRequestEndpoint endpoint) {
this.endpoint = endpoint;
return this;
}
/**
* Get endpoint
* @return endpoint
**/
@jakarta.annotation.Nullable
public DeployRequestEndpoint getEndpoint() {
return endpoint;
}
public void setEndpoint(DeployRequestEndpoint endpoint) {
this.endpoint = endpoint;
}
public DeployRequest dynamoState(DeployRequestDynamoState dynamoState) {
this.dynamoState = dynamoState;
return this;
}
/**
* Get dynamoState
* @return dynamoState
**/
@jakarta.annotation.Nullable
public DeployRequestDynamoState getDynamoState() {
return dynamoState;
}
public void setDynamoState(DeployRequestDynamoState dynamoState) {
this.dynamoState = dynamoState;
}
public DeployRequest switchToNow(Boolean switchToNow) {
this.switchToNow = switchToNow;
return this;
}
/**
* Get switchToNow
* @return switchToNow
**/
@jakarta.annotation.Nonnull
public Boolean getSwitchToNow() {
return switchToNow;
}
public void setSwitchToNow(Boolean switchToNow) {
this.switchToNow = switchToNow;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DeployRequest deployRequest = (DeployRequest) o;
return Objects.equals(this.codeUrl, deployRequest.codeUrl) &&
Objects.equals(this.handler, deployRequest.handler) &&
Objects.equals(this.inputQueueNames, deployRequest.inputQueueNames) &&
Objects.equals(this.outputQueueNames, deployRequest.outputQueueNames) &&
Objects.equals(this.runtime, deployRequest.runtime) &&
Objects.equals(this.endpoint, deployRequest.endpoint) &&
Objects.equals(this.dynamoState, deployRequest.dynamoState) &&
Objects.equals(this.switchToNow, deployRequest.switchToNow);
}
@Override
public int hashCode() {
return Objects.hash(codeUrl, handler, inputQueueNames, outputQueueNames, runtime, endpoint, dynamoState, switchToNow);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DeployRequest {\n");
sb.append(" codeUrl: ").append(toIndentedString(codeUrl)).append("\n");
sb.append(" handler: ").append(toIndentedString(handler)).append("\n");
sb.append(" inputQueueNames: ").append(toIndentedString(inputQueueNames)).append("\n");
sb.append(" outputQueueNames: ").append(toIndentedString(outputQueueNames)).append("\n");
sb.append(" runtime: ").append(toIndentedString(runtime)).append("\n");
sb.append(" endpoint: ").append(toIndentedString(endpoint)).append("\n");
sb.append(" dynamoState: ").append(toIndentedString(dynamoState)).append("\n");
sb.append(" switchToNow: ").append(toIndentedString(switchToNow)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static HashSet openapiFields;
public static HashSet openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet();
openapiFields.add("codeUrl");
openapiFields.add("handler");
openapiFields.add("inputQueueNames");
openapiFields.add("outputQueueNames");
openapiFields.add("runtime");
openapiFields.add("endpoint");
openapiFields.add("dynamoState");
openapiFields.add("switchToNow");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("codeUrl");
openapiRequiredFields.add("handler");
openapiRequiredFields.add("inputQueueNames");
openapiRequiredFields.add("outputQueueNames");
openapiRequiredFields.add("switchToNow");
}
/**
* Validates the JSON Element and throws an exception if issues found
*
* @param jsonElement JSON Element
* @throws IOException if the JSON Element is invalid with respect to DeployRequest
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!DeployRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in DeployRequest is not found in the empty JSON string", DeployRequest.openapiRequiredFields.toString()));
}
}
Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Map.Entry entry : entries) {
if (!DeployRequest.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DeployRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : DeployRequest.openapiRequiredFields) {
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if (!jsonObj.get("codeUrl").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `codeUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("codeUrl").toString()));
}
if (!jsonObj.get("handler").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `handler` to be a primitive type in the JSON string but got `%s`", jsonObj.get("handler").toString()));
}
// ensure the required json array is present
if (jsonObj.get("inputQueueNames") == null) {
throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`");
} else if (!jsonObj.get("inputQueueNames").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `inputQueueNames` to be an array in the JSON string but got `%s`", jsonObj.get("inputQueueNames").toString()));
}
// ensure the required json array is present
if (jsonObj.get("outputQueueNames") == null) {
throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`");
} else if (!jsonObj.get("outputQueueNames").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `outputQueueNames` to be an array in the JSON string but got `%s`", jsonObj.get("outputQueueNames").toString()));
}
if ((jsonObj.get("runtime") != null && !jsonObj.get("runtime").isJsonNull()) && !jsonObj.get("runtime").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `runtime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("runtime").toString()));
}
// validate the optional field `runtime`
if (jsonObj.get("runtime") != null && !jsonObj.get("runtime").isJsonNull()) {
RuntimeEnum.validateJsonElement(jsonObj.get("runtime"));
}
// validate the optional field `endpoint`
if (jsonObj.get("endpoint") != null && !jsonObj.get("endpoint").isJsonNull()) {
DeployRequestEndpoint.validateJsonElement(jsonObj.get("endpoint"));
}
// validate the optional field `dynamoState`
if (jsonObj.get("dynamoState") != null && !jsonObj.get("dynamoState").isJsonNull()) {
DeployRequestDynamoState.validateJsonElement(jsonObj.get("dynamoState"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!DeployRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'DeployRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(DeployRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, DeployRequest value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public DeployRequest read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of DeployRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of DeployRequest
* @throws IOException if the JSON string is invalid with respect to DeployRequest
*/
public static DeployRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, DeployRequest.class);
}
/**
* Convert an instance of DeployRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy