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

io.cert.manager.models.V1alpha2CertificateRequestSpec Maven / Gradle / Ivy

The newest version!
/*
Copyright 2020 The Kubernetes Authors.
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 io.cert.manager.models;

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.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/** Desired state of the CertificateRequest resource. */
@ApiModel(description = "Desired state of the CertificateRequest resource.")
@javax.annotation.Generated(
    value = "org.openapitools.codegen.languages.JavaClientCodegen",
    date = "2020-08-18T19:55:23.947Z[Etc/UTC]")
public class V1alpha2CertificateRequestSpec {
  public static final String SERIALIZED_NAME_CSR = "csr";

  @SerializedName(SERIALIZED_NAME_CSR)
  private byte[] csr;

  public static final String SERIALIZED_NAME_DURATION = "duration";

  @SerializedName(SERIALIZED_NAME_DURATION)
  private String duration;

  public static final String SERIALIZED_NAME_IS_C_A = "isCA";

  @SerializedName(SERIALIZED_NAME_IS_C_A)
  private Boolean isCA;

  public static final String SERIALIZED_NAME_ISSUER_REF = "issuerRef";

  @SerializedName(SERIALIZED_NAME_ISSUER_REF)
  private V1beta1CertificateRequestSpecIssuerRef issuerRef;

  /**
   * KeyUsage specifies valid usage contexts for keys. See:
   * https://tools.ietf.org/html/rfc5280#section-4.2.1.3
   * https://tools.ietf.org/html/rfc5280#section-4.2.1.12 Valid KeyUsage values are as follows:
   * \"signing\", \"digital signature\", \"content commitment\",
   * \"key encipherment\", \"key agreement\", \"data encipherment\",
   * \"cert sign\", \"crl sign\", \"encipher only\", \"decipher
   * only\", \"any\", \"server auth\", \"client auth\",
   * \"code signing\", \"email protection\", \"s/mime\", \"ipsec
   * end system\", \"ipsec tunnel\", \"ipsec user\",
   * \"timestamping\", \"ocsp signing\", \"microsoft sgc\",
   * \"netscape sgc\"
   */
  @JsonAdapter(UsagesEnum.Adapter.class)
  public enum UsagesEnum {
    SIGNING("signing"),

    DIGITAL_SIGNATURE("digital signature"),

    CONTENT_COMMITMENT("content commitment"),

    KEY_ENCIPHERMENT("key encipherment"),

    KEY_AGREEMENT("key agreement"),

    DATA_ENCIPHERMENT("data encipherment"),

    CERT_SIGN("cert sign"),

    CRL_SIGN("crl sign"),

    ENCIPHER_ONLY("encipher only"),

    DECIPHER_ONLY("decipher only"),

    ANY("any"),

    SERVER_AUTH("server auth"),

    CLIENT_AUTH("client auth"),

    CODE_SIGNING("code signing"),

    EMAIL_PROTECTION("email protection"),

    S_MIME("s/mime"),

    IPSEC_END_SYSTEM("ipsec end system"),

    IPSEC_TUNNEL("ipsec tunnel"),

    IPSEC_USER("ipsec user"),

    TIMESTAMPING("timestamping"),

    OCSP_SIGNING("ocsp signing"),

    MICROSOFT_SGC("microsoft sgc"),

    NETSCAPE_SGC("netscape sgc");

    private String value;

    UsagesEnum(String value) {
      this.value = value;
    }

    public String getValue() {
      return value;
    }

    @Override
    public String toString() {
      return String.valueOf(value);
    }

    public static UsagesEnum fromValue(String value) {
      for (UsagesEnum b : UsagesEnum.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 UsagesEnum enumeration)
          throws IOException {
        jsonWriter.value(enumeration.getValue());
      }

      @Override
      public UsagesEnum read(final JsonReader jsonReader) throws IOException {
        String value = jsonReader.nextString();
        return UsagesEnum.fromValue(value);
      }
    }
  }

  public static final String SERIALIZED_NAME_USAGES = "usages";

  @SerializedName(SERIALIZED_NAME_USAGES)
  private List usages = null;

  public V1alpha2CertificateRequestSpec csr(byte[] csr) {

    this.csr = csr;
    return this;
  }

  /**
   * The PEM-encoded x509 certificate signing request to be submitted to the CA for signing.
   *
   * @return csr
   */
  @ApiModelProperty(
      required = true,
      value =
          "The PEM-encoded x509 certificate signing request to be submitted to the CA for signing.")
  public byte[] getCsr() {
    return csr;
  }

  public void setCsr(byte[] csr) {
    this.csr = csr;
  }

  public V1alpha2CertificateRequestSpec duration(String duration) {

    this.duration = duration;
    return this;
  }

  /**
   * The requested 'duration' (i.e. lifetime) of the Certificate. This option may be
   * ignored/overridden by some issuer types.
   *
   * @return duration
   */
  @javax.annotation.Nullable
  @ApiModelProperty(
      value =
          "The requested 'duration' (i.e. lifetime) of the Certificate. This option may be ignored/overridden by some issuer types.")
  public String getDuration() {
    return duration;
  }

  public void setDuration(String duration) {
    this.duration = duration;
  }

  public V1alpha2CertificateRequestSpec isCA(Boolean isCA) {

    this.isCA = isCA;
    return this;
  }

  /**
   * IsCA will request to mark the certificate as valid for certificate signing when submitting to
   * the issuer. This will automatically add the `cert sign` usage to the list of
   * `usages`.
   *
   * @return isCA
   */
  @javax.annotation.Nullable
  @ApiModelProperty(
      value =
          "IsCA will request to mark the certificate as valid for certificate signing when submitting to the issuer. This will automatically add the `cert sign` usage to the list of `usages`.")
  public Boolean getIsCA() {
    return isCA;
  }

  public void setIsCA(Boolean isCA) {
    this.isCA = isCA;
  }

  public V1alpha2CertificateRequestSpec issuerRef(
      V1beta1CertificateRequestSpecIssuerRef issuerRef) {

    this.issuerRef = issuerRef;
    return this;
  }

  /**
   * Get issuerRef
   *
   * @return issuerRef
   */
  @ApiModelProperty(required = true, value = "")
  public V1beta1CertificateRequestSpecIssuerRef getIssuerRef() {
    return issuerRef;
  }

  public void setIssuerRef(V1beta1CertificateRequestSpecIssuerRef issuerRef) {
    this.issuerRef = issuerRef;
  }

  public V1alpha2CertificateRequestSpec usages(List usages) {

    this.usages = usages;
    return this;
  }

  public V1alpha2CertificateRequestSpec addUsagesItem(UsagesEnum usagesItem) {
    if (this.usages == null) {
      this.usages = new ArrayList();
    }
    this.usages.add(usagesItem);
    return this;
  }

  /**
   * Usages is the set of x509 usages that are requested for the certificate. Defaults to
   * `digital signature` and `key encipherment` if not specified.
   *
   * @return usages
   */
  @javax.annotation.Nullable
  @ApiModelProperty(
      value =
          "Usages is the set of x509 usages that are requested for the certificate. Defaults to `digital signature` and `key encipherment` if not specified.")
  public List getUsages() {
    return usages;
  }

  public void setUsages(List usages) {
    this.usages = usages;
  }

  @Override
  public boolean equals(java.lang.Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    V1alpha2CertificateRequestSpec v1alpha2CertificateRequestSpec =
        (V1alpha2CertificateRequestSpec) o;
    return Arrays.equals(this.csr, v1alpha2CertificateRequestSpec.csr)
        && Objects.equals(this.duration, v1alpha2CertificateRequestSpec.duration)
        && Objects.equals(this.isCA, v1alpha2CertificateRequestSpec.isCA)
        && Objects.equals(this.issuerRef, v1alpha2CertificateRequestSpec.issuerRef)
        && Objects.equals(this.usages, v1alpha2CertificateRequestSpec.usages);
  }

  @Override
  public int hashCode() {
    return Objects.hash(Arrays.hashCode(csr), duration, isCA, issuerRef, usages);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class V1alpha2CertificateRequestSpec {\n");
    sb.append("    csr: ").append(toIndentedString(csr)).append("\n");
    sb.append("    duration: ").append(toIndentedString(duration)).append("\n");
    sb.append("    isCA: ").append(toIndentedString(isCA)).append("\n");
    sb.append("    issuerRef: ").append(toIndentedString(issuerRef)).append("\n");
    sb.append("    usages: ").append(toIndentedString(usages)).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(java.lang.Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy