Skip to content

Commit a4565af

Browse files
Generate alb
1 parent 4798168 commit a4565af

49 files changed

Lines changed: 385 additions & 251 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎services/alb/build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies {
1010
implementation 'com.google.code.gson:gson:2.9.1'
1111
implementation 'io.gsonfire:gson-fire:1.9.0'
1212
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6'
13-
implementation 'org.openapitools:jackson-databind-nullable:0.2.8'
13+
implementation 'org.openapitools:jackson-databind-nullable:0.2.12'
1414
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0'
1515
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
1616
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'

‎services/alb/oas_commit‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7651289307a7a9e2dc9947ef380df3c4ca80fa60
1+
c9fb47b3087043293b6f77e5d3b778784de27ef2

‎services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/ApiClient.java‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,17 @@ public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
397397
return this;
398398
}
399399

400+
/**
401+
* Set LocalDateTimeFormat.
402+
*
403+
* @param dateFormat a {@link java.time.format.DateTimeFormatter} object
404+
* @return a {@link cloud.stackit.sdk.alb.v2api.ApiClient} object
405+
*/
406+
public ApiClient setLocalDateTimeFormat(DateTimeFormatter dateFormat) {
407+
JSON.setLocalDateTimeFormat(dateFormat);
408+
return this;
409+
}
410+
400411
/**
401412
* Set LenientOnJson.
402413
*
@@ -597,6 +608,46 @@ public String parameterToString(Object param) {
597608
}
598609
}
599610

611+
/**
612+
* Format the given parameter object as an ASCII-safe JSON string.
613+
*
614+
* @param param Parameter
615+
* @return JSON representation of the parameter
616+
*/
617+
public String parameterToJsonString(Object param) {
618+
if (param == null) {
619+
return "";
620+
}
621+
String json = JSON.serialize(param);
622+
int firstUnsafe = -1;
623+
for (int i = 0; i < json.length(); i++) {
624+
if (json.charAt(i) >= 0x7f) {
625+
firstUnsafe = i;
626+
break;
627+
}
628+
}
629+
if (firstUnsafe == -1) {
630+
return json;
631+
}
632+
633+
StringBuilder escaped = new StringBuilder(json.length());
634+
escaped.append(json, 0, firstUnsafe);
635+
for (int i = firstUnsafe; i < json.length(); i++) {
636+
char c = json.charAt(i);
637+
if (c >= 0x7f) {
638+
escaped.append("\\u");
639+
escaped.append(Character.forDigit((c >> 12) & 0xf, 16));
640+
escaped.append(Character.forDigit((c >> 8) & 0xf, 16));
641+
escaped.append(Character.forDigit((c >> 4) & 0xf, 16));
642+
escaped.append(Character.forDigit(c & 0xf, 16));
643+
} else {
644+
escaped.append(c);
645+
}
646+
}
647+
648+
return escaped.toString();
649+
}
650+
600651
/**
601652
* Formats the specified query parameter to a list containing a single {@code Pair} object.
602653
*

‎services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/JSON.java‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
import java.text.ParseException;
3232
import java.text.ParsePosition;
3333
import java.time.LocalDate;
34+
import java.time.LocalDateTime;
3435
import java.time.OffsetDateTime;
3536
import java.time.format.DateTimeFormatter;
37+
import java.time.format.DateTimeParseException;
3638
import java.util.Date;
3739
import java.util.Map;
3840
import okio.ByteString;
@@ -51,6 +53,8 @@ public class JSON {
5153
private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter =
5254
new OffsetDateTimeTypeAdapter();
5355
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
56+
private static LocalDateTimeTypeAdapter localDateTimeTypeAdapter =
57+
new LocalDateTimeTypeAdapter();
5458
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
5559

5660
@SuppressWarnings("unchecked")
@@ -94,6 +98,7 @@ private static Class getClassByDiscriminator(
9498
gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter);
9599
gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter);
96100
gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter);
101+
gsonBuilder.registerTypeAdapter(LocalDateTime.class, localDateTimeTypeAdapter);
97102
gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter);
98103
gsonBuilder.registerTypeAdapterFactory(
99104
new cloud.stackit.sdk.alb.v2api.model.ActiveHealthCheck.CustomTypeAdapterFactory());
@@ -390,6 +395,53 @@ public LocalDate read(JsonReader in) throws IOException {
390395
}
391396
}
392397

398+
/** Gson TypeAdapter for JSR310 LocalDateTime type */
399+
public static class LocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> {
400+
401+
private DateTimeFormatter formatter;
402+
403+
public LocalDateTimeTypeAdapter() {
404+
this(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
405+
}
406+
407+
public LocalDateTimeTypeAdapter(DateTimeFormatter formatter) {
408+
this.formatter = formatter;
409+
}
410+
411+
public void setFormat(DateTimeFormatter dateFormat) {
412+
this.formatter = dateFormat;
413+
}
414+
415+
@Override
416+
public void write(JsonWriter out, LocalDateTime date) throws IOException {
417+
if (date == null) {
418+
out.nullValue();
419+
} else {
420+
out.value(formatter.format(date));
421+
}
422+
}
423+
424+
@Override
425+
public LocalDateTime read(JsonReader in) throws IOException {
426+
switch (in.peek()) {
427+
case NULL:
428+
in.nextNull();
429+
return null;
430+
default:
431+
String date = in.nextString();
432+
try {
433+
return LocalDateTime.parse(date, formatter);
434+
} catch (DateTimeParseException e) {
435+
if (date.length() > 10 && date.charAt(10) == ' ') {
436+
date = date.substring(0, 10) + 'T' + date.substring(11);
437+
return LocalDateTime.parse(date, formatter);
438+
}
439+
throw e;
440+
}
441+
}
442+
}
443+
}
444+
393445
public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
394446
offsetDateTimeTypeAdapter.setFormat(dateFormat);
395447
}
@@ -398,6 +450,10 @@ public static void setLocalDateFormat(DateTimeFormatter dateFormat) {
398450
localDateTypeAdapter.setFormat(dateFormat);
399451
}
400452

453+
public static void setLocalDateTimeFormat(DateTimeFormatter dateFormat) {
454+
localDateTimeTypeAdapter.setFormat(dateFormat);
455+
}
456+
401457
/**
402458
* Gson TypeAdapter for java.sql.Date type If the dateFormat is null, a simple "yyyy-MM-dd"
403459
* format will be used (more efficient than SimpleDateFormat).

‎services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/Pair.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
package cloud.stackit.sdk.alb.v2api;
1414

15-
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
15+
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
1616
public class Pair {
1717
private final String name;
1818
private final String value;

‎services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/ServerConfiguration.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.util.Map;
1616

1717
/** Representing a Server configuration. */
18-
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
18+
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
1919
public class ServerConfiguration {
2020
public String URL;
2121
public String description;

‎services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/ServerVariable.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.util.HashSet;
1616

1717
/** Representing a Server Variable for server URL template substitution. */
18-
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
18+
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
1919
public class ServerVariable {
2020
public String description;
2121
public String defaultValue;

‎services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/StringUtil.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.util.Collection;
1616
import java.util.Iterator;
1717

18-
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
18+
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
1919
public class StringUtil {
2020
/**
2121
* Check if the given array contains the given value (with case-insensitive comparison).

‎services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/model/AbstractOpenApiSchema.java‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.Objects;
1717

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

2222
// store the actual instance of the schema/object
@@ -104,10 +104,7 @@ public String toString() {
104104
* line).
105105
*/
106106
private String toIndentedString(Object o) {
107-
if (o == null) {
108-
return "null";
109-
}
110-
return o.toString().replace("\n", "\n ");
107+
return o == null ? "null" : o.toString().replace("\n", "\n ");
111108
}
112109

113110
public boolean equals(Object o) {

‎services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/model/ActiveHealthCheck.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import cloud.stackit.sdk.alb.v2api.JSON;
1616
import com.google.gson.Gson;
1717
import com.google.gson.JsonElement;
18+
import com.google.gson.JsonNull;
1819
import com.google.gson.JsonObject;
1920
import com.google.gson.TypeAdapter;
2021
import com.google.gson.TypeAdapterFactory;
@@ -31,7 +32,7 @@
3132
import java.util.Objects;
3233

3334
/** Set this to customize active health checks for targets in this pool. */
34-
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
35+
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
3536
public class ActiveHealthCheck {
3637
public static final String SERIALIZED_NAME_ALT_PORT = "altPort";
3738

@@ -300,10 +301,7 @@ public String toString() {
300301
* line).
301302
*/
302303
private String toIndentedString(Object o) {
303-
if (o == null) {
304-
return "null";
305-
}
306-
return o.toString().replace("\n", "\n ");
304+
return o == null ? "null" : o.toString().replace("\n", "\n ");
307305
}
308306

309307
public static HashSet<String> openapiFields;
@@ -408,7 +406,9 @@ else if (entry.getValue() instanceof Character)
408406
entry.getKey(), (Character) entry.getValue());
409407
else {
410408
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
411-
if (jsonElement.isJsonArray()) {
409+
if (jsonElement.isJsonNull()) {
410+
obj.add(entry.getKey(), JsonNull.INSTANCE);
411+
} else if (jsonElement.isJsonArray()) {
412412
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
413413
} else {
414414
obj.add(entry.getKey(), jsonElement.getAsJsonObject());

0 commit comments

Comments
 (0)