From 3fb87cd7db4e1af73ee8dbe18c5dfc8462806c5c Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Wed, 22 Oct 2025 11:48:05 +0000 Subject: [PATCH] Generate resourcemanager --- .../stackit/sdk/resourcemanager/JSON.java | 3 + .../model/ContainerSearchResult.java | 435 ++++++++++++++++++ 2 files changed, 438 insertions(+) create mode 100644 services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ContainerSearchResult.java diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/JSON.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/JSON.java index 7c17a69..c7b73d2 100644 --- a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/JSON.java +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/JSON.java @@ -95,6 +95,9 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.resourcemanager.model.ContainerSearchResult + .CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.resourcemanager.model.CreateFolderPayload .CustomTypeAdapterFactory()); diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ContainerSearchResult.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ContainerSearchResult.java new file mode 100644 index 0000000..a29a142 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ContainerSearchResult.java @@ -0,0 +1,435 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.resourcemanager.model; + +import cloud.stackit.sdk.resourcemanager.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.JsonAdapter; +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; + +/** ContainerSearchResult */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ContainerSearchResult { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + /** Resource container type. */ + @JsonAdapter(ContainerTypeEnum.Adapter.class) + public enum ContainerTypeEnum { + PROJECT("PROJECT"), + + FOLDER("FOLDER"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ContainerTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ContainerTypeEnum fromValue(String value) { + for (ContainerTypeEnum b : ContainerTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ContainerTypeEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ContainerTypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ContainerTypeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ContainerTypeEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_CONTAINER_TYPE = "containerType"; + + @SerializedName(SERIALIZED_NAME_CONTAINER_TYPE) + @javax.annotation.Nonnull + private ContainerTypeEnum containerType; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private UUID id; + + public static final String SERIALIZED_NAME_LIFECYCLE_STATE = "lifecycleState"; + + @SerializedName(SERIALIZED_NAME_LIFECYCLE_STATE) + @javax.annotation.Nullable private LifecycleState lifecycleState; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_ORGANIZATION_ID = "organizationId"; + + @SerializedName(SERIALIZED_NAME_ORGANIZATION_ID) + @javax.annotation.Nullable private UUID organizationId; + + public ContainerSearchResult() {} + + public ContainerSearchResult containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * Globally unique user-friendly identifier. + * + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + public ContainerSearchResult containerType( + @javax.annotation.Nonnull ContainerTypeEnum containerType) { + this.containerType = containerType; + return this; + } + + /** + * Resource container type. + * + * @return containerType + */ + @javax.annotation.Nonnull + public ContainerTypeEnum getContainerType() { + return containerType; + } + + public void setContainerType(@javax.annotation.Nonnull ContainerTypeEnum containerType) { + this.containerType = containerType; + } + + public ContainerSearchResult id(@javax.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * Globally unique identifier. + * + * @return id + */ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull UUID id) { + this.id = id; + } + + public ContainerSearchResult lifecycleState( + @javax.annotation.Nullable LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + return this; + } + + /** + * Get lifecycleState + * + * @return lifecycleState + */ + @javax.annotation.Nullable public LifecycleState getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(@javax.annotation.Nullable LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public ContainerSearchResult name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Resource container name. + * + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + public ContainerSearchResult organizationId(@javax.annotation.Nullable UUID organizationId) { + this.organizationId = organizationId; + return this; + } + + /** + * Id of the organization the container is in. + * + * @return organizationId + */ + @javax.annotation.Nullable public UUID getOrganizationId() { + return organizationId; + } + + public void setOrganizationId(@javax.annotation.Nullable UUID organizationId) { + this.organizationId = organizationId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ContainerSearchResult containerSearchResult = (ContainerSearchResult) o; + return Objects.equals(this.containerId, containerSearchResult.containerId) + && Objects.equals(this.containerType, containerSearchResult.containerType) + && Objects.equals(this.id, containerSearchResult.id) + && Objects.equals(this.lifecycleState, containerSearchResult.lifecycleState) + && Objects.equals(this.name, containerSearchResult.name) + && Objects.equals(this.organizationId, containerSearchResult.organizationId); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, containerType, id, lifecycleState, name, organizationId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ContainerSearchResult {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" containerType: ").append(toIndentedString(containerType)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" lifecycleState: ").append(toIndentedString(lifecycleState)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" organizationId: ").append(toIndentedString(organizationId)).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( + Arrays.asList( + "containerId", + "containerType", + "id", + "lifecycleState", + "name", + "organizationId")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet(Arrays.asList("containerId", "containerType", "id", "name")); + } + + /** + * 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 ContainerSearchResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ContainerSearchResult.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ContainerSearchResult is not found in the empty JSON string", + ContainerSearchResult.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ContainerSearchResult.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `ContainerSearchResult` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ContainerSearchResult.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("containerId").toString())); + } + if (!jsonObj.get("containerType").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `containerType` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("containerType").toString())); + } + // validate the required field `containerType` + ContainerTypeEnum.validateJsonElement(jsonObj.get("containerType")); + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + // validate the optional field `lifecycleState` + if (jsonObj.get("lifecycleState") != null && !jsonObj.get("lifecycleState").isJsonNull()) { + LifecycleState.validateJsonElement(jsonObj.get("lifecycleState")); + } + if (!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("organizationId") != null && !jsonObj.get("organizationId").isJsonNull()) + && !jsonObj.get("organizationId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `organizationId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("organizationId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ContainerSearchResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ContainerSearchResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ContainerSearchResult.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ContainerSearchResult value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ContainerSearchResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of ContainerSearchResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of ContainerSearchResult + * @throws IOException if the JSON string is invalid with respect to ContainerSearchResult + */ + public static ContainerSearchResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ContainerSearchResult.class); + } + + /** + * Convert an instance of ContainerSearchResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +}