Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/loadbalancer/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/loadbalancer/oas_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f5a2c1cbdac2b440d8dc8bfa89af5ca4cd9cc89d
1cb7803383991935e2278722c995a222c96aa43a
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.loadbalancer.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.loadbalancer.v1api.model.ActiveHealthCheck
Expand Down Expand Up @@ -387,6 +392,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 @@ -395,6 +447,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.loadbalancer.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.loadbalancer.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 @@ -31,7 +32,7 @@
import java.util.Objects;

/** ActiveHealthCheck */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class ActiveHealthCheck {
public static final String SERIALIZED_NAME_HEALTHY_THRESHOLD = "healthyThreshold";

Expand Down Expand Up @@ -247,10 +248,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 @@ -348,7 +346,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.loadbalancer.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 @@ -31,7 +32,7 @@
import java.util.Objects;

/** CreateCredentialsPayload */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class CreateCredentialsPayload {
public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName";

Expand Down Expand Up @@ -188,10 +189,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 @@ -283,7 +281,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.loadbalancer.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 @@ -31,7 +32,7 @@
import java.util.Objects;

/** CreateCredentialsResponse */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class CreateCredentialsResponse {
public static final String SERIALIZED_NAME_CREDENTIAL = "credential";

Expand Down Expand Up @@ -139,10 +140,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 @@ -214,7 +212,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 @@ -34,7 +35,7 @@
import java.util.Objects;

/** CreateLoadBalancerPayload */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class CreateLoadBalancerPayload {
public static final String SERIALIZED_NAME_ERRORS = "errors";

Expand Down Expand Up @@ -492,10 +493,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 @@ -708,7 +706,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
Loading
Loading