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

com.finbourne.luminesce.model.CertificateState Maven / Gradle / Ivy

There is a newer version: 2.0.285
Show newest version
/*
 * FINBOURNE Luminesce Web API
 *
 * Contact: [email protected]
 *
 * 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.finbourne.luminesce.model;

import java.util.Objects;
import com.finbourne.luminesce.model.CertificateStatus;
import com.finbourne.luminesce.model.CertificateType;
import com.finbourne.luminesce.model.Link;
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 java.io.IOException;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.openapitools.jackson.nullable.JsonNullable;

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.Map.Entry;
import java.util.Set;

import com.finbourne.luminesce.JSON;

/**
 * Information held about the minting / revoking of a certificate.  It does *not* contain the certificate itself
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class CertificateState {
  public static final String SERIALIZED_NAME_KEY = "key";
  @SerializedName(SERIALIZED_NAME_KEY)
  private String key;

  public static final String SERIALIZED_NAME_VERSION = "version";
  @SerializedName(SERIALIZED_NAME_VERSION)
  private Integer version;

  public static final String SERIALIZED_NAME_COMMON_NAME = "commonName";
  @SerializedName(SERIALIZED_NAME_COMMON_NAME)
  private String commonName;

  public static final String SERIALIZED_NAME_TYPE = "type";
  @SerializedName(SERIALIZED_NAME_TYPE)
  private CertificateType type;

  public static final String SERIALIZED_NAME_CREATION_STATUS = "creationStatus";
  @SerializedName(SERIALIZED_NAME_CREATION_STATUS)
  private CertificateStatus creationStatus;

  public static final String SERIALIZED_NAME_REVOCATION_STATUS = "revocationStatus";
  @SerializedName(SERIALIZED_NAME_REVOCATION_STATUS)
  private CertificateStatus revocationStatus;

  public static final String SERIALIZED_NAME_VALIDITY_START = "validityStart";
  @SerializedName(SERIALIZED_NAME_VALIDITY_START)
  private OffsetDateTime validityStart;

  public static final String SERIALIZED_NAME_VALIDITY_END = "validityEnd";
  @SerializedName(SERIALIZED_NAME_VALIDITY_END)
  private OffsetDateTime validityEnd;

  public static final String SERIALIZED_NAME_REVOKED_AT = "revokedAt";
  @SerializedName(SERIALIZED_NAME_REVOKED_AT)
  private OffsetDateTime revokedAt;

  public static final String SERIALIZED_NAME_REVOKED_BY = "revokedBy";
  @SerializedName(SERIALIZED_NAME_REVOKED_BY)
  private String revokedBy;

  public static final String SERIALIZED_NAME_CREATED_AT = "createdAt";
  @SerializedName(SERIALIZED_NAME_CREATED_AT)
  private OffsetDateTime createdAt;

  public static final String SERIALIZED_NAME_CREATED_BY = "createdBy";
  @SerializedName(SERIALIZED_NAME_CREATED_BY)
  private String createdBy;

  public static final String SERIALIZED_NAME_SERIAL_NUMBER = "serialNumber";
  @SerializedName(SERIALIZED_NAME_SERIAL_NUMBER)
  private String serialNumber;

  public static final String SERIALIZED_NAME_LINKS = "links";
  @SerializedName(SERIALIZED_NAME_LINKS)
  private List links;

  public CertificateState() {
  }

  public CertificateState key(String key) {
    
    this.key = key;
    return this;
  }

   /**
   * The \"key\" to which this belongs in the dictionary,  basically the CN without any version information
   * @return key
  **/
  @jakarta.annotation.Nullable
  public String getKey() {
    return key;
  }


  public void setKey(String key) {
    this.key = key;
  }


  public CertificateState version(Integer version) {
    
    this.version = version;
    return this;
  }

   /**
   * The version of this certificate
   * @return version
  **/
  @jakarta.annotation.Nullable
  public Integer getVersion() {
    return version;
  }


  public void setVersion(Integer version) {
    this.version = version;
  }


  public CertificateState commonName(String commonName) {
    
    this.commonName = commonName;
    return this;
  }

   /**
   * The common Name of the Certificate
   * @return commonName
  **/
  @jakarta.annotation.Nullable
  public String getCommonName() {
    return commonName;
  }


  public void setCommonName(String commonName) {
    this.commonName = commonName;
  }


  public CertificateState type(CertificateType type) {
    
    this.type = type;
    return this;
  }

   /**
   * Get type
   * @return type
  **/
  @jakarta.annotation.Nullable
  public CertificateType getType() {
    return type;
  }


  public void setType(CertificateType type) {
    this.type = type;
  }


  public CertificateState creationStatus(CertificateStatus creationStatus) {
    
    this.creationStatus = creationStatus;
    return this;
  }

   /**
   * Get creationStatus
   * @return creationStatus
  **/
  @jakarta.annotation.Nullable
  public CertificateStatus getCreationStatus() {
    return creationStatus;
  }


  public void setCreationStatus(CertificateStatus creationStatus) {
    this.creationStatus = creationStatus;
  }


  public CertificateState revocationStatus(CertificateStatus revocationStatus) {
    
    this.revocationStatus = revocationStatus;
    return this;
  }

   /**
   * Get revocationStatus
   * @return revocationStatus
  **/
  @jakarta.annotation.Nullable
  public CertificateStatus getRevocationStatus() {
    return revocationStatus;
  }


  public void setRevocationStatus(CertificateStatus revocationStatus) {
    this.revocationStatus = revocationStatus;
  }


  public CertificateState validityStart(OffsetDateTime validityStart) {
    
    this.validityStart = validityStart;
    return this;
  }

   /**
   * The earliest point at which a certificate can be used
   * @return validityStart
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getValidityStart() {
    return validityStart;
  }


  public void setValidityStart(OffsetDateTime validityStart) {
    this.validityStart = validityStart;
  }


  public CertificateState validityEnd(OffsetDateTime validityEnd) {
    
    this.validityEnd = validityEnd;
    return this;
  }

   /**
   * The latest point at which a certificate can be used
   * @return validityEnd
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getValidityEnd() {
    return validityEnd;
  }


  public void setValidityEnd(OffsetDateTime validityEnd) {
    this.validityEnd = validityEnd;
  }


  public CertificateState revokedAt(OffsetDateTime revokedAt) {
    
    this.revokedAt = revokedAt;
    return this;
  }

   /**
   * The point at which this was revoked, if any
   * @return revokedAt
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getRevokedAt() {
    return revokedAt;
  }


  public void setRevokedAt(OffsetDateTime revokedAt) {
    this.revokedAt = revokedAt;
  }


  public CertificateState revokedBy(String revokedBy) {
    
    this.revokedBy = revokedBy;
    return this;
  }

   /**
   * The user which revoked this, if any
   * @return revokedBy
  **/
  @jakarta.annotation.Nullable
  public String getRevokedBy() {
    return revokedBy;
  }


  public void setRevokedBy(String revokedBy) {
    this.revokedBy = revokedBy;
  }


  public CertificateState createdAt(OffsetDateTime createdAt) {
    
    this.createdAt = createdAt;
    return this;
  }

   /**
   * The point at which this was created
   * @return createdAt
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getCreatedAt() {
    return createdAt;
  }


  public void setCreatedAt(OffsetDateTime createdAt) {
    this.createdAt = createdAt;
  }


  public CertificateState createdBy(String createdBy) {
    
    this.createdBy = createdBy;
    return this;
  }

   /**
   * The user which created this
   * @return createdBy
  **/
  @jakarta.annotation.Nullable
  public String getCreatedBy() {
    return createdBy;
  }


  public void setCreatedBy(String createdBy) {
    this.createdBy = createdBy;
  }


  public CertificateState serialNumber(String serialNumber) {
    
    this.serialNumber = serialNumber;
    return this;
  }

   /**
   * The Vault-issued serial number of the certificate, if any - used for revocation
   * @return serialNumber
  **/
  @jakarta.annotation.Nullable
  public String getSerialNumber() {
    return serialNumber;
  }


  public void setSerialNumber(String serialNumber) {
    this.serialNumber = serialNumber;
  }


  public CertificateState links(List links) {
    
    this.links = links;
    return this;
  }

  public CertificateState addLinksItem(Link linksItem) {
    if (this.links == null) {
      this.links = new ArrayList<>();
    }
    this.links.add(linksItem);
    return this;
  }

   /**
   * The location within Configuration Store that this is saved to
   * @return links
  **/
  @jakarta.annotation.Nullable
  public List getLinks() {
    return links;
  }


  public void setLinks(List links) {
    this.links = links;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    CertificateState certificateState = (CertificateState) o;
    return Objects.equals(this.key, certificateState.key) &&
        Objects.equals(this.version, certificateState.version) &&
        Objects.equals(this.commonName, certificateState.commonName) &&
        Objects.equals(this.type, certificateState.type) &&
        Objects.equals(this.creationStatus, certificateState.creationStatus) &&
        Objects.equals(this.revocationStatus, certificateState.revocationStatus) &&
        Objects.equals(this.validityStart, certificateState.validityStart) &&
        Objects.equals(this.validityEnd, certificateState.validityEnd) &&
        Objects.equals(this.revokedAt, certificateState.revokedAt) &&
        Objects.equals(this.revokedBy, certificateState.revokedBy) &&
        Objects.equals(this.createdAt, certificateState.createdAt) &&
        Objects.equals(this.createdBy, certificateState.createdBy) &&
        Objects.equals(this.serialNumber, certificateState.serialNumber) &&
        Objects.equals(this.links, certificateState.links);
  }

  private static  boolean equalsNullable(JsonNullable a, JsonNullable b) {
    return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
  }

  @Override
  public int hashCode() {
    return Objects.hash(key, version, commonName, type, creationStatus, revocationStatus, validityStart, validityEnd, revokedAt, revokedBy, createdAt, createdBy, serialNumber, links);
  }

  private static  int hashCodeNullable(JsonNullable a) {
    if (a == null) {
      return 1;
    }
    return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class CertificateState {\n");
    sb.append("    key: ").append(toIndentedString(key)).append("\n");
    sb.append("    version: ").append(toIndentedString(version)).append("\n");
    sb.append("    commonName: ").append(toIndentedString(commonName)).append("\n");
    sb.append("    type: ").append(toIndentedString(type)).append("\n");
    sb.append("    creationStatus: ").append(toIndentedString(creationStatus)).append("\n");
    sb.append("    revocationStatus: ").append(toIndentedString(revocationStatus)).append("\n");
    sb.append("    validityStart: ").append(toIndentedString(validityStart)).append("\n");
    sb.append("    validityEnd: ").append(toIndentedString(validityEnd)).append("\n");
    sb.append("    revokedAt: ").append(toIndentedString(revokedAt)).append("\n");
    sb.append("    revokedBy: ").append(toIndentedString(revokedBy)).append("\n");
    sb.append("    createdAt: ").append(toIndentedString(createdAt)).append("\n");
    sb.append("    createdBy: ").append(toIndentedString(createdBy)).append("\n");
    sb.append("    serialNumber: ").append(toIndentedString(serialNumber)).append("\n");
    sb.append("    links: ").append(toIndentedString(links)).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("key");
    openapiFields.add("version");
    openapiFields.add("commonName");
    openapiFields.add("type");
    openapiFields.add("creationStatus");
    openapiFields.add("revocationStatus");
    openapiFields.add("validityStart");
    openapiFields.add("validityEnd");
    openapiFields.add("revokedAt");
    openapiFields.add("revokedBy");
    openapiFields.add("createdAt");
    openapiFields.add("createdBy");
    openapiFields.add("serialNumber");
    openapiFields.add("links");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
  }

 /**
  * 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 CertificateState
  */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!CertificateState.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in CertificateState is not found in the empty JSON string", CertificateState.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) && !jsonObj.get("key").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString()));
      }
      if ((jsonObj.get("commonName") != null && !jsonObj.get("commonName").isJsonNull()) && !jsonObj.get("commonName").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `commonName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("commonName").toString()));
      }
      if ((jsonObj.get("revokedBy") != null && !jsonObj.get("revokedBy").isJsonNull()) && !jsonObj.get("revokedBy").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `revokedBy` to be a primitive type in the JSON string but got `%s`", jsonObj.get("revokedBy").toString()));
      }
      if ((jsonObj.get("createdBy") != null && !jsonObj.get("createdBy").isJsonNull()) && !jsonObj.get("createdBy").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `createdBy` to be a primitive type in the JSON string but got `%s`", jsonObj.get("createdBy").toString()));
      }
      if ((jsonObj.get("serialNumber") != null && !jsonObj.get("serialNumber").isJsonNull()) && !jsonObj.get("serialNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `serialNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("serialNumber").toString()));
      }
      if (jsonObj.get("links") != null && !jsonObj.get("links").isJsonNull()) {
        JsonArray jsonArraylinks = jsonObj.getAsJsonArray("links");
        if (jsonArraylinks != null) {
          // ensure the json data is an array
          if (!jsonObj.get("links").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `links` to be an array in the JSON string but got `%s`", jsonObj.get("links").toString()));
          }

          // validate the optional field `links` (array)
          for (int i = 0; i < jsonArraylinks.size(); i++) {
            Link.validateJsonElement(jsonArraylinks.get(i));
          };
        }
      }
  }

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

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

           @Override
           public CertificateState read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             return thisAdapter.fromJsonTree(jsonElement);
           }

       }.nullSafe();
    }
  }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy