
com.configcat.publicapi.java.client.model.ConfigModel Maven / Gradle / Ivy
/*
* ConfigCat Public Management API
* The purpose of this API is to access the ConfigCat platform programmatically. You can **Create**, **Read**, **Update** and **Delete** any entities like **Feature Flags, Configs, Environments** or **Products** within ConfigCat. **Base API URL**: https://api.configcat.com If you prefer the swagger documentation, you can find it here: [Swagger UI](https://api.configcat.com/swagger). The API is based on HTTP REST, uses resource-oriented URLs, status codes and supports JSON format. **Important:** Do not use this API for accessing and evaluating feature flag values. Use the [SDKs](https://configcat.com/docs/sdk-reference/overview) or the [ConfigCat Proxy](https://configcat.com/docs/advanced/proxy/proxy-overview/) instead. # OpenAPI Specification The complete specification is publicly available in the following formats: - [OpenAPI v3](https://api.configcat.com/docs/v1/swagger.json) - [Swagger v2](https://api.configcat.com/docs/v1/swagger.v2.json) You can use it to generate client libraries in various languages with [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) or [Swagger Codegen](https://swagger.io/tools/swagger-codegen/) to interact with this API. # Authentication This API uses the [Basic HTTP Authentication Scheme](https://en.wikipedia.org/wiki/Basic_access_authentication). # Throttling and rate limits All the rate limited API calls are returning information about the current rate limit period in the following HTTP headers: | Header | Description | | :- | :- | | X-Rate-Limit-Remaining | The maximum number of requests remaining in the current rate limit period. | | X-Rate-Limit-Reset | The time when the current rate limit period resets. | When the rate limit is exceeded by a request, the API returns with a `HTTP 429 - Too many requests` status along with a `Retry-After` HTTP header.
*
* The version of the OpenAPI document: v1
* 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.configcat.publicapi.java.client.model;
import com.configcat.publicapi.java.client.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import org.openapitools.jackson.nullable.JsonNullable;
/** Details of the Config. */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
date = "2024-10-09T12:38:06.739118192Z[Etc/UTC]",
comments = "Generator version: 7.7.0")
public class ConfigModel {
public static final String SERIALIZED_NAME_PRODUCT = "product";
@SerializedName(SERIALIZED_NAME_PRODUCT)
private ProductModel product;
public static final String SERIALIZED_NAME_CONFIG_ID = "configId";
@SerializedName(SERIALIZED_NAME_CONFIG_ID)
private UUID configId;
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_DESCRIPTION = "description";
@SerializedName(SERIALIZED_NAME_DESCRIPTION)
private String description;
public static final String SERIALIZED_NAME_ORDER = "order";
@SerializedName(SERIALIZED_NAME_ORDER)
private Integer order;
public static final String SERIALIZED_NAME_MIGRATED_CONFIG_ID = "migratedConfigId";
@SerializedName(SERIALIZED_NAME_MIGRATED_CONFIG_ID)
private UUID migratedConfigId;
public static final String SERIALIZED_NAME_EVALUATION_VERSION = "evaluationVersion";
@SerializedName(SERIALIZED_NAME_EVALUATION_VERSION)
private EvaluationVersion evaluationVersion;
public ConfigModel() {}
public ConfigModel product(ProductModel product) {
this.product = product;
return this;
}
/**
* Get product
*
* @return product
*/
@javax.annotation.Nullable
public ProductModel getProduct() {
return product;
}
public void setProduct(ProductModel product) {
this.product = product;
}
public ConfigModel configId(UUID configId) {
this.configId = configId;
return this;
}
/**
* Identifier of the Config.
*
* @return configId
*/
@javax.annotation.Nullable
public UUID getConfigId() {
return configId;
}
public void setConfigId(UUID configId) {
this.configId = configId;
}
public ConfigModel name(String name) {
this.name = name;
return this;
}
/**
* Name of the Config.
*
* @return name
*/
@javax.annotation.Nullable
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ConfigModel description(String description) {
this.description = description;
return this;
}
/**
* Description of the Config.
*
* @return description
*/
@javax.annotation.Nullable
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public ConfigModel order(Integer order) {
this.order = order;
return this;
}
/**
* The order of the Config represented on the ConfigCat Dashboard.
*
* @return order
*/
@javax.annotation.Nullable
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public ConfigModel migratedConfigId(UUID migratedConfigId) {
this.migratedConfigId = migratedConfigId;
return this;
}
/**
* Get migratedConfigId
*
* @return migratedConfigId
*/
@javax.annotation.Nullable
public UUID getMigratedConfigId() {
return migratedConfigId;
}
public void setMigratedConfigId(UUID migratedConfigId) {
this.migratedConfigId = migratedConfigId;
}
public ConfigModel evaluationVersion(EvaluationVersion evaluationVersion) {
this.evaluationVersion = evaluationVersion;
return this;
}
/**
* Get evaluationVersion
*
* @return evaluationVersion
*/
@javax.annotation.Nullable
public EvaluationVersion getEvaluationVersion() {
return evaluationVersion;
}
public void setEvaluationVersion(EvaluationVersion evaluationVersion) {
this.evaluationVersion = evaluationVersion;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ConfigModel configModel = (ConfigModel) o;
return Objects.equals(this.product, configModel.product)
&& Objects.equals(this.configId, configModel.configId)
&& Objects.equals(this.name, configModel.name)
&& Objects.equals(this.description, configModel.description)
&& Objects.equals(this.order, configModel.order)
&& Objects.equals(this.migratedConfigId, configModel.migratedConfigId)
&& Objects.equals(this.evaluationVersion, configModel.evaluationVersion);
}
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(
product, configId, name, description, order, migratedConfigId, evaluationVersion);
}
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 ConfigModel {\n");
sb.append(" product: ").append(toIndentedString(product)).append("\n");
sb.append(" configId: ").append(toIndentedString(configId)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" order: ").append(toIndentedString(order)).append("\n");
sb.append(" migratedConfigId: ").append(toIndentedString(migratedConfigId)).append("\n");
sb.append(" evaluationVersion: ")
.append(toIndentedString(evaluationVersion))
.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("product");
openapiFields.add("configId");
openapiFields.add("name");
openapiFields.add("description");
openapiFields.add("order");
openapiFields.add("migratedConfigId");
openapiFields.add("evaluationVersion");
// 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 ConfigModel
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!ConfigModel.openapiRequiredFields
.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(
String.format(
"The required field(s) %s in ConfigModel is not found in the empty"
+ " JSON string",
ConfigModel.openapiRequiredFields.toString()));
}
}
Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Map.Entry entry : entries) {
if (!ConfigModel.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(
String.format(
"The field `%s` in the JSON string is not defined in the"
+ " `ConfigModel` properties. JSON: %s",
entry.getKey(), jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
// validate the optional field `product`
if (jsonObj.get("product") != null && !jsonObj.get("product").isJsonNull()) {
ProductModel.validateJsonElement(jsonObj.get("product"));
}
if ((jsonObj.get("configId") != null && !jsonObj.get("configId").isJsonNull())
&& !jsonObj.get("configId").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `configId` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("configId").toString()));
}
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull())
&& !jsonObj.get("name").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `name` to be a primitive type in the JSON string"
+ " but got `%s`",
jsonObj.get("name").toString()));
}
if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull())
&& !jsonObj.get("description").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `description` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("description").toString()));
}
if ((jsonObj.get("migratedConfigId") != null
&& !jsonObj.get("migratedConfigId").isJsonNull())
&& !jsonObj.get("migratedConfigId").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `migratedConfigId` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("migratedConfigId").toString()));
}
// validate the optional field `evaluationVersion`
if (jsonObj.get("evaluationVersion") != null
&& !jsonObj.get("evaluationVersion").isJsonNull()) {
EvaluationVersion.validateJsonElement(jsonObj.get("evaluationVersion"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!ConfigModel.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'ConfigModel' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter =
gson.getDelegateAdapter(this, TypeToken.get(ConfigModel.class));
return (TypeAdapter)
new TypeAdapter() {
@Override
public void write(JsonWriter out, ConfigModel value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public ConfigModel read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of ConfigModel given an JSON string
*
* @param jsonString JSON string
* @return An instance of ConfigModel
* @throws IOException if the JSON string is invalid with respect to ConfigModel
*/
public static ConfigModel fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, ConfigModel.class);
}
/**
* Convert an instance of ConfigModel to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy