|
| 1 | +/* |
| 2 | + * Kubernetes |
| 3 | + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) |
| 4 | + * |
| 5 | + * The version of the OpenAPI document: v1.21.1 |
| 6 | + * |
| 7 | + * |
| 8 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 9 | + * https://openapi-generator.tech |
| 10 | + * Do not edit the class manually. |
| 11 | + */ |
| 12 | + |
| 13 | + |
| 14 | +package io.cert.manager.models; |
| 15 | + |
| 16 | +import java.util.Objects; |
| 17 | +import java.util.Arrays; |
| 18 | +import com.google.gson.TypeAdapter; |
| 19 | +import com.google.gson.annotations.JsonAdapter; |
| 20 | +import com.google.gson.annotations.SerializedName; |
| 21 | +import com.google.gson.stream.JsonReader; |
| 22 | +import com.google.gson.stream.JsonWriter; |
| 23 | +import io.cert.manager.models.V1CertificateSpec; |
| 24 | +import io.cert.manager.models.V1CertificateStatus; |
| 25 | +import io.kubernetes.client.openapi.models.V1ObjectMeta; |
| 26 | +import java.io.IOException; |
| 27 | + |
| 28 | +import com.google.gson.Gson; |
| 29 | +import com.google.gson.GsonBuilder; |
| 30 | +import com.google.gson.JsonArray; |
| 31 | +import com.google.gson.JsonDeserializationContext; |
| 32 | +import com.google.gson.JsonDeserializer; |
| 33 | +import com.google.gson.JsonElement; |
| 34 | +import com.google.gson.JsonObject; |
| 35 | +import com.google.gson.JsonParseException; |
| 36 | +import com.google.gson.TypeAdapterFactory; |
| 37 | +import com.google.gson.reflect.TypeToken; |
| 38 | +import com.google.gson.TypeAdapter; |
| 39 | +import com.google.gson.stream.JsonReader; |
| 40 | +import com.google.gson.stream.JsonWriter; |
| 41 | +import java.io.IOException; |
| 42 | + |
| 43 | +import java.lang.reflect.Type; |
| 44 | +import java.util.HashMap; |
| 45 | +import java.util.HashSet; |
| 46 | +import java.util.List; |
| 47 | +import java.util.Map; |
| 48 | +import java.util.Map.Entry; |
| 49 | +import java.util.Set; |
| 50 | + |
| 51 | +import io.kubernetes.client.openapi.JSON; |
| 52 | + |
| 53 | +/** |
| 54 | + * A Certificate resource should be created to ensure an up to date and signed X.509 certificate is stored in the Kubernetes Secret resource named in `spec.secretName`. The stored certificate will be renewed before it expires (as configured by `spec.renewBefore`). |
| 55 | + */ |
| 56 | +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-01T07:00:20.132973Z[Etc/UTC]") |
| 57 | +public class V1Certificate implements io.kubernetes.client.common.KubernetesObject { |
| 58 | + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; |
| 59 | + @SerializedName(SERIALIZED_NAME_API_VERSION) |
| 60 | + private String apiVersion; |
| 61 | + |
| 62 | + public static final String SERIALIZED_NAME_KIND = "kind"; |
| 63 | + @SerializedName(SERIALIZED_NAME_KIND) |
| 64 | + private String kind; |
| 65 | + |
| 66 | + public static final String SERIALIZED_NAME_METADATA = "metadata"; |
| 67 | + @SerializedName(SERIALIZED_NAME_METADATA) |
| 68 | + private V1ObjectMeta metadata = null; |
| 69 | + |
| 70 | + public static final String SERIALIZED_NAME_SPEC = "spec"; |
| 71 | + @SerializedName(SERIALIZED_NAME_SPEC) |
| 72 | + private V1CertificateSpec spec; |
| 73 | + |
| 74 | + public static final String SERIALIZED_NAME_STATUS = "status"; |
| 75 | + @SerializedName(SERIALIZED_NAME_STATUS) |
| 76 | + private V1CertificateStatus status; |
| 77 | + |
| 78 | + public V1Certificate() { |
| 79 | + } |
| 80 | + |
| 81 | + public V1Certificate apiVersion(String apiVersion) { |
| 82 | + |
| 83 | + this.apiVersion = apiVersion; |
| 84 | + return this; |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources |
| 89 | + * @return apiVersion |
| 90 | + **/ |
| 91 | + @jakarta.annotation.Nullable |
| 92 | + public String getApiVersion() { |
| 93 | + return apiVersion; |
| 94 | + } |
| 95 | + |
| 96 | + |
| 97 | + public void setApiVersion(String apiVersion) { |
| 98 | + this.apiVersion = apiVersion; |
| 99 | + } |
| 100 | + |
| 101 | + |
| 102 | + public V1Certificate kind(String kind) { |
| 103 | + |
| 104 | + this.kind = kind; |
| 105 | + return this; |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
| 110 | + * @return kind |
| 111 | + **/ |
| 112 | + @jakarta.annotation.Nullable |
| 113 | + public String getKind() { |
| 114 | + return kind; |
| 115 | + } |
| 116 | + |
| 117 | + |
| 118 | + public void setKind(String kind) { |
| 119 | + this.kind = kind; |
| 120 | + } |
| 121 | + |
| 122 | + |
| 123 | + public V1Certificate metadata(V1ObjectMeta metadata) { |
| 124 | + |
| 125 | + this.metadata = metadata; |
| 126 | + return this; |
| 127 | + } |
| 128 | + |
| 129 | + /** |
| 130 | + * Get metadata |
| 131 | + * @return metadata |
| 132 | + **/ |
| 133 | + @jakarta.annotation.Nullable |
| 134 | + public V1ObjectMeta getMetadata() { |
| 135 | + return metadata; |
| 136 | + } |
| 137 | + |
| 138 | + |
| 139 | + public void setMetadata(V1ObjectMeta metadata) { |
| 140 | + this.metadata = metadata; |
| 141 | + } |
| 142 | + |
| 143 | + |
| 144 | + public V1Certificate spec(V1CertificateSpec spec) { |
| 145 | + |
| 146 | + this.spec = spec; |
| 147 | + return this; |
| 148 | + } |
| 149 | + |
| 150 | + /** |
| 151 | + * Get spec |
| 152 | + * @return spec |
| 153 | + **/ |
| 154 | + @jakarta.annotation.Nullable |
| 155 | + public V1CertificateSpec getSpec() { |
| 156 | + return spec; |
| 157 | + } |
| 158 | + |
| 159 | + |
| 160 | + public void setSpec(V1CertificateSpec spec) { |
| 161 | + this.spec = spec; |
| 162 | + } |
| 163 | + |
| 164 | + |
| 165 | + public V1Certificate status(V1CertificateStatus status) { |
| 166 | + |
| 167 | + this.status = status; |
| 168 | + return this; |
| 169 | + } |
| 170 | + |
| 171 | + /** |
| 172 | + * Get status |
| 173 | + * @return status |
| 174 | + **/ |
| 175 | + @jakarta.annotation.Nullable |
| 176 | + public V1CertificateStatus getStatus() { |
| 177 | + return status; |
| 178 | + } |
| 179 | + |
| 180 | + |
| 181 | + public void setStatus(V1CertificateStatus status) { |
| 182 | + this.status = status; |
| 183 | + } |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | + @Override |
| 188 | + public boolean equals(Object o) { |
| 189 | + if (this == o) { |
| 190 | + return true; |
| 191 | + } |
| 192 | + if (o == null || getClass() != o.getClass()) { |
| 193 | + return false; |
| 194 | + } |
| 195 | + V1Certificate v1Certificate = (V1Certificate) o; |
| 196 | + return Objects.equals(this.apiVersion, v1Certificate.apiVersion) && |
| 197 | + Objects.equals(this.kind, v1Certificate.kind) && |
| 198 | + Objects.equals(this.metadata, v1Certificate.metadata) && |
| 199 | + Objects.equals(this.spec, v1Certificate.spec) && |
| 200 | + Objects.equals(this.status, v1Certificate.status); |
| 201 | + } |
| 202 | + |
| 203 | + @Override |
| 204 | + public int hashCode() { |
| 205 | + return Objects.hash(apiVersion, kind, metadata, spec, status); |
| 206 | + } |
| 207 | + |
| 208 | + @Override |
| 209 | + public String toString() { |
| 210 | + StringBuilder sb = new StringBuilder(); |
| 211 | + sb.append("class V1Certificate {\n"); |
| 212 | + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); |
| 213 | + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); |
| 214 | + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); |
| 215 | + sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); |
| 216 | + sb.append(" status: ").append(toIndentedString(status)).append("\n"); |
| 217 | + sb.append("}"); |
| 218 | + return sb.toString(); |
| 219 | + } |
| 220 | + |
| 221 | + /** |
| 222 | + * Convert the given object to string with each line indented by 4 spaces |
| 223 | + * (except the first line). |
| 224 | + */ |
| 225 | + private String toIndentedString(Object o) { |
| 226 | + if (o == null) { |
| 227 | + return "null"; |
| 228 | + } |
| 229 | + return o.toString().replace("\n", "\n "); |
| 230 | + } |
| 231 | + |
| 232 | + |
| 233 | + public static HashSet<String> openapiFields; |
| 234 | + public static HashSet<String> openapiRequiredFields; |
| 235 | + |
| 236 | + static { |
| 237 | + // a set of all properties/fields (JSON key names) |
| 238 | + openapiFields = new HashSet<String>(); |
| 239 | + openapiFields.add("apiVersion"); |
| 240 | + openapiFields.add("kind"); |
| 241 | + openapiFields.add("metadata"); |
| 242 | + openapiFields.add("spec"); |
| 243 | + openapiFields.add("status"); |
| 244 | + |
| 245 | + // a set of required properties/fields (JSON key names) |
| 246 | + openapiRequiredFields = new HashSet<String>(); |
| 247 | + } |
| 248 | + |
| 249 | + /** |
| 250 | + * Validates the JSON Object and throws an exception if issues found |
| 251 | + * |
| 252 | + * @param jsonObj JSON Object |
| 253 | + * @throws IOException if the JSON Object is invalid with respect to V1Certificate |
| 254 | + */ |
| 255 | + public static void validateJsonObject(JsonObject jsonObj) throws IOException { |
| 256 | + if (jsonObj == null) { |
| 257 | + if (!V1Certificate.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null |
| 258 | + throw new IllegalArgumentException(String.format("The required field(s) %s in V1Certificate is not found in the empty JSON string", V1Certificate.openapiRequiredFields.toString())); |
| 259 | + } |
| 260 | + } |
| 261 | + |
| 262 | + Set<Entry<String, JsonElement>> entries = jsonObj.entrySet(); |
| 263 | + // check to see if the JSON string contains additional fields |
| 264 | + for (Entry<String, JsonElement> entry : entries) { |
| 265 | + if (!V1Certificate.openapiFields.contains(entry.getKey())) { |
| 266 | + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `V1Certificate` properties. JSON: %s", entry.getKey(), jsonObj.toString())); |
| 267 | + } |
| 268 | + } |
| 269 | + if ((jsonObj.get("apiVersion") != null && !jsonObj.get("apiVersion").isJsonNull()) && !jsonObj.get("apiVersion").isJsonPrimitive()) { |
| 270 | + throw new IllegalArgumentException(String.format("Expected the field `apiVersion` to be a primitive type in the JSON string but got `%s`", jsonObj.get("apiVersion").toString())); |
| 271 | + } |
| 272 | + if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) { |
| 273 | + throw new IllegalArgumentException(String.format("Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); |
| 274 | + } |
| 275 | + // validate the optional field `spec` |
| 276 | + if (jsonObj.get("spec") != null && !jsonObj.get("spec").isJsonNull()) { |
| 277 | + V1CertificateSpec.validateJsonObject(jsonObj.getAsJsonObject("spec")); |
| 278 | + } |
| 279 | + // validate the optional field `status` |
| 280 | + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { |
| 281 | + V1CertificateStatus.validateJsonObject(jsonObj.getAsJsonObject("status")); |
| 282 | + } |
| 283 | + } |
| 284 | + |
| 285 | + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { |
| 286 | + @SuppressWarnings("unchecked") |
| 287 | + @Override |
| 288 | + public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { |
| 289 | + if (!V1Certificate.class.isAssignableFrom(type.getRawType())) { |
| 290 | + return null; // this class only serializes 'V1Certificate' and its subtypes |
| 291 | + } |
| 292 | + final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class); |
| 293 | + final TypeAdapter<V1Certificate> thisAdapter |
| 294 | + = gson.getDelegateAdapter(this, TypeToken.get(V1Certificate.class)); |
| 295 | + |
| 296 | + return (TypeAdapter<T>) new TypeAdapter<V1Certificate>() { |
| 297 | + @Override |
| 298 | + public void write(JsonWriter out, V1Certificate value) throws IOException { |
| 299 | + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); |
| 300 | + elementAdapter.write(out, obj); |
| 301 | + } |
| 302 | + |
| 303 | + @Override |
| 304 | + public V1Certificate read(JsonReader in) throws IOException { |
| 305 | + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); |
| 306 | + validateJsonObject(jsonObj); |
| 307 | + return thisAdapter.fromJsonTree(jsonObj); |
| 308 | + } |
| 309 | + |
| 310 | + }.nullSafe(); |
| 311 | + } |
| 312 | + } |
| 313 | + |
| 314 | + /** |
| 315 | + * Create an instance of V1Certificate given an JSON string |
| 316 | + * |
| 317 | + * @param jsonString JSON string |
| 318 | + * @return An instance of V1Certificate |
| 319 | + * @throws IOException if the JSON string is invalid with respect to V1Certificate |
| 320 | + */ |
| 321 | + public static V1Certificate fromJson(String jsonString) throws IOException { |
| 322 | + return JSON.getGson().fromJson(jsonString, V1Certificate.class); |
| 323 | + } |
| 324 | + |
| 325 | + /** |
| 326 | + * Convert an instance of V1Certificate to an JSON string |
| 327 | + * |
| 328 | + * @return JSON string |
| 329 | + */ |
| 330 | + public String toJson() { |
| 331 | + return JSON.getGson().toJson(this); |
| 332 | + } |
| 333 | +} |
| 334 | + |
0 commit comments