11/*
2- * STACKIT Object Storage API
3- * STACKIT API to manage the Object Storage
2+ * [DEPRECATED] STACKIT Object Storage API
3+ * ## ⚠️ WARNING: THIS API IS DEPRECATED Use V2
44 *
55 * The version of the OpenAPI document: 1.1.0
66 *
3131import java .text .ParseException ;
3232import java .text .ParsePosition ;
3333import java .time .LocalDate ;
34+ import java .time .LocalDateTime ;
3435import java .time .OffsetDateTime ;
3536import java .time .format .DateTimeFormatter ;
37+ import java .time .format .DateTimeParseException ;
3638import java .util .Date ;
3739import java .util .Map ;
3840import 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 .objectstorage .v1api .model .AccessKey
@@ -175,6 +180,9 @@ private static Class getClassByDiscriminator(
175180 gsonBuilder .registerTypeAdapterFactory (
176181 new cloud .stackit .sdk .objectstorage .v1api .model .SetDefaultRetentionPayload
177182 .CustomTypeAdapterFactory ());
183+ gsonBuilder .registerTypeAdapterFactory (
184+ new cloud .stackit .sdk .objectstorage .v1api .model .UpdateServicePayload
185+ .CustomTypeAdapterFactory ());
178186 gsonBuilder .registerTypeAdapterFactory (
179187 new cloud .stackit .sdk .objectstorage .v1api .model .ValidationError
180188 .CustomTypeAdapterFactory ());
@@ -375,6 +383,53 @@ public LocalDate read(JsonReader in) throws IOException {
375383 }
376384 }
377385
386+ /** Gson TypeAdapter for JSR310 LocalDateTime type */
387+ public static class LocalDateTimeTypeAdapter extends TypeAdapter <LocalDateTime > {
388+
389+ private DateTimeFormatter formatter ;
390+
391+ public LocalDateTimeTypeAdapter () {
392+ this (DateTimeFormatter .ISO_LOCAL_DATE_TIME );
393+ }
394+
395+ public LocalDateTimeTypeAdapter (DateTimeFormatter formatter ) {
396+ this .formatter = formatter ;
397+ }
398+
399+ public void setFormat (DateTimeFormatter dateFormat ) {
400+ this .formatter = dateFormat ;
401+ }
402+
403+ @ Override
404+ public void write (JsonWriter out , LocalDateTime date ) throws IOException {
405+ if (date == null ) {
406+ out .nullValue ();
407+ } else {
408+ out .value (formatter .format (date ));
409+ }
410+ }
411+
412+ @ Override
413+ public LocalDateTime read (JsonReader in ) throws IOException {
414+ switch (in .peek ()) {
415+ case NULL :
416+ in .nextNull ();
417+ return null ;
418+ default :
419+ String date = in .nextString ();
420+ try {
421+ return LocalDateTime .parse (date , formatter );
422+ } catch (DateTimeParseException e ) {
423+ if (date .length () > 10 && date .charAt (10 ) == ' ' ) {
424+ date = date .substring (0 , 10 ) + 'T' + date .substring (11 );
425+ return LocalDateTime .parse (date , formatter );
426+ }
427+ throw e ;
428+ }
429+ }
430+ }
431+ }
432+
378433 public static void setOffsetDateTimeFormat (DateTimeFormatter dateFormat ) {
379434 offsetDateTimeTypeAdapter .setFormat (dateFormat );
380435 }
@@ -383,6 +438,10 @@ public static void setLocalDateFormat(DateTimeFormatter dateFormat) {
383438 localDateTypeAdapter .setFormat (dateFormat );
384439 }
385440
441+ public static void setLocalDateTimeFormat (DateTimeFormatter dateFormat ) {
442+ localDateTimeTypeAdapter .setFormat (dateFormat );
443+ }
444+
386445 /**
387446 * Gson TypeAdapter for java.sql.Date type If the dateFormat is null, a simple "yyyy-MM-dd"
388447 * format will be used (more efficient than SimpleDateFormat).
0 commit comments