
com.configcat.publicapi.java.client.model.CodeReferenceModel 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.JsonArray;
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.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import org.openapitools.jackson.nullable.JsonNullable;
/** CodeReferenceModel */
@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 CodeReferenceModel {
public static final String SERIALIZED_NAME_BRANCH = "branch";
@SerializedName(SERIALIZED_NAME_BRANCH)
private String branch;
public static final String SERIALIZED_NAME_REFERENCES = "references";
@SerializedName(SERIALIZED_NAME_REFERENCES)
private List references;
public static final String SERIALIZED_NAME_COMMIT_URL = "commitUrl";
@SerializedName(SERIALIZED_NAME_COMMIT_URL)
private String commitUrl;
public static final String SERIALIZED_NAME_COMMIT_HASH = "commitHash";
@SerializedName(SERIALIZED_NAME_COMMIT_HASH)
private String commitHash;
public static final String SERIALIZED_NAME_SYNCED_AT = "syncedAt";
@SerializedName(SERIALIZED_NAME_SYNCED_AT)
private OffsetDateTime syncedAt;
public static final String SERIALIZED_NAME_REPOSITORY = "repository";
@SerializedName(SERIALIZED_NAME_REPOSITORY)
private String repository;
public static final String SERIALIZED_NAME_CODE_REFERENCE_ID = "codeReferenceId";
@SerializedName(SERIALIZED_NAME_CODE_REFERENCE_ID)
private UUID codeReferenceId;
public static final String SERIALIZED_NAME_UPLOADER = "uploader";
@SerializedName(SERIALIZED_NAME_UPLOADER)
private String uploader;
public CodeReferenceModel() {}
public CodeReferenceModel branch(String branch) {
this.branch = branch;
return this;
}
/**
* The source control branch on where the scan was performed. (Source of the branch selector on
* the ConfigCat Dashboard)
*
* @return branch
*/
@javax.annotation.Nullable
public String getBranch() {
return branch;
}
public void setBranch(String branch) {
this.branch = branch;
}
public CodeReferenceModel references(List references) {
this.references = references;
return this;
}
public CodeReferenceModel addReferencesItem(ReferenceLines referencesItem) {
if (this.references == null) {
this.references = new ArrayList<>();
}
this.references.add(referencesItem);
return this;
}
/**
* The actual references to the given Feature Flag or Setting.
*
* @return references
*/
@javax.annotation.Nullable
public List getReferences() {
return references;
}
public void setReferences(List references) {
this.references = references;
}
public CodeReferenceModel commitUrl(String commitUrl) {
this.commitUrl = commitUrl;
return this;
}
/**
* The related commit's URL.
*
* @return commitUrl
*/
@javax.annotation.Nullable
public String getCommitUrl() {
return commitUrl;
}
public void setCommitUrl(String commitUrl) {
this.commitUrl = commitUrl;
}
public CodeReferenceModel commitHash(String commitHash) {
this.commitHash = commitHash;
return this;
}
/**
* The related commit's hash.
*
* @return commitHash
*/
@javax.annotation.Nullable
public String getCommitHash() {
return commitHash;
}
public void setCommitHash(String commitHash) {
this.commitHash = commitHash;
}
public CodeReferenceModel syncedAt(OffsetDateTime syncedAt) {
this.syncedAt = syncedAt;
return this;
}
/**
* The date and time when the reference report was uploaded.
*
* @return syncedAt
*/
@javax.annotation.Nullable
public OffsetDateTime getSyncedAt() {
return syncedAt;
}
public void setSyncedAt(OffsetDateTime syncedAt) {
this.syncedAt = syncedAt;
}
public CodeReferenceModel repository(String repository) {
this.repository = repository;
return this;
}
/**
* The source control repository that contains the scanned code.
*
* @return repository
*/
@javax.annotation.Nullable
public String getRepository() {
return repository;
}
public void setRepository(String repository) {
this.repository = repository;
}
public CodeReferenceModel codeReferenceId(UUID codeReferenceId) {
this.codeReferenceId = codeReferenceId;
return this;
}
/**
* The identifier of the reference report.
*
* @return codeReferenceId
*/
@javax.annotation.Nullable
public UUID getCodeReferenceId() {
return codeReferenceId;
}
public void setCodeReferenceId(UUID codeReferenceId) {
this.codeReferenceId = codeReferenceId;
}
public CodeReferenceModel uploader(String uploader) {
this.uploader = uploader;
return this;
}
/**
* The code reference scanning tool's name.
*
* @return uploader
*/
@javax.annotation.Nullable
public String getUploader() {
return uploader;
}
public void setUploader(String uploader) {
this.uploader = uploader;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CodeReferenceModel codeReferenceModel = (CodeReferenceModel) o;
return Objects.equals(this.branch, codeReferenceModel.branch)
&& Objects.equals(this.references, codeReferenceModel.references)
&& Objects.equals(this.commitUrl, codeReferenceModel.commitUrl)
&& Objects.equals(this.commitHash, codeReferenceModel.commitHash)
&& Objects.equals(this.syncedAt, codeReferenceModel.syncedAt)
&& Objects.equals(this.repository, codeReferenceModel.repository)
&& Objects.equals(this.codeReferenceId, codeReferenceModel.codeReferenceId)
&& Objects.equals(this.uploader, codeReferenceModel.uploader);
}
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(
branch,
references,
commitUrl,
commitHash,
syncedAt,
repository,
codeReferenceId,
uploader);
}
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 CodeReferenceModel {\n");
sb.append(" branch: ").append(toIndentedString(branch)).append("\n");
sb.append(" references: ").append(toIndentedString(references)).append("\n");
sb.append(" commitUrl: ").append(toIndentedString(commitUrl)).append("\n");
sb.append(" commitHash: ").append(toIndentedString(commitHash)).append("\n");
sb.append(" syncedAt: ").append(toIndentedString(syncedAt)).append("\n");
sb.append(" repository: ").append(toIndentedString(repository)).append("\n");
sb.append(" codeReferenceId: ").append(toIndentedString(codeReferenceId)).append("\n");
sb.append(" uploader: ").append(toIndentedString(uploader)).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("branch");
openapiFields.add("references");
openapiFields.add("commitUrl");
openapiFields.add("commitHash");
openapiFields.add("syncedAt");
openapiFields.add("repository");
openapiFields.add("codeReferenceId");
openapiFields.add("uploader");
// 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 CodeReferenceModel
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!CodeReferenceModel.openapiRequiredFields
.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(
String.format(
"The required field(s) %s in CodeReferenceModel is not found in"
+ " the empty JSON string",
CodeReferenceModel.openapiRequiredFields.toString()));
}
}
Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Map.Entry entry : entries) {
if (!CodeReferenceModel.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(
String.format(
"The field `%s` in the JSON string is not defined in the"
+ " `CodeReferenceModel` properties. JSON: %s",
entry.getKey(), jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("branch") != null && !jsonObj.get("branch").isJsonNull())
&& !jsonObj.get("branch").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `branch` to be a primitive type in the JSON string"
+ " but got `%s`",
jsonObj.get("branch").toString()));
}
if (jsonObj.get("references") != null && !jsonObj.get("references").isJsonNull()) {
JsonArray jsonArrayreferences = jsonObj.getAsJsonArray("references");
if (jsonArrayreferences != null) {
// ensure the json data is an array
if (!jsonObj.get("references").isJsonArray()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `references` to be an array in the JSON"
+ " string but got `%s`",
jsonObj.get("references").toString()));
}
// validate the optional field `references` (array)
for (int i = 0; i < jsonArrayreferences.size(); i++) {
ReferenceLines.validateJsonElement(jsonArrayreferences.get(i));
}
;
}
}
if ((jsonObj.get("commitUrl") != null && !jsonObj.get("commitUrl").isJsonNull())
&& !jsonObj.get("commitUrl").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `commitUrl` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("commitUrl").toString()));
}
if ((jsonObj.get("commitHash") != null && !jsonObj.get("commitHash").isJsonNull())
&& !jsonObj.get("commitHash").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `commitHash` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("commitHash").toString()));
}
if ((jsonObj.get("repository") != null && !jsonObj.get("repository").isJsonNull())
&& !jsonObj.get("repository").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `repository` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("repository").toString()));
}
if ((jsonObj.get("codeReferenceId") != null && !jsonObj.get("codeReferenceId").isJsonNull())
&& !jsonObj.get("codeReferenceId").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `codeReferenceId` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("codeReferenceId").toString()));
}
if ((jsonObj.get("uploader") != null && !jsonObj.get("uploader").isJsonNull())
&& !jsonObj.get("uploader").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `uploader` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("uploader").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CodeReferenceModel.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CodeReferenceModel' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter =
gson.getDelegateAdapter(this, TypeToken.get(CodeReferenceModel.class));
return (TypeAdapter)
new TypeAdapter() {
@Override
public void write(JsonWriter out, CodeReferenceModel value)
throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public CodeReferenceModel read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of CodeReferenceModel given an JSON string
*
* @param jsonString JSON string
* @return An instance of CodeReferenceModel
* @throws IOException if the JSON string is invalid with respect to CodeReferenceModel
*/
public static CodeReferenceModel fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CodeReferenceModel.class);
}
/**
* Convert an instance of CodeReferenceModel to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy