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
4 changes: 2 additions & 2 deletions services/serverupdate/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ 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.6'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'
implementation 'org.openapitools:jackson-databind-nullable:0.2.8'
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'
testImplementation 'org.mockito:mockito-core:3.12.4'
Expand Down
2 changes: 1 addition & 1 deletion services/serverupdate/oas_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ed4e4fbee2f5db4d95725108fb3d736e5363fb2f
4ba9d6ffcf1ec61aff0807a261f8c0ca25d266f8
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class ApiClient {
protected InputStream sslCaCert;
protected boolean verifyingSsl;
protected KeyManager[] keyManagers;
protected String tlsServerName;

protected OkHttpClient httpClient;
protected JSON json;
Expand Down Expand Up @@ -189,8 +190,8 @@ public String getBasePath() {
/**
* Set base path
*
* @param basePath Base path of the URL (e.g https://server-update.api.stackit.cloud
* @return An instance of OkHttpClient
* @param basePath Base path of the URL (e.g https://server-update.api.stackit.cloud)
* @return An instance of ApiClient
*/
public ApiClient setBasePath(String basePath) {
this.basePath = basePath;
Expand Down Expand Up @@ -321,6 +322,28 @@ public ApiClient setKeyManagers(KeyManager[] managers) {
return this;
}

/**
* Get TLS server name for SNI (Server Name Indication).
*
* @return The TLS server name
*/
public String getTlsServerName() {
return tlsServerName;
}

/**
* Set TLS server name for SNI (Server Name Indication). This is used to verify the server
* certificate against a specific hostname instead of the hostname in the URL.
*
* @param tlsServerName The TLS server name to use for certificate verification
* @return ApiClient
*/
public ApiClient setTlsServerName(String tlsServerName) {
this.tlsServerName = tlsServerName;
applySslSettings();
return this;
}

/**
* Getter for the field <code>dateFormat</code>.
*
Expand Down Expand Up @@ -605,7 +628,7 @@ public List<Pair> parameterToPair(String name, Object value) {
* @param value The value of the parameter.
* @return A list of {@code Pair} objects.
*/
public List<Pair> parameterToPairs(String collectionFormat, String name, Collection value) {
public List<Pair> parameterToPairs(String collectionFormat, String name, Collection<?> value) {
List<Pair> params = new ArrayList<Pair>();

// preconditions
Expand Down Expand Up @@ -827,7 +850,17 @@ public <T> T deserialize(Response response, Type returnType) throws ApiException
}
try {
if (isJsonMime(contentType)) {
return JSON.deserialize(respBody.byteStream(), returnType);
if (returnType.equals(String.class)) {
String respBodyString = respBody.string();
if (respBodyString.isEmpty()) {
return null;
}
// Use String-based deserialize for String return type with fallback
return JSON.deserialize(respBodyString, returnType);
} else {
// Use InputStream-based deserialize which supports responses > 2GB
return JSON.deserialize(respBody.byteStream(), returnType);
}
} else if (returnType.equals(String.class)) {
String respBodyString = respBody.string();
if (respBodyString.isEmpty()) {
Expand Down Expand Up @@ -1227,8 +1260,10 @@ public String buildUrl(
if (serverIndex < 0 || serverIndex >= servers.size()) {
throw new ArrayIndexOutOfBoundsException(
String.format(
java.util.Locale.ROOT,
"Invalid index %d when selecting the host settings. Must be less than %d",
serverIndex, servers.size()));
serverIndex,
servers.size()));
}
baseURL = servers.get(serverIndex).URL(serverVariables);
} else {
Expand Down Expand Up @@ -1302,12 +1337,16 @@ public void processHeaderParams(Map<String, String> headerParams, Request.Builde
public void processCookieParams(Map<String, String> cookieParams, Request.Builder reqBuilder) {
for (Entry<String, String> param : cookieParams.entrySet()) {
reqBuilder.addHeader(
"Cookie", String.format("%s=%s", param.getKey(), param.getValue()));
"Cookie",
String.format(
java.util.Locale.ROOT, "%s=%s", param.getKey(), param.getValue()));
}
for (Entry<String, String> param : defaultCookieMap.entrySet()) {
if (!cookieParams.containsKey(param.getKey())) {
reqBuilder.addHeader(
"Cookie", String.format("%s=%s", param.getKey(), param.getValue()));
"Cookie",
String.format(
java.util.Locale.ROOT, "%s=%s", param.getKey(), param.getValue()));
}
}
}
Expand Down Expand Up @@ -1495,7 +1534,20 @@ public boolean verify(String hostname, SSLSession session) {
trustManagerFactory.init(caKeyStore);
}
trustManagers = trustManagerFactory.getTrustManagers();
hostnameVerifier = OkHostnameVerifier.INSTANCE;
if (tlsServerName != null && !tlsServerName.isEmpty()) {
hostnameVerifier =
new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
// Verify the certificate against tlsServerName instead of the
// actual hostname
return OkHostnameVerifier.INSTANCE.verify(
tlsServerName, session);
}
};
} else {
hostnameVerifier = OkHostnameVerifier.INSTANCE;
}
}

SSLContext sslContext = SSLContext.getInstance("TLS");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.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 @@ -17,7 +17,7 @@
/** Representing a Server configuration. */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.0")
public class ServerConfiguration {
public String URL;
public String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/** Representing a Server Variable for server URL template substitution. */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.0")
public class ServerVariable {
public String description;
public String defaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.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 @@ -18,7 +18,7 @@
/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.0")
public abstract class AbstractOpenApiSchema {

// store the actual instance of the schema/object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/** CreateUpdatePayload */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.0")
public class CreateUpdatePayload {
public static final String SERIALIZED_NAME_BACKUP_BEFORE_UPDATE = "backupBeforeUpdate";

Expand Down Expand Up @@ -203,6 +203,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The required field(s) %s in CreateUpdatePayload is not found in the empty JSON string",
CreateUpdatePayload.openapiRequiredFields.toString()));
}
Expand All @@ -213,8 +214,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The required field `%s` is not found in the JSON string: %s",
requiredField, jsonElement.toString()));
requiredField,
jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
Expand Down Expand Up @@ -287,6 +290,7 @@ else if (entry.getValue().getAsJsonPrimitive().isBoolean())
else
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The field `%s` has unknown primitive type. Value: %s",
entry.getKey(),
entry.getValue().toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/** CreateUpdateSchedulePayload */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.0")
public class CreateUpdateSchedulePayload {
public static final String SERIALIZED_NAME_ENABLED = "enabled";

Expand Down Expand Up @@ -260,6 +260,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The required field(s) %s in CreateUpdateSchedulePayload is not found in the empty JSON string",
CreateUpdateSchedulePayload.openapiRequiredFields.toString()));
}
Expand All @@ -270,20 +271,24 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The required field `%s` is not found in the JSON string: %s",
requiredField, jsonElement.toString()));
requiredField,
jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if (!jsonObj.get("name").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `name` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("name").toString()));
}
if (!jsonObj.get("rrule").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `rrule` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("rrule").toString()));
}
Expand Down Expand Up @@ -358,6 +363,7 @@ else if (entry.getValue().getAsJsonPrimitive().isBoolean())
else
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The field `%s` has unknown primitive type. Value: %s",
entry.getKey(),
entry.getValue().toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/** EnableServiceResourcePayload */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.0")
public class EnableServiceResourcePayload {
public static final String SERIALIZED_NAME_UPDATE_POLICY_ID = "updatePolicyId";

Expand Down Expand Up @@ -174,6 +174,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The required field(s) %s in EnableServiceResourcePayload is not found in the empty JSON string",
EnableServiceResourcePayload.openapiRequiredFields.toString()));
}
Expand All @@ -183,6 +184,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
&& !jsonObj.get("updatePolicyId").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `updatePolicyId` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("updatePolicyId").toString()));
}
Expand Down Expand Up @@ -258,6 +260,7 @@ else if (entry.getValue().getAsJsonPrimitive().isBoolean())
else
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The field `%s` has unknown primitive type. Value: %s",
entry.getKey(),
entry.getValue().toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/** ErrorResponse */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.0")
public class ErrorResponse {
public static final String SERIALIZED_NAME_MESSAGE = "message";

Expand Down Expand Up @@ -197,6 +197,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The required field(s) %s in ErrorResponse is not found in the empty JSON string",
ErrorResponse.openapiRequiredFields.toString()));
}
Expand All @@ -207,20 +208,24 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The required field `%s` is not found in the JSON string: %s",
requiredField, jsonElement.toString()));
requiredField,
jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if (!jsonObj.get("message").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `message` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("message").toString()));
}
if (!jsonObj.get("status").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `status` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("status").toString()));
}
Expand Down Expand Up @@ -292,6 +297,7 @@ else if (entry.getValue().getAsJsonPrimitive().isBoolean())
else
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The field `%s` has unknown primitive type. Value: %s",
entry.getKey(),
entry.getValue().toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/** GetUpdatePoliciesResponse */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.15.0")
comments = "Generator version: 7.19.0")
public class GetUpdatePoliciesResponse {
public static final String SERIALIZED_NAME_ITEMS = "items";

Expand Down Expand Up @@ -179,6 +179,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The required field(s) %s in GetUpdatePoliciesResponse is not found in the empty JSON string",
GetUpdatePoliciesResponse.openapiRequiredFields.toString()));
}
Expand All @@ -191,6 +192,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
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()));
}
Expand Down Expand Up @@ -272,6 +274,7 @@ else if (entry.getValue().getAsJsonPrimitive().isBoolean())
else
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The field `%s` has unknown primitive type. Value: %s",
entry.getKey(),
entry.getValue().toString()));
Expand Down
Loading