From f0953f9549ea630436d4e32a80cf68e1281341d8 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Mon, 27 Apr 2026 14:24:19 +0000 Subject: [PATCH 1/2] Generate sfs --- services/sfs/oas_commit | 2 +- .../cloud/stackit/sdk/sfs/v1api/JSON.java | 3 + .../sdk/sfs/v1api/model/SnapshotPolicy.java | 84 ++- .../v1api/model/SnapshotPolicySchedule.java | 47 +- .../SnapshotPolicySnapshotPolicySchedule.java | 512 ++++++++++++++++++ 5 files changed, 638 insertions(+), 10 deletions(-) create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicySnapshotPolicySchedule.java diff --git a/services/sfs/oas_commit b/services/sfs/oas_commit index e86c7db2..7d5fc0bc 100644 --- a/services/sfs/oas_commit +++ b/services/sfs/oas_commit @@ -1 +1 @@ -9356c10747db357b4ec533ec97231f1af5530ca0 +a896a71ffc1c1152f63b40a0194ac461ce179d6c diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/JSON.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/JSON.java index 376c0a93..c3e28c35 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/JSON.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/JSON.java @@ -198,6 +198,9 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.sfs.v1api.model.SnapshotPolicySchedule .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.v1api.model.SnapshotPolicySnapshotPolicySchedule + .CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.sfs.v1api.model.Status.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicy.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicy.java index 4adddbfe..848bd056 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicy.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicy.java @@ -65,9 +65,15 @@ public class SnapshotPolicy { public static final String SERIALIZED_NAME_SCHEDULES = "schedules"; + @Deprecated @SerializedName(SERIALIZED_NAME_SCHEDULES) @javax.annotation.Nullable private List schedules = new ArrayList<>(); + public static final String SERIALIZED_NAME_SNAPSHOT_SCHEDULES = "snapshotSchedules"; + + @SerializedName(SERIALIZED_NAME_SNAPSHOT_SCHEDULES) + @javax.annotation.Nullable private List snapshotSchedules = new ArrayList<>(); + public SnapshotPolicy() {} public SnapshotPolicy comment(@javax.annotation.Nullable String comment) { @@ -160,6 +166,7 @@ public void setName(@javax.annotation.Nullable String name) { this.name = name; } + @Deprecated public SnapshotPolicy schedules( @javax.annotation.Nullable List schedules) { this.schedules = schedules; @@ -175,18 +182,50 @@ public SnapshotPolicy addSchedulesItem(SnapshotPolicySchedule schedulesItem) { } /** - * associated schedules + * (deprecated) associated schedules * * @return schedules + * @deprecated */ + @Deprecated @javax.annotation.Nullable public List getSchedules() { return schedules; } + @Deprecated public void setSchedules(@javax.annotation.Nullable List schedules) { this.schedules = schedules; } + public SnapshotPolicy snapshotSchedules( + @javax.annotation.Nullable List snapshotSchedules) { + this.snapshotSchedules = snapshotSchedules; + return this; + } + + public SnapshotPolicy addSnapshotSchedulesItem( + SnapshotPolicySnapshotPolicySchedule snapshotSchedulesItem) { + if (this.snapshotSchedules == null) { + this.snapshotSchedules = new ArrayList<>(); + } + this.snapshotSchedules.add(snapshotSchedulesItem); + return this; + } + + /** + * associated schedules + * + * @return snapshotSchedules + */ + @javax.annotation.Nullable public List getSnapshotSchedules() { + return snapshotSchedules; + } + + public void setSnapshotSchedules( + @javax.annotation.Nullable List snapshotSchedules) { + this.snapshotSchedules = snapshotSchedules; + } + /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -246,12 +285,21 @@ public boolean equals(Object o) { && Objects.equals(this.id, snapshotPolicy.id) && Objects.equals(this.name, snapshotPolicy.name) && Objects.equals(this.schedules, snapshotPolicy.schedules) + && Objects.equals(this.snapshotSchedules, snapshotPolicy.snapshotSchedules) && Objects.equals(this.additionalProperties, snapshotPolicy.additionalProperties); } @Override public int hashCode() { - return Objects.hash(comment, createdAt, enabled, id, name, schedules, additionalProperties); + return Objects.hash( + comment, + createdAt, + enabled, + id, + name, + schedules, + snapshotSchedules, + additionalProperties); } @Override @@ -264,6 +312,9 @@ public String toString() { sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" schedules: ").append(toIndentedString(schedules)).append("\n"); + sb.append(" snapshotSchedules: ") + .append(toIndentedString(snapshotSchedules)) + .append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); @@ -290,7 +341,13 @@ private String toIndentedString(Object o) { openapiFields = new HashSet( Arrays.asList( - "comment", "createdAt", "enabled", "id", "name", "schedules")); + "comment", + "createdAt", + "enabled", + "id", + "name", + "schedules", + "snapshotSchedules")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(0); @@ -357,6 +414,27 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ; } } + if (jsonObj.get("snapshotSchedules") != null + && !jsonObj.get("snapshotSchedules").isJsonNull()) { + JsonArray jsonArraysnapshotSchedules = jsonObj.getAsJsonArray("snapshotSchedules"); + if (jsonArraysnapshotSchedules != null) { + // ensure the json data is an array + if (!jsonObj.get("snapshotSchedules").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `snapshotSchedules` to be an array in the JSON string but got `%s`", + jsonObj.get("snapshotSchedules").toString())); + } + + // validate the optional field `snapshotSchedules` (array) + for (int i = 0; i < jsonArraysnapshotSchedules.size(); i++) { + SnapshotPolicySnapshotPolicySchedule.validateJsonElement( + jsonArraysnapshotSchedules.get(i)); + } + ; + } + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicySchedule.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicySchedule.java index 4e13f1fe..fdb01d3f 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicySchedule.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicySchedule.java @@ -40,6 +40,11 @@ public class SnapshotPolicySchedule { @SerializedName(SERIALIZED_NAME_COUNT) @javax.annotation.Nullable private Integer count; + public static final String SERIALIZED_NAME_INTERVAL = "interval"; + + @SerializedName(SERIALIZED_NAME_INTERVAL) + @javax.annotation.Nullable private String interval; + public static final String SERIALIZED_NAME_PREFIX = "prefix"; @SerializedName(SERIALIZED_NAME_PREFIX) @@ -63,7 +68,7 @@ public SnapshotPolicySchedule count(@javax.annotation.Nullable Integer count) { } /** - * Get count + * Retention Count * * @return count */ @@ -75,13 +80,31 @@ public void setCount(@javax.annotation.Nullable Integer count) { this.count = count; } + public SnapshotPolicySchedule interval(@javax.annotation.Nullable String interval) { + this.interval = interval; + return this; + } + + /** + * Interval of the Schedule (follows the cron schedule expression in Unix-like systems) + * + * @return interval + */ + @javax.annotation.Nullable public String getInterval() { + return interval; + } + + public void setInterval(@javax.annotation.Nullable String interval) { + this.interval = interval; + } + public SnapshotPolicySchedule prefix(@javax.annotation.Nullable String prefix) { this.prefix = prefix; return this; } /** - * Get prefix + * Prefix used for the snapshots created by this policy * * @return prefix */ @@ -100,7 +123,7 @@ public SnapshotPolicySchedule retentionPeriod( } /** - * Get retentionPeriod + * Retention Period (ISO 8601 format or \"infinite\") * * @return retentionPeriod */ @@ -118,7 +141,7 @@ public SnapshotPolicySchedule scheduleId(@javax.annotation.Nullable String sched } /** - * Get scheduleId + * ID of the Schedule * * @return scheduleId */ @@ -184,6 +207,7 @@ public boolean equals(Object o) { } SnapshotPolicySchedule snapshotPolicySchedule = (SnapshotPolicySchedule) o; return Objects.equals(this.count, snapshotPolicySchedule.count) + && Objects.equals(this.interval, snapshotPolicySchedule.interval) && Objects.equals(this.prefix, snapshotPolicySchedule.prefix) && Objects.equals(this.retentionPeriod, snapshotPolicySchedule.retentionPeriod) && Objects.equals(this.scheduleId, snapshotPolicySchedule.scheduleId) @@ -193,7 +217,8 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(count, prefix, retentionPeriod, scheduleId, additionalProperties); + return Objects.hash( + count, interval, prefix, retentionPeriod, scheduleId, additionalProperties); } @Override @@ -201,6 +226,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class SnapshotPolicySchedule {\n"); sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" interval: ").append(toIndentedString(interval)).append("\n"); sb.append(" prefix: ").append(toIndentedString(prefix)).append("\n"); sb.append(" retentionPeriod: ").append(toIndentedString(retentionPeriod)).append("\n"); sb.append(" scheduleId: ").append(toIndentedString(scheduleId)).append("\n"); @@ -229,7 +255,8 @@ private String toIndentedString(Object o) { // a set of all properties/fields (JSON key names) openapiFields = new HashSet( - Arrays.asList("count", "prefix", "retentionPeriod", "scheduleId")); + Arrays.asList( + "count", "interval", "prefix", "retentionPeriod", "scheduleId")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(0); @@ -253,6 +280,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("interval") != null && !jsonObj.get("interval").isJsonNull()) + && !jsonObj.get("interval").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `interval` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("interval").toString())); + } if ((jsonObj.get("prefix") != null && !jsonObj.get("prefix").isJsonNull()) && !jsonObj.get("prefix").isJsonPrimitive()) { throw new IllegalArgumentException( diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicySnapshotPolicySchedule.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicySnapshotPolicySchedule.java new file mode 100644 index 00000000..8c32f3d2 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/SnapshotPolicySnapshotPolicySchedule.java @@ -0,0 +1,512 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1.0.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.sfs.v1api.model; + +import cloud.stackit.sdk.sfs.v1api.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.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** SnapshotPolicySnapshotPolicySchedule */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.19.0") +public class SnapshotPolicySnapshotPolicySchedule { + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nullable private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nullable private String id; + + public static final String SERIALIZED_NAME_INTERVAL = "interval"; + + @SerializedName(SERIALIZED_NAME_INTERVAL) + @javax.annotation.Nullable private String interval; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_PREFIX = "prefix"; + + @SerializedName(SERIALIZED_NAME_PREFIX) + @javax.annotation.Nullable private String prefix; + + public static final String SERIALIZED_NAME_RETENTION_COUNT = "retentionCount"; + + @SerializedName(SERIALIZED_NAME_RETENTION_COUNT) + @javax.annotation.Nullable private Integer retentionCount; + + public static final String SERIALIZED_NAME_RETENTION_PERIOD = "retentionPeriod"; + + @SerializedName(SERIALIZED_NAME_RETENTION_PERIOD) + @javax.annotation.Nullable private String retentionPeriod; + + public SnapshotPolicySnapshotPolicySchedule() {} + + public SnapshotPolicySnapshotPolicySchedule createdAt( + @javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @javax.annotation.Nullable public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public SnapshotPolicySnapshotPolicySchedule id(@javax.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * ID of the Schedule + * + * @return id + */ + @javax.annotation.Nullable public String getId() { + return id; + } + + public void setId(@javax.annotation.Nullable String id) { + this.id = id; + } + + public SnapshotPolicySnapshotPolicySchedule interval( + @javax.annotation.Nullable String interval) { + this.interval = interval; + return this; + } + + /** + * Interval of the Schedule (follows the cron schedule expression in Unix-like systems) + * + * @return interval + */ + @javax.annotation.Nullable public String getInterval() { + return interval; + } + + public void setInterval(@javax.annotation.Nullable String interval) { + this.interval = interval; + } + + public SnapshotPolicySnapshotPolicySchedule name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Schedule + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public SnapshotPolicySnapshotPolicySchedule prefix(@javax.annotation.Nullable String prefix) { + this.prefix = prefix; + return this; + } + + /** + * Prefix used for the snapshots created by this policy + * + * @return prefix + */ + @javax.annotation.Nullable public String getPrefix() { + return prefix; + } + + public void setPrefix(@javax.annotation.Nullable String prefix) { + this.prefix = prefix; + } + + public SnapshotPolicySnapshotPolicySchedule retentionCount( + @javax.annotation.Nullable Integer retentionCount) { + this.retentionCount = retentionCount; + return this; + } + + /** + * Retention Count + * + * @return retentionCount + */ + @javax.annotation.Nullable public Integer getRetentionCount() { + return retentionCount; + } + + public void setRetentionCount(@javax.annotation.Nullable Integer retentionCount) { + this.retentionCount = retentionCount; + } + + public SnapshotPolicySnapshotPolicySchedule retentionPeriod( + @javax.annotation.Nullable String retentionPeriod) { + this.retentionPeriod = retentionPeriod; + return this; + } + + /** + * Retention Period (ISO 8601 format or \"infinite\") + * + * @return retentionPeriod + */ + @javax.annotation.Nullable public String getRetentionPeriod() { + return retentionPeriod; + } + + public void setRetentionPeriod(@javax.annotation.Nullable String retentionPeriod) { + this.retentionPeriod = retentionPeriod; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SnapshotPolicySnapshotPolicySchedule instance itself + */ + public SnapshotPolicySnapshotPolicySchedule putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SnapshotPolicySnapshotPolicySchedule snapshotPolicySnapshotPolicySchedule = + (SnapshotPolicySnapshotPolicySchedule) o; + return Objects.equals(this.createdAt, snapshotPolicySnapshotPolicySchedule.createdAt) + && Objects.equals(this.id, snapshotPolicySnapshotPolicySchedule.id) + && Objects.equals(this.interval, snapshotPolicySnapshotPolicySchedule.interval) + && Objects.equals(this.name, snapshotPolicySnapshotPolicySchedule.name) + && Objects.equals(this.prefix, snapshotPolicySnapshotPolicySchedule.prefix) + && Objects.equals( + this.retentionCount, snapshotPolicySnapshotPolicySchedule.retentionCount) + && Objects.equals( + this.retentionPeriod, snapshotPolicySnapshotPolicySchedule.retentionPeriod) + && Objects.equals( + this.additionalProperties, + snapshotPolicySnapshotPolicySchedule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + createdAt, + id, + interval, + name, + prefix, + retentionCount, + retentionPeriod, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SnapshotPolicySnapshotPolicySchedule {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" interval: ").append(toIndentedString(interval)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" prefix: ").append(toIndentedString(prefix)).append("\n"); + sb.append(" retentionCount: ").append(toIndentedString(retentionCount)).append("\n"); + sb.append(" retentionPeriod: ").append(toIndentedString(retentionPeriod)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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( + "createdAt", + "id", + "interval", + "name", + "prefix", + "retentionCount", + "retentionPeriod")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * 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 + * SnapshotPolicySnapshotPolicySchedule + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SnapshotPolicySnapshotPolicySchedule.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in SnapshotPolicySnapshotPolicySchedule is not found in the empty JSON string", + SnapshotPolicySnapshotPolicySchedule.openapiRequiredFields + .toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + if ((jsonObj.get("interval") != null && !jsonObj.get("interval").isJsonNull()) + && !jsonObj.get("interval").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `interval` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("interval").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if ((jsonObj.get("prefix") != null && !jsonObj.get("prefix").isJsonNull()) + && !jsonObj.get("prefix").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `prefix` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("prefix").toString())); + } + if ((jsonObj.get("retentionPeriod") != null && !jsonObj.get("retentionPeriod").isJsonNull()) + && !jsonObj.get("retentionPeriod").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `retentionPeriod` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("retentionPeriod").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SnapshotPolicySnapshotPolicySchedule.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SnapshotPolicySnapshotPolicySchedule' + // and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(SnapshotPolicySnapshotPolicySchedule.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write( + JsonWriter out, SnapshotPolicySnapshotPolicySchedule value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : + value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty( + entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SnapshotPolicySnapshotPolicySchedule read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SnapshotPolicySnapshotPolicySchedule instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of SnapshotPolicySnapshotPolicySchedule given an JSON string + * + * @param jsonString JSON string + * @return An instance of SnapshotPolicySnapshotPolicySchedule + * @throws IOException if the JSON string is invalid with respect to + * SnapshotPolicySnapshotPolicySchedule + */ + public static SnapshotPolicySnapshotPolicySchedule fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, SnapshotPolicySnapshotPolicySchedule.class); + } + + /** + * Convert an instance of SnapshotPolicySnapshotPolicySchedule to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} From b3a1f757177ed5f42773fbbd9b3e16f98b6a44e7 Mon Sep 17 00:00:00 2001 From: Carlo Goetz Date: Tue, 28 Apr 2026 12:21:40 +0200 Subject: [PATCH 2/2] chore(sfs) write changelogs, bump version --- CHANGELOG.md | 5 +++++ services/sfs/CHANGELOG.md | 6 ++++++ services/sfs/VERSION | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 202bab34..23d8787c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ - Deprecate `getSchedule` and `listSchedules` methods in `SfsApi` class - [v0.4.0](services/sfs/CHANGELOG.md#v040) - **Feature (breaking change):** Introduction of multi API version support. See the GitHub discussion post for more details: https://github.com/stackitcloud/stackit-sdk-java/discussions/530 + - [v0.5.0](services/sfs/CHANGELOG.md#v050) + - **Deprecation:** deprecated field `schedules` in model `SnapshotPolicy` + - **Feature:** new field `snapshotSchedules` in model `SnapshotPolicy` + - **Feature:** new field `interval` in model `SnapshotPolicySchedule` + - **Feature:** new model `SnapshotPolicySnapshotPolicySchedule` - `serverbackup`: [v0.2.0](services/serverbackup/CHANGELOG.md#v020) - **Feature (breaking change):** Introduction of multi API version support. See the GitHub discussion post for more details: https://github.com/stackitcloud/stackit-sdk-java/discussions/530 diff --git a/services/sfs/CHANGELOG.md b/services/sfs/CHANGELOG.md index 1ac2df5e..52368592 100644 --- a/services/sfs/CHANGELOG.md +++ b/services/sfs/CHANGELOG.md @@ -1,3 +1,9 @@ +## v0.5.0 +- **Deprecation:** deprecated field `schedules` in model `SnapshotPolicy` +- **Feature:** new field `snapshotSchedules` in model `SnapshotPolicy` +- **Feature:** new field `interval` in model `SnapshotPolicySchedule` +- **Feature:** new model `SnapshotPolicySnapshotPolicySchedule` + ## v0.4.0 - **Feature (breaking change):** Introduction of multi API version support. See the GitHub discussion post for more details: https://github.com/stackitcloud/stackit-sdk-java/discussions/530 diff --git a/services/sfs/VERSION b/services/sfs/VERSION index 1d0ba9ea..8f0916f7 100644 --- a/services/sfs/VERSION +++ b/services/sfs/VERSION @@ -1 +1 @@ -0.4.0 +0.5.0