All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.piiano.vault.client.openapi.model.Config Maven / Gradle / Ivy

/*
 * Piiano Vault REST API
 * --- sidebar_position: 1 sidebar_label: Overview description: The Piiano Vault REST API enables you to access and manage collections, objects, tokens, users, policies, and other resources within Piiano Vault. slug: / ---  # Introduction  The Piiano Vault REST API enables you to access and manage collections, objects, tokens, users, policies, and other resources within Piiano Vault in a simple, programmatic way using conventional HTTP requests and standard HTTP response codes.  The API follows RESTful conventions when possible, with most operations performed by `GET`, `POST`, `PUT`, `PATCH`, and `DELETE` requests. Request and response bodies are [JSON-encoded](https://www.json.org/json-en.html). However, for collection operations, an SQL-like [PVSchema](/guides/reference/pvschema) encoding is available.  This API reference provides details for each operation available in the API.  When you install a local copy of Vault, you can try each operation using **Send API request**.  An OpenAPI specification is available in [YAML](@site/static/assets/openapi.yaml) and [JSON](@site/static/assets/openapi.json) formats and can be used to generate client code for the API. 
 *
 * The version of the OpenAPI document: 1.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 com.piiano.vault.client.openapi.model;

import java.util.Objects;
import java.util.Arrays;
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 com.piiano.vault.client.openapi.model.DBConfig;
import com.piiano.vault.client.openapi.model.ExpirationConfig;
import com.piiano.vault.client.openapi.model.FeaturesConfig;
import com.piiano.vault.client.openapi.model.KMSConfig;
import com.piiano.vault.client.openapi.model.LogConfig;
import com.piiano.vault.client.openapi.model.SentryConfig;
import com.piiano.vault.client.openapi.model.ServiceConfig;
import com.piiano.vault.client.openapi.model.TLSConfig;
import java.io.IOException;

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 java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.piiano.vault.client.openapi.JSON;

/**
 * Config
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-04-02T19:10:30.315351Z[Etc/UTC]")
public class Config {
  public static final String SERIALIZED_NAME_DB = "db";
  @SerializedName(SERIALIZED_NAME_DB)
  private DBConfig db;

  public static final String SERIALIZED_NAME_DEVMODE = "devmode";
  @SerializedName(SERIALIZED_NAME_DEVMODE)
  private Boolean devmode;

  public static final String SERIALIZED_NAME_BACKING_STORE = "backing_store";
  @SerializedName(SERIALIZED_NAME_BACKING_STORE)
  private String backingStore;

  public static final String SERIALIZED_NAME_GENERATE_SECRETS = "generate_secrets";
  @SerializedName(SERIALIZED_NAME_GENERATE_SECRETS)
  private Boolean generateSecrets;

  public static final String SERIALIZED_NAME_FEATURES = "features";
  @SerializedName(SERIALIZED_NAME_FEATURES)
  private FeaturesConfig features;

  public static final String SERIALIZED_NAME_KMS = "kms";
  @SerializedName(SERIALIZED_NAME_KMS)
  private KMSConfig kms;

  public static final String SERIALIZED_NAME_LOG = "log";
  @SerializedName(SERIALIZED_NAME_LOG)
  private LogConfig log;

  public static final String SERIALIZED_NAME_SENTRY = "sentry";
  @SerializedName(SERIALIZED_NAME_SENTRY)
  private SentryConfig sentry;

  public static final String SERIALIZED_NAME_SERVICE = "service";
  @SerializedName(SERIALIZED_NAME_SERVICE)
  private ServiceConfig service;

  public static final String SERIALIZED_NAME_TLS = "tls";
  @SerializedName(SERIALIZED_NAME_TLS)
  private TLSConfig tls;

  public static final String SERIALIZED_NAME_EXPIRATION = "expiration";
  @SerializedName(SERIALIZED_NAME_EXPIRATION)
  private ExpirationConfig expiration;

  public Config() {
  }

  public Config db(DBConfig db) {
    
    this.db = db;
    return this;
  }

   /**
   * Get db
   * @return db
  **/
  @javax.annotation.Nonnull

  public DBConfig getDb() {
    return db;
  }


  public void setDb(DBConfig db) {
    this.db = db;
  }


  public Config devmode(Boolean devmode) {
    
    this.devmode = devmode;
    return this;
  }

   /**
   * Get devmode
   * @return devmode
  **/
  @javax.annotation.Nonnull

  public Boolean isDevmode() {
    return devmode;
  }


  public void setDevmode(Boolean devmode) {
    this.devmode = devmode;
  }


  public Config backingStore(String backingStore) {
    
    this.backingStore = backingStore;
    return this;
  }

   /**
   * Get backingStore
   * @return backingStore
  **/
  @javax.annotation.Nullable

  public String getBackingStore() {
    return backingStore;
  }


  public void setBackingStore(String backingStore) {
    this.backingStore = backingStore;
  }


  public Config generateSecrets(Boolean generateSecrets) {
    
    this.generateSecrets = generateSecrets;
    return this;
  }

   /**
   * Get generateSecrets
   * @return generateSecrets
  **/
  @javax.annotation.Nullable

  public Boolean isGenerateSecrets() {
    return generateSecrets;
  }


  public void setGenerateSecrets(Boolean generateSecrets) {
    this.generateSecrets = generateSecrets;
  }


  public Config features(FeaturesConfig features) {
    
    this.features = features;
    return this;
  }

   /**
   * Get features
   * @return features
  **/
  @javax.annotation.Nonnull

  public FeaturesConfig getFeatures() {
    return features;
  }


  public void setFeatures(FeaturesConfig features) {
    this.features = features;
  }


  public Config kms(KMSConfig kms) {
    
    this.kms = kms;
    return this;
  }

   /**
   * Get kms
   * @return kms
  **/
  @javax.annotation.Nonnull

  public KMSConfig getKms() {
    return kms;
  }


  public void setKms(KMSConfig kms) {
    this.kms = kms;
  }


  public Config log(LogConfig log) {
    
    this.log = log;
    return this;
  }

   /**
   * Get log
   * @return log
  **/
  @javax.annotation.Nonnull

  public LogConfig getLog() {
    return log;
  }


  public void setLog(LogConfig log) {
    this.log = log;
  }


  public Config sentry(SentryConfig sentry) {
    
    this.sentry = sentry;
    return this;
  }

   /**
   * Get sentry
   * @return sentry
  **/
  @javax.annotation.Nonnull

  public SentryConfig getSentry() {
    return sentry;
  }


  public void setSentry(SentryConfig sentry) {
    this.sentry = sentry;
  }


  public Config service(ServiceConfig service) {
    
    this.service = service;
    return this;
  }

   /**
   * Get service
   * @return service
  **/
  @javax.annotation.Nonnull

  public ServiceConfig getService() {
    return service;
  }


  public void setService(ServiceConfig service) {
    this.service = service;
  }


  public Config tls(TLSConfig tls) {
    
    this.tls = tls;
    return this;
  }

   /**
   * Get tls
   * @return tls
  **/
  @javax.annotation.Nonnull

  public TLSConfig getTls() {
    return tls;
  }


  public void setTls(TLSConfig tls) {
    this.tls = tls;
  }


  public Config expiration(ExpirationConfig expiration) {
    
    this.expiration = expiration;
    return this;
  }

   /**
   * Get expiration
   * @return expiration
  **/
  @javax.annotation.Nonnull

  public ExpirationConfig getExpiration() {
    return expiration;
  }


  public void setExpiration(ExpirationConfig expiration) {
    this.expiration = expiration;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    Config config = (Config) o;
    return Objects.equals(this.db, config.db) &&
        Objects.equals(this.devmode, config.devmode) &&
        Objects.equals(this.backingStore, config.backingStore) &&
        Objects.equals(this.generateSecrets, config.generateSecrets) &&
        Objects.equals(this.features, config.features) &&
        Objects.equals(this.kms, config.kms) &&
        Objects.equals(this.log, config.log) &&
        Objects.equals(this.sentry, config.sentry) &&
        Objects.equals(this.service, config.service) &&
        Objects.equals(this.tls, config.tls) &&
        Objects.equals(this.expiration, config.expiration);
  }

  @Override
  public int hashCode() {
    return Objects.hash(db, devmode, backingStore, generateSecrets, features, kms, log, sentry, service, tls, expiration);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class Config {\n");
    sb.append("    db: ").append(toIndentedString(db)).append("\n");
    sb.append("    devmode: ").append(toIndentedString(devmode)).append("\n");
    sb.append("    backingStore: ").append(toIndentedString(backingStore)).append("\n");
    sb.append("    generateSecrets: ").append(toIndentedString(generateSecrets)).append("\n");
    sb.append("    features: ").append(toIndentedString(features)).append("\n");
    sb.append("    kms: ").append(toIndentedString(kms)).append("\n");
    sb.append("    log: ").append(toIndentedString(log)).append("\n");
    sb.append("    sentry: ").append(toIndentedString(sentry)).append("\n");
    sb.append("    service: ").append(toIndentedString(service)).append("\n");
    sb.append("    tls: ").append(toIndentedString(tls)).append("\n");
    sb.append("    expiration: ").append(toIndentedString(expiration)).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("db");
    openapiFields.add("devmode");
    openapiFields.add("backing_store");
    openapiFields.add("generate_secrets");
    openapiFields.add("features");
    openapiFields.add("kms");
    openapiFields.add("log");
    openapiFields.add("sentry");
    openapiFields.add("service");
    openapiFields.add("tls");
    openapiFields.add("expiration");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
    openapiRequiredFields.add("db");
    openapiRequiredFields.add("devmode");
    openapiRequiredFields.add("features");
    openapiRequiredFields.add("kms");
    openapiRequiredFields.add("log");
    openapiRequiredFields.add("sentry");
    openapiRequiredFields.add("service");
    openapiRequiredFields.add("tls");
    openapiRequiredFields.add("expiration");
  }

 /**
  * Validates the JSON Object and throws an exception if issues found
  *
  * @param jsonObj JSON Object
  * @throws IOException if the JSON Object is invalid with respect to Config
  */
  public static void validateJsonObject(JsonObject jsonObj) throws IOException {
      if (jsonObj == null) {
        if (!Config.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in Config is not found in the empty JSON string", Config.openapiRequiredFields.toString()));
        }
      }

      Set> entries = jsonObj.entrySet();
      // check to see if the JSON string contains additional fields
      for (Entry entry : entries) {
        if (!Config.openapiFields.contains(entry.getKey())) {
          throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Config` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : Config.openapiRequiredFields) {
        if (jsonObj.get(requiredField) == null) {
          throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
        }
      }
      // validate the required field `db`
      DBConfig.validateJsonObject(jsonObj.getAsJsonObject("db"));
      if ((jsonObj.get("backing_store") != null && !jsonObj.get("backing_store").isJsonNull()) && !jsonObj.get("backing_store").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `backing_store` to be a primitive type in the JSON string but got `%s`", jsonObj.get("backing_store").toString()));
      }
      // validate the required field `features`
      FeaturesConfig.validateJsonObject(jsonObj.getAsJsonObject("features"));
      // validate the required field `kms`
      KMSConfig.validateJsonObject(jsonObj.getAsJsonObject("kms"));
      // validate the required field `log`
      LogConfig.validateJsonObject(jsonObj.getAsJsonObject("log"));
      // validate the required field `sentry`
      SentryConfig.validateJsonObject(jsonObj.getAsJsonObject("sentry"));
      // validate the required field `service`
      ServiceConfig.validateJsonObject(jsonObj.getAsJsonObject("service"));
      // validate the required field `tls`
      TLSConfig.validateJsonObject(jsonObj.getAsJsonObject("tls"));
      // validate the required field `expiration`
      ExpirationConfig.validateJsonObject(jsonObj.getAsJsonObject("expiration"));
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!Config.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'Config' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(Config.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, Config value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             elementAdapter.write(out, obj);
           }

           @Override
           public Config read(JsonReader in) throws IOException {
             JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
             validateJsonObject(jsonObj);
             return thisAdapter.fromJsonTree(jsonObj);
           }

       }.nullSafe();
    }
  }

 /**
  * Create an instance of Config given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of Config
  * @throws IOException if the JSON string is invalid with respect to Config
  */
  public static Config fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, Config.class);
  }

 /**
  * Convert an instance of Config to an JSON string
  *
  * @return JSON string
  */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy