Skip to content

Commit 373bb70

Browse files
Generator: Update SDK /services/objectstorage (#272)
1 parent e83b74f commit 373bb70

24 files changed

+2230
-301
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
## Release (2026-MM-DD)
2+
- `objectstorage`: [v0.1.2](services/objectstorage/CHANGELOG.md#v012)
3+
- **Improvement:** Support additional properties in models
24
- `resourcemanager`: [v0.4.2](services/resourcemanager/CHANGELOG.md#v042)
35
- **Improvement:** Support additional properties in models
46
- `serverbackup`: [v0.1.1](services/serverbackup/CHANGELOG.md#v011)

services/objectstorage/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/objectstorage/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/objectstorage/oas_commit

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

services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/model/AccessKey.java

Lines changed: 110 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
/** AccessKey */
3334
@javax.annotation.Generated(
@@ -111,6 +112,50 @@ public void setKeyId(@javax.annotation.Nonnull String keyId) {
111112
this.keyId = keyId;
112113
}
113114

115+
/**
116+
* A container for additional, undeclared properties. This is a holder for any undeclared
117+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
118+
*/
119+
private Map<String, Object> additionalProperties;
120+
121+
/**
122+
* Set the additional (undeclared) property with the specified name and value. If the property
123+
* does not already exist, create it otherwise replace it.
124+
*
125+
* @param key name of the property
126+
* @param value value of the property
127+
* @return the AccessKey instance itself
128+
*/
129+
public AccessKey putAdditionalProperty(String key, Object value) {
130+
if (this.additionalProperties == null) {
131+
this.additionalProperties = new HashMap<String, Object>();
132+
}
133+
this.additionalProperties.put(key, value);
134+
return this;
135+
}
136+
137+
/**
138+
* Return the additional (undeclared) property.
139+
*
140+
* @return a map of objects
141+
*/
142+
public Map<String, Object> getAdditionalProperties() {
143+
return additionalProperties;
144+
}
145+
146+
/**
147+
* Return the additional (undeclared) property with the specified name.
148+
*
149+
* @param key name of the property
150+
* @return an object
151+
*/
152+
public Object getAdditionalProperty(String key) {
153+
if (this.additionalProperties == null) {
154+
return null;
155+
}
156+
return this.additionalProperties.get(key);
157+
}
158+
114159
@Override
115160
public boolean equals(Object o) {
116161
if (this == o) {
@@ -122,12 +167,13 @@ public boolean equals(Object o) {
122167
AccessKey accessKey = (AccessKey) o;
123168
return Objects.equals(this.displayName, accessKey.displayName)
124169
&& Objects.equals(this.expires, accessKey.expires)
125-
&& Objects.equals(this.keyId, accessKey.keyId);
170+
&& Objects.equals(this.keyId, accessKey.keyId)
171+
&& Objects.equals(this.additionalProperties, accessKey.additionalProperties);
126172
}
127173

128174
@Override
129175
public int hashCode() {
130-
return Objects.hash(displayName, expires, keyId);
176+
return Objects.hash(displayName, expires, keyId, additionalProperties);
131177
}
132178

133179
@Override
@@ -137,6 +183,9 @@ public String toString() {
137183
sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n");
138184
sb.append(" expires: ").append(toIndentedString(expires)).append("\n");
139185
sb.append(" keyId: ").append(toIndentedString(keyId)).append("\n");
186+
sb.append(" additionalProperties: ")
187+
.append(toIndentedString(additionalProperties))
188+
.append("\n");
140189
sb.append("}");
141190
return sb.toString();
142191
}
@@ -181,17 +230,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
181230
}
182231
}
183232

184-
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
185-
// check to see if the JSON string contains additional fields
186-
for (Map.Entry<String, JsonElement> entry : entries) {
187-
if (!AccessKey.openapiFields.contains(entry.getKey())) {
188-
throw new IllegalArgumentException(
189-
String.format(
190-
"The field `%s` in the JSON string is not defined in the `AccessKey` properties. JSON: %s",
191-
entry.getKey(), jsonElement.toString()));
192-
}
193-
}
194-
195233
// check to make sure all required properties/fields are present in the JSON string
196234
for (String requiredField : AccessKey.openapiRequiredFields) {
197235
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
@@ -238,14 +276,71 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
238276
@Override
239277
public void write(JsonWriter out, AccessKey value) throws IOException {
240278
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
279+
obj.remove("additionalProperties");
280+
// serialize additional properties
281+
if (value.getAdditionalProperties() != null) {
282+
for (Map.Entry<String, Object> entry :
283+
value.getAdditionalProperties().entrySet()) {
284+
if (entry.getValue() instanceof String)
285+
obj.addProperty(entry.getKey(), (String) entry.getValue());
286+
else if (entry.getValue() instanceof Number)
287+
obj.addProperty(entry.getKey(), (Number) entry.getValue());
288+
else if (entry.getValue() instanceof Boolean)
289+
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
290+
else if (entry.getValue() instanceof Character)
291+
obj.addProperty(
292+
entry.getKey(), (Character) entry.getValue());
293+
else {
294+
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
295+
if (jsonElement.isJsonArray()) {
296+
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
297+
} else {
298+
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
299+
}
300+
}
301+
}
302+
}
241303
elementAdapter.write(out, obj);
242304
}
243305

244306
@Override
245307
public AccessKey read(JsonReader in) throws IOException {
246308
JsonElement jsonElement = elementAdapter.read(in);
247309
validateJsonElement(jsonElement);
248-
return thisAdapter.fromJsonTree(jsonElement);
310+
JsonObject jsonObj = jsonElement.getAsJsonObject();
311+
// store additional fields in the deserialized instance
312+
AccessKey instance = thisAdapter.fromJsonTree(jsonObj);
313+
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
314+
if (!openapiFields.contains(entry.getKey())) {
315+
if (entry.getValue().isJsonPrimitive()) { // primitive type
316+
if (entry.getValue().getAsJsonPrimitive().isString())
317+
instance.putAdditionalProperty(
318+
entry.getKey(), entry.getValue().getAsString());
319+
else if (entry.getValue().getAsJsonPrimitive().isNumber())
320+
instance.putAdditionalProperty(
321+
entry.getKey(), entry.getValue().getAsNumber());
322+
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
323+
instance.putAdditionalProperty(
324+
entry.getKey(),
325+
entry.getValue().getAsBoolean());
326+
else
327+
throw new IllegalArgumentException(
328+
String.format(
329+
"The field `%s` has unknown primitive type. Value: %s",
330+
entry.getKey(),
331+
entry.getValue().toString()));
332+
} else if (entry.getValue().isJsonArray()) {
333+
instance.putAdditionalProperty(
334+
entry.getKey(),
335+
gson.fromJson(entry.getValue(), List.class));
336+
} else { // JSON object
337+
instance.putAdditionalProperty(
338+
entry.getKey(),
339+
gson.fromJson(entry.getValue(), HashMap.class));
340+
}
341+
}
342+
}
343+
return instance;
249344
}
250345
}.nullSafe();
251346
}

services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/model/Bucket.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
/** Bucket */
3334
@javax.annotation.Generated(
@@ -136,6 +137,50 @@ public void setUrlVirtualHostedStyle(@javax.annotation.Nonnull String urlVirtual
136137
this.urlVirtualHostedStyle = urlVirtualHostedStyle;
137138
}
138139

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

154200
@Override
155201
public int hashCode() {
156-
return Objects.hash(name, region, urlPathStyle, urlVirtualHostedStyle);
202+
return Objects.hash(
203+
name, region, urlPathStyle, urlVirtualHostedStyle, additionalProperties);
157204
}
158205

159206
@Override
@@ -166,6 +213,9 @@ public String toString() {
166213
sb.append(" urlVirtualHostedStyle: ")
167214
.append(toIndentedString(urlVirtualHostedStyle))
168215
.append("\n");
216+
sb.append(" additionalProperties: ")
217+
.append(toIndentedString(additionalProperties))
218+
.append("\n");
169219
sb.append("}");
170220
return sb.toString();
171221
}
@@ -213,17 +263,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
213263
}
214264
}
215265

216-
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
217-
// check to see if the JSON string contains additional fields
218-
for (Map.Entry<String, JsonElement> entry : entries) {
219-
if (!Bucket.openapiFields.contains(entry.getKey())) {
220-
throw new IllegalArgumentException(
221-
String.format(
222-
"The field `%s` in the JSON string is not defined in the `Bucket` properties. JSON: %s",
223-
entry.getKey(), jsonElement.toString()));
224-
}
225-
}
226-
227266
// check to make sure all required properties/fields are present in the JSON string
228267
for (String requiredField : Bucket.openapiRequiredFields) {
229268
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
@@ -276,14 +315,71 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
276315
@Override
277316
public void write(JsonWriter out, Bucket value) throws IOException {
278317
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
318+
obj.remove("additionalProperties");
319+
// serialize additional properties
320+
if (value.getAdditionalProperties() != null) {
321+
for (Map.Entry<String, Object> entry :
322+
value.getAdditionalProperties().entrySet()) {
323+
if (entry.getValue() instanceof String)
324+
obj.addProperty(entry.getKey(), (String) entry.getValue());
325+
else if (entry.getValue() instanceof Number)
326+
obj.addProperty(entry.getKey(), (Number) entry.getValue());
327+
else if (entry.getValue() instanceof Boolean)
328+
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
329+
else if (entry.getValue() instanceof Character)
330+
obj.addProperty(
331+
entry.getKey(), (Character) entry.getValue());
332+
else {
333+
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
334+
if (jsonElement.isJsonArray()) {
335+
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
336+
} else {
337+
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
338+
}
339+
}
340+
}
341+
}
279342
elementAdapter.write(out, obj);
280343
}
281344

282345
@Override
283346
public Bucket read(JsonReader in) throws IOException {
284347
JsonElement jsonElement = elementAdapter.read(in);
285348
validateJsonElement(jsonElement);
286-
return thisAdapter.fromJsonTree(jsonElement);
349+
JsonObject jsonObj = jsonElement.getAsJsonObject();
350+
// store additional fields in the deserialized instance
351+
Bucket instance = thisAdapter.fromJsonTree(jsonObj);
352+
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
353+
if (!openapiFields.contains(entry.getKey())) {
354+
if (entry.getValue().isJsonPrimitive()) { // primitive type
355+
if (entry.getValue().getAsJsonPrimitive().isString())
356+
instance.putAdditionalProperty(
357+
entry.getKey(), entry.getValue().getAsString());
358+
else if (entry.getValue().getAsJsonPrimitive().isNumber())
359+
instance.putAdditionalProperty(
360+
entry.getKey(), entry.getValue().getAsNumber());
361+
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
362+
instance.putAdditionalProperty(
363+
entry.getKey(),
364+
entry.getValue().getAsBoolean());
365+
else
366+
throw new IllegalArgumentException(
367+
String.format(
368+
"The field `%s` has unknown primitive type. Value: %s",
369+
entry.getKey(),
370+
entry.getValue().toString()));
371+
} else if (entry.getValue().isJsonArray()) {
372+
instance.putAdditionalProperty(
373+
entry.getKey(),
374+
gson.fromJson(entry.getValue(), List.class));
375+
} else { // JSON object
376+
instance.putAdditionalProperty(
377+
entry.getKey(),
378+
gson.fromJson(entry.getValue(), HashMap.class));
379+
}
380+
}
381+
}
382+
return instance;
287383
}
288384
}.nullSafe();
289385
}

0 commit comments

Comments
 (0)