Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion services/iaas/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'io.gsonfire:gson-fire:1.9.0'
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6'
implementation 'org.openapitools:jackson-databind-nullable:0.2.8'
implementation 'org.openapitools:jackson-databind-nullable:0.2.12'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0'
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
Expand Down
2 changes: 1 addition & 1 deletion services/iaas/oas_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
43a874547d9e5b23655d0f351c47b32b46d4a19e
c2afb47c530277ab9289d3d54cc32a606a28fd4b
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,17 @@ public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
return this;
}

/**
* Set LocalDateTimeFormat.
*
* @param dateFormat a {@link java.time.format.DateTimeFormatter} object
* @return a {@link cloud.stackit.sdk.iaas.v1api.ApiClient} object
*/
public ApiClient setLocalDateTimeFormat(DateTimeFormatter dateFormat) {
JSON.setLocalDateTimeFormat(dateFormat);
return this;
}

/**
* Set LenientOnJson.
*
Expand Down Expand Up @@ -598,6 +609,46 @@ public String parameterToString(Object param) {
}
}

/**
* Format the given parameter object as an ASCII-safe JSON string.
*
* @param param Parameter
* @return JSON representation of the parameter
*/
public String parameterToJsonString(Object param) {
if (param == null) {
return "";
}
String json = JSON.serialize(param);
int firstUnsafe = -1;
for (int i = 0; i < json.length(); i++) {
if (json.charAt(i) >= 0x7f) {
firstUnsafe = i;
break;
}
}
if (firstUnsafe == -1) {
return json;
}

StringBuilder escaped = new StringBuilder(json.length());
escaped.append(json, 0, firstUnsafe);
for (int i = firstUnsafe; i < json.length(); i++) {
char c = json.charAt(i);
if (c >= 0x7f) {
escaped.append("\\u");
escaped.append(Character.forDigit((c >> 12) & 0xf, 16));
escaped.append(Character.forDigit((c >> 8) & 0xf, 16));
escaped.append(Character.forDigit((c >> 4) & 0xf, 16));
escaped.append(Character.forDigit(c & 0xf, 16));
} else {
escaped.append(c);
}
}

return escaped.toString();
}

/**
* Formats the specified query parameter to a list containing a single {@code Pair} object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Date;
import java.util.Map;
import okio.ByteString;
Expand All @@ -51,6 +53,8 @@ public class JSON {
private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter =
new OffsetDateTimeTypeAdapter();
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private static LocalDateTimeTypeAdapter localDateTimeTypeAdapter =
new LocalDateTimeTypeAdapter();
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -94,6 +98,7 @@ private static Class getClassByDiscriminator(
gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter);
gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter);
gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter);
gsonBuilder.registerTypeAdapter(LocalDateTime.class, localDateTimeTypeAdapter);
gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter);
gsonBuilder.registerTypeAdapterFactory(
new cloud.stackit.sdk.iaas.v1api.model.AddVolumeToServerPayload
Expand Down Expand Up @@ -619,6 +624,53 @@ public LocalDate read(JsonReader in) throws IOException {
}
}

/** Gson TypeAdapter for JSR310 LocalDateTime type */
public static class LocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> {

private DateTimeFormatter formatter;

public LocalDateTimeTypeAdapter() {
this(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
}

public LocalDateTimeTypeAdapter(DateTimeFormatter formatter) {
this.formatter = formatter;
}

public void setFormat(DateTimeFormatter dateFormat) {
this.formatter = dateFormat;
}

@Override
public void write(JsonWriter out, LocalDateTime date) throws IOException {
if (date == null) {
out.nullValue();
} else {
out.value(formatter.format(date));
}
}

@Override
public LocalDateTime read(JsonReader in) throws IOException {
switch (in.peek()) {
case NULL:
in.nextNull();
return null;
default:
String date = in.nextString();
try {
return LocalDateTime.parse(date, formatter);
} catch (DateTimeParseException e) {
if (date.length() > 10 && date.charAt(10) == ' ') {
date = date.substring(0, 10) + 'T' + date.substring(11);
return LocalDateTime.parse(date, formatter);
}
throw e;
}
}
}
}

public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
offsetDateTimeTypeAdapter.setFormat(dateFormat);
}
Expand All @@ -627,6 +679,10 @@ public static void setLocalDateFormat(DateTimeFormatter dateFormat) {
localDateTypeAdapter.setFormat(dateFormat);
}

public static void setLocalDateTimeFormat(DateTimeFormatter dateFormat) {
localDateTimeTypeAdapter.setFormat(dateFormat);
}

/**
* Gson TypeAdapter for java.sql.Date type If the dateFormat is null, a simple "yyyy-MM-dd"
* format will be used (more efficient than SimpleDateFormat).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

package cloud.stackit.sdk.iaas.v1api;

@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class Pair {
private final String name;
private final String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Map;

/** Representing a Server configuration. */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class ServerConfiguration {
public String URL;
public String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.HashSet;

/** Representing a Server Variable for server URL template substitution. */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class ServerVariable {
public String description;
public String defaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Collection;
import java.util.Iterator;

@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Objects;

/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public abstract class AbstractOpenApiSchema {

// store the actual instance of the schema/object
Expand Down Expand Up @@ -104,10 +104,7 @@ public String toString() {
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
return o == null ? "null" : o.toString().replace("\n", "\n ");
}

public boolean equals(Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import cloud.stackit.sdk.iaas.v1api.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
Expand All @@ -32,7 +33,7 @@
import java.util.UUID;

/** Object that represents a Volume attachment to a server. */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class AddVolumeToServerPayload {
public static final String SERIALIZED_NAME_DELETE_ON_TERMINATION = "deleteOnTermination";

Expand Down Expand Up @@ -181,10 +182,7 @@ public String toString() {
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
return o == null ? "null" : o.toString().replace("\n", "\n ");
}

public static HashSet<String> openapiFields;
Expand Down Expand Up @@ -269,7 +267,9 @@ else if (entry.getValue() instanceof Character)
entry.getKey(), (Character) entry.getValue());
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
if (jsonElement.isJsonNull()) {
obj.add(entry.getKey(), JsonNull.INSTANCE);
} else if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import cloud.stackit.sdk.iaas.v1api.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
Expand All @@ -33,7 +34,7 @@
import java.util.UUID;

/** Definition of an affinity group. */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class AffinityGroup {
public static final String SERIALIZED_NAME_ID = "id";

Expand Down Expand Up @@ -212,10 +213,7 @@ public String toString() {
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
return o == null ? "null" : o.toString().replace("\n", "\n ");
}

public static HashSet<String> openapiFields;
Expand Down Expand Up @@ -325,7 +323,9 @@ else if (entry.getValue() instanceof Character)
entry.getKey(), (Character) entry.getValue());
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
if (jsonElement.isJsonNull()) {
obj.add(entry.getKey(), JsonNull.INSTANCE);
} else if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
Expand All @@ -33,7 +34,7 @@
import java.util.Objects;

/** Response object for affinity group list request. */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class AffinityGroupListResponse {
public static final String SERIALIZED_NAME_ITEMS = "items";

Expand Down Expand Up @@ -150,10 +151,7 @@ public String toString() {
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
return o == null ? "null" : o.toString().replace("\n", "\n ");
}

public static HashSet<String> openapiFields;
Expand Down Expand Up @@ -197,21 +195,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the json data is an array
if (!jsonObj.get("items").isJsonArray()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `items` to be an array in the JSON string but got `%s`",
jsonObj.get("items").toString()));
}

JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items");
// validate the required field `items` (array)
for (int i = 0; i < jsonArrayitems.size(); i++) {
AffinityGroup.validateJsonElement(jsonArrayitems.get(i));
if (jsonObj.get("items") != null) {
if (!jsonObj.get("items").isJsonArray()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `items` to be an array in the JSON string but got `%s`",
jsonObj.get("items").toString()));
}
JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items");
// validate the required field `items` (array)
for (int i = 0; i < jsonArrayitems.size(); i++) {
AffinityGroup.validateJsonElement(jsonArrayitems.get(i));
}
}
;
}

public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
Expand Down Expand Up @@ -248,7 +245,9 @@ else if (entry.getValue() instanceof Character)
entry.getKey(), (Character) entry.getValue());
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
if (jsonElement.isJsonNull()) {
obj.add(entry.getKey(), JsonNull.INSTANCE);
} else if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class AllowedAddressesInner extends AbstractOpenApiSchema {
private static final Logger log = Logger.getLogger(AllowedAddressesInner.class.getName());

Expand Down Expand Up @@ -174,6 +174,7 @@ public Object getActualInstance() {
* @return The actual instance of `String`
* @throws ClassCastException if the instance is not `String`
*/
@SuppressWarnings("unchecked")
public String getString() throws ClassCastException {
return (String) super.getActualInstance();
}
Expand Down
Loading
Loading