Skip to content

Commit 8d66593

Browse files
Generator: Update SDK /services/serverupdate (#275)
1 parent d382e6d commit 8d66593

17 files changed

+1468
-196
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Release (2026-MM-DD)
2+
- `serverupdate`: [v0.1.2](services/serverupdate/CHANGELOG.md#v012)
3+
- **Improvement:** Support additional properties in models
4+
15
## Release (2026-01-27)
26
- `core`: [v0.4.1](core/CHANGELOG.md/#v041)
37
- **Bugfix:** Add check in `KeyFlowAuthenticator` to prevent endless loops

services/serverupdate/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v0.1.2
2+
- **Improvement:** Support additional properties in models
3+
14
## v0.1.1
25
- Bump dependency `cloud.stackit.sdk.core` to v0.4.1
36

services/serverupdate/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.1
1+
0.1.2

services/serverupdate/oas_commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ed4e4fbee2f5db4d95725108fb3d736e5363fb2f

services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdatePayload.java

Lines changed: 111 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
import com.google.gson.stream.JsonWriter;
2525
import java.io.IOException;
2626
import java.util.Arrays;
27+
import java.util.HashMap;
2728
import java.util.HashSet;
29+
import java.util.List;
2830
import java.util.Map;
2931
import java.util.Objects;
30-
import java.util.Set;
3132

3233
/** CreateUpdatePayload */
3334
@javax.annotation.Generated(
@@ -86,6 +87,50 @@ public void setMaintenanceWindow(@javax.annotation.Nonnull Integer maintenanceWi
8687
this.maintenanceWindow = maintenanceWindow;
8788
}
8889

90+
/**
91+
* A container for additional, undeclared properties. This is a holder for any undeclared
92+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
93+
*/
94+
private Map<String, Object> additionalProperties;
95+
96+
/**
97+
* Set the additional (undeclared) property with the specified name and value. If the property
98+
* does not already exist, create it otherwise replace it.
99+
*
100+
* @param key name of the property
101+
* @param value value of the property
102+
* @return the CreateUpdatePayload instance itself
103+
*/
104+
public CreateUpdatePayload putAdditionalProperty(String key, Object value) {
105+
if (this.additionalProperties == null) {
106+
this.additionalProperties = new HashMap<String, Object>();
107+
}
108+
this.additionalProperties.put(key, value);
109+
return this;
110+
}
111+
112+
/**
113+
* Return the additional (undeclared) property.
114+
*
115+
* @return a map of objects
116+
*/
117+
public Map<String, Object> getAdditionalProperties() {
118+
return additionalProperties;
119+
}
120+
121+
/**
122+
* Return the additional (undeclared) property with the specified name.
123+
*
124+
* @param key name of the property
125+
* @return an object
126+
*/
127+
public Object getAdditionalProperty(String key) {
128+
if (this.additionalProperties == null) {
129+
return null;
130+
}
131+
return this.additionalProperties.get(key);
132+
}
133+
89134
@Override
90135
public boolean equals(Object o) {
91136
if (this == o) {
@@ -96,12 +141,14 @@ public boolean equals(Object o) {
96141
}
97142
CreateUpdatePayload createUpdatePayload = (CreateUpdatePayload) o;
98143
return Objects.equals(this.backupBeforeUpdate, createUpdatePayload.backupBeforeUpdate)
99-
&& Objects.equals(this.maintenanceWindow, createUpdatePayload.maintenanceWindow);
144+
&& Objects.equals(this.maintenanceWindow, createUpdatePayload.maintenanceWindow)
145+
&& Objects.equals(
146+
this.additionalProperties, createUpdatePayload.additionalProperties);
100147
}
101148

102149
@Override
103150
public int hashCode() {
104-
return Objects.hash(backupBeforeUpdate, maintenanceWindow);
151+
return Objects.hash(backupBeforeUpdate, maintenanceWindow, additionalProperties);
105152
}
106153

107154
@Override
@@ -114,6 +161,9 @@ public String toString() {
114161
sb.append(" maintenanceWindow: ")
115162
.append(toIndentedString(maintenanceWindow))
116163
.append("\n");
164+
sb.append(" additionalProperties: ")
165+
.append(toIndentedString(additionalProperties))
166+
.append("\n");
117167
sb.append("}");
118168
return sb.toString();
119169
}
@@ -158,17 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
158208
}
159209
}
160210

161-
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
162-
// check to see if the JSON string contains additional fields
163-
for (Map.Entry<String, JsonElement> entry : entries) {
164-
if (!CreateUpdatePayload.openapiFields.contains(entry.getKey())) {
165-
throw new IllegalArgumentException(
166-
String.format(
167-
"The field `%s` in the JSON string is not defined in the `CreateUpdatePayload` properties. JSON: %s",
168-
entry.getKey(), jsonElement.toString()));
169-
}
170-
}
171-
172211
// check to make sure all required properties/fields are present in the JSON string
173212
for (String requiredField : CreateUpdatePayload.openapiRequiredFields) {
174213
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
@@ -198,14 +237,71 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
198237
public void write(JsonWriter out, CreateUpdatePayload value)
199238
throws IOException {
200239
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
240+
obj.remove("additionalProperties");
241+
// serialize additional properties
242+
if (value.getAdditionalProperties() != null) {
243+
for (Map.Entry<String, Object> entry :
244+
value.getAdditionalProperties().entrySet()) {
245+
if (entry.getValue() instanceof String)
246+
obj.addProperty(entry.getKey(), (String) entry.getValue());
247+
else if (entry.getValue() instanceof Number)
248+
obj.addProperty(entry.getKey(), (Number) entry.getValue());
249+
else if (entry.getValue() instanceof Boolean)
250+
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
251+
else if (entry.getValue() instanceof Character)
252+
obj.addProperty(
253+
entry.getKey(), (Character) entry.getValue());
254+
else {
255+
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
256+
if (jsonElement.isJsonArray()) {
257+
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
258+
} else {
259+
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
260+
}
261+
}
262+
}
263+
}
201264
elementAdapter.write(out, obj);
202265
}
203266

204267
@Override
205268
public CreateUpdatePayload read(JsonReader in) throws IOException {
206269
JsonElement jsonElement = elementAdapter.read(in);
207270
validateJsonElement(jsonElement);
208-
return thisAdapter.fromJsonTree(jsonElement);
271+
JsonObject jsonObj = jsonElement.getAsJsonObject();
272+
// store additional fields in the deserialized instance
273+
CreateUpdatePayload instance = thisAdapter.fromJsonTree(jsonObj);
274+
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
275+
if (!openapiFields.contains(entry.getKey())) {
276+
if (entry.getValue().isJsonPrimitive()) { // primitive type
277+
if (entry.getValue().getAsJsonPrimitive().isString())
278+
instance.putAdditionalProperty(
279+
entry.getKey(), entry.getValue().getAsString());
280+
else if (entry.getValue().getAsJsonPrimitive().isNumber())
281+
instance.putAdditionalProperty(
282+
entry.getKey(), entry.getValue().getAsNumber());
283+
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
284+
instance.putAdditionalProperty(
285+
entry.getKey(),
286+
entry.getValue().getAsBoolean());
287+
else
288+
throw new IllegalArgumentException(
289+
String.format(
290+
"The field `%s` has unknown primitive type. Value: %s",
291+
entry.getKey(),
292+
entry.getValue().toString()));
293+
} else if (entry.getValue().isJsonArray()) {
294+
instance.putAdditionalProperty(
295+
entry.getKey(),
296+
gson.fromJson(entry.getValue(), List.class));
297+
} else { // JSON object
298+
instance.putAdditionalProperty(
299+
entry.getKey(),
300+
gson.fromJson(entry.getValue(), HashMap.class));
301+
}
302+
}
303+
}
304+
return instance;
209305
}
210306
}.nullSafe();
211307
}

services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdateSchedulePayload.java

Lines changed: 113 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
import com.google.gson.stream.JsonWriter;
2525
import java.io.IOException;
2626
import java.util.Arrays;
27+
import java.util.HashMap;
2728
import java.util.HashSet;
29+
import java.util.List;
2830
import java.util.Map;
2931
import java.util.Objects;
30-
import java.util.Set;
3132

3233
/** CreateUpdateSchedulePayload */
3334
@javax.annotation.Generated(
@@ -137,6 +138,50 @@ public void setRrule(@javax.annotation.Nonnull String rrule) {
137138
this.rrule = rrule;
138139
}
139140

141+
/**
142+
* A container for additional, undeclared properties. This is a holder for any undeclared
143+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
144+
*/
145+
private Map<String, Object> additionalProperties;
146+
147+
/**
148+
* Set the additional (undeclared) property with the specified name and value. If the property
149+
* does not already exist, create it otherwise replace it.
150+
*
151+
* @param key name of the property
152+
* @param value value of the property
153+
* @return the CreateUpdateSchedulePayload instance itself
154+
*/
155+
public CreateUpdateSchedulePayload putAdditionalProperty(String key, Object value) {
156+
if (this.additionalProperties == null) {
157+
this.additionalProperties = new HashMap<String, Object>();
158+
}
159+
this.additionalProperties.put(key, value);
160+
return this;
161+
}
162+
163+
/**
164+
* Return the additional (undeclared) property.
165+
*
166+
* @return a map of objects
167+
*/
168+
public Map<String, Object> getAdditionalProperties() {
169+
return additionalProperties;
170+
}
171+
172+
/**
173+
* Return the additional (undeclared) property with the specified name.
174+
*
175+
* @param key name of the property
176+
* @return an object
177+
*/
178+
public Object getAdditionalProperty(String key) {
179+
if (this.additionalProperties == null) {
180+
return null;
181+
}
182+
return this.additionalProperties.get(key);
183+
}
184+
140185
@Override
141186
public boolean equals(Object o) {
142187
if (this == o) {
@@ -150,12 +195,15 @@ public boolean equals(Object o) {
150195
&& Objects.equals(
151196
this.maintenanceWindow, createUpdateSchedulePayload.maintenanceWindow)
152197
&& Objects.equals(this.name, createUpdateSchedulePayload.name)
153-
&& Objects.equals(this.rrule, createUpdateSchedulePayload.rrule);
198+
&& Objects.equals(this.rrule, createUpdateSchedulePayload.rrule)
199+
&& Objects.equals(
200+
this.additionalProperties,
201+
createUpdateSchedulePayload.additionalProperties);
154202
}
155203

156204
@Override
157205
public int hashCode() {
158-
return Objects.hash(enabled, maintenanceWindow, name, rrule);
206+
return Objects.hash(enabled, maintenanceWindow, name, rrule, additionalProperties);
159207
}
160208

161209
@Override
@@ -168,6 +216,9 @@ public String toString() {
168216
.append("\n");
169217
sb.append(" name: ").append(toIndentedString(name)).append("\n");
170218
sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n");
219+
sb.append(" additionalProperties: ")
220+
.append(toIndentedString(additionalProperties))
221+
.append("\n");
171222
sb.append("}");
172223
return sb.toString();
173224
}
@@ -214,17 +265,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
214265
}
215266
}
216267

217-
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
218-
// check to see if the JSON string contains additional fields
219-
for (Map.Entry<String, JsonElement> entry : entries) {
220-
if (!CreateUpdateSchedulePayload.openapiFields.contains(entry.getKey())) {
221-
throw new IllegalArgumentException(
222-
String.format(
223-
"The field `%s` in the JSON string is not defined in the `CreateUpdateSchedulePayload` properties. JSON: %s",
224-
entry.getKey(), jsonElement.toString()));
225-
}
226-
}
227-
228268
// check to make sure all required properties/fields are present in the JSON string
229269
for (String requiredField : CreateUpdateSchedulePayload.openapiRequiredFields) {
230270
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
@@ -267,14 +307,72 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
267307
public void write(JsonWriter out, CreateUpdateSchedulePayload value)
268308
throws IOException {
269309
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
310+
obj.remove("additionalProperties");
311+
// serialize additional properties
312+
if (value.getAdditionalProperties() != null) {
313+
for (Map.Entry<String, Object> entry :
314+
value.getAdditionalProperties().entrySet()) {
315+
if (entry.getValue() instanceof String)
316+
obj.addProperty(entry.getKey(), (String) entry.getValue());
317+
else if (entry.getValue() instanceof Number)
318+
obj.addProperty(entry.getKey(), (Number) entry.getValue());
319+
else if (entry.getValue() instanceof Boolean)
320+
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
321+
else if (entry.getValue() instanceof Character)
322+
obj.addProperty(
323+
entry.getKey(), (Character) entry.getValue());
324+
else {
325+
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
326+
if (jsonElement.isJsonArray()) {
327+
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
328+
} else {
329+
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
330+
}
331+
}
332+
}
333+
}
270334
elementAdapter.write(out, obj);
271335
}
272336

273337
@Override
274338
public CreateUpdateSchedulePayload read(JsonReader in) throws IOException {
275339
JsonElement jsonElement = elementAdapter.read(in);
276340
validateJsonElement(jsonElement);
277-
return thisAdapter.fromJsonTree(jsonElement);
341+
JsonObject jsonObj = jsonElement.getAsJsonObject();
342+
// store additional fields in the deserialized instance
343+
CreateUpdateSchedulePayload instance =
344+
thisAdapter.fromJsonTree(jsonObj);
345+
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
346+
if (!openapiFields.contains(entry.getKey())) {
347+
if (entry.getValue().isJsonPrimitive()) { // primitive type
348+
if (entry.getValue().getAsJsonPrimitive().isString())
349+
instance.putAdditionalProperty(
350+
entry.getKey(), entry.getValue().getAsString());
351+
else if (entry.getValue().getAsJsonPrimitive().isNumber())
352+
instance.putAdditionalProperty(
353+
entry.getKey(), entry.getValue().getAsNumber());
354+
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
355+
instance.putAdditionalProperty(
356+
entry.getKey(),
357+
entry.getValue().getAsBoolean());
358+
else
359+
throw new IllegalArgumentException(
360+
String.format(
361+
"The field `%s` has unknown primitive type. Value: %s",
362+
entry.getKey(),
363+
entry.getValue().toString()));
364+
} else if (entry.getValue().isJsonArray()) {
365+
instance.putAdditionalProperty(
366+
entry.getKey(),
367+
gson.fromJson(entry.getValue(), List.class));
368+
} else { // JSON object
369+
instance.putAdditionalProperty(
370+
entry.getKey(),
371+
gson.fromJson(entry.getValue(), HashMap.class));
372+
}
373+
}
374+
}
375+
return instance;
278376
}
279377
}.nullSafe();
280378
}

0 commit comments

Comments
 (0)