ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.531.4

This commit is contained in:
speakeasybot
2025-04-14 00:32:09 +00:00
parent dd781d1e27
commit 4b28ca3416
13 changed files with 237 additions and 68 deletions

View File

@@ -52,7 +52,7 @@ public class PlexAPI {
/**
* The full address of your Plex Server
*/
"https://10.10.10.47:32400",
"{protocol}://{ip}:{port}",
};
/**

View File

@@ -42,8 +42,8 @@ class SDKConfiguration {
} };
private static final String LANGUAGE = "java";
public static final String OPENAPI_DOC_VERSION = "0.0.3";
public static final String SDK_VERSION = "0.14.2";
public static final String GEN_VERSION = "2.566.5";
public static final String SDK_VERSION = "0.15.0";
public static final String GEN_VERSION = "2.570.4";
private static final String BASE_PACKAGE = "dev.plexapi.sdk";
public static final String USER_AGENT =
String.format("speakeasy-sdk/%s %s %s %s %s",

View File

@@ -12,7 +12,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
import dev.plexapi.sdk.utils.LazySingletonValue;
import dev.plexapi.sdk.utils.Utils;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.Long;
import java.lang.Override;
import java.lang.String;
@@ -127,10 +126,11 @@ public class GetAllLibrariesDirectory {
private boolean directory;
/**
* The number of seconds since the content was last changed relative to now.
* Timestamp (in seconds) representing the last time the content was modified.
* NOTE: Some Plex server have some absurd values for this field, like 8457612157633039800 so it should be int64
*/
@JsonProperty("contentChangedAt")
private int contentChangedAt;
private long contentChangedAt;
@JsonInclude(Include.NON_ABSENT)
@JsonProperty("hidden")
@@ -159,7 +159,7 @@ public class GetAllLibrariesDirectory {
@JsonProperty("scannedAt") long scannedAt,
@JsonProperty("content") boolean content,
@JsonProperty("directory") boolean directory,
@JsonProperty("contentChangedAt") int contentChangedAt,
@JsonProperty("contentChangedAt") long contentChangedAt,
@JsonProperty("hidden") Optional<? extends Hidden> hidden,
@JsonProperty("Location") List<GetAllLibrariesLocation> location) {
Utils.checkNotNull(allowSync, "allowSync");
@@ -224,7 +224,7 @@ public class GetAllLibrariesDirectory {
long scannedAt,
boolean content,
boolean directory,
int contentChangedAt,
long contentChangedAt,
List<GetAllLibrariesLocation> location) {
this(allowSync, art, composite, filters, refreshing, thumb, key, type, title, agent, scanner, language, uuid, updatedAt, Optional.empty(), scannedAt, content, directory, contentChangedAt, Optional.empty(), location);
}
@@ -368,10 +368,11 @@ public class GetAllLibrariesDirectory {
}
/**
* The number of seconds since the content was last changed relative to now.
* Timestamp (in seconds) representing the last time the content was modified.
* NOTE: Some Plex server have some absurd values for this field, like 8457612157633039800 so it should be int64
*/
@JsonIgnore
public int contentChangedAt() {
public long contentChangedAt() {
return contentChangedAt;
}
@@ -553,9 +554,10 @@ public class GetAllLibrariesDirectory {
}
/**
* The number of seconds since the content was last changed relative to now.
* Timestamp (in seconds) representing the last time the content was modified.
* NOTE: Some Plex server have some absurd values for this field, like 8457612157633039800 so it should be int64
*/
public GetAllLibrariesDirectory withContentChangedAt(int contentChangedAt) {
public GetAllLibrariesDirectory withContentChangedAt(long contentChangedAt) {
Utils.checkNotNull(contentChangedAt, "contentChangedAt");
this.contentChangedAt = contentChangedAt;
return this;
@@ -703,7 +705,7 @@ public class GetAllLibrariesDirectory {
private Boolean directory;
private Integer contentChangedAt;
private Long contentChangedAt;
private Optional<? extends Hidden> hidden;
@@ -876,9 +878,10 @@ public class GetAllLibrariesDirectory {
}
/**
* The number of seconds since the content was last changed relative to now.
* Timestamp (in seconds) representing the last time the content was modified.
* NOTE: Some Plex server have some absurd values for this field, like 8457612157633039800 so it should be int64
*/
public Builder contentChangedAt(int contentChangedAt) {
public Builder contentChangedAt(long contentChangedAt) {
Utils.checkNotNull(contentChangedAt, "contentChangedAt");
this.contentChangedAt = contentChangedAt;
return this;

View File

@@ -4,18 +4,139 @@
package dev.plexapi.sdk.utils;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Locale;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
public class SpeakeasyHTTPClient implements HTTPClient {
private static boolean debugEnabled = false;
// uppercase
private static Set<String> redactedHeaders = Set.of("AUTHORIZATION", "X-API-KEY");
private static Consumer<? super String> logger = System.out::println;
/**
* Experimental, may be changed anytime. Sets debug logging on or off for
* requests and responses including bodies for JSON content. WARNING: this
* setting may expose sensitive information in logs (like <i>Authorization</i>
* headers), and should only be enabled temporarily for local debugging
* purposes. By default, <i>Authorization</i> headers are redacted in the logs
* ( printed with a value of {@code [*******]}). Header suppression is controlled
* with the {@link #setRedactedHeaders(Collection)} method.
*
* @param enabled true to enable debug logging, false to disable it
*/
public static void setDebugLogging(boolean enabled) {
debugEnabled = enabled;
}
/**
* Experimental, may be changed anytime. When debug logging is enabled this
* method controls the suppression of header values in the logs. By default,
* <i>Authorization</i> headers are redacted in the logs (printed with a value
* of {@code [*******]}). Header suppression is controlled with the
* {@link #setRedactedHeaders(Collection)} method.
*
* @param headerNames the names (case-insensitive) of the headers whose values
* will be redacted in the logs
*/
public static void setRedactedHeaders(Collection<String> headerNames) {
redactedHeaders = headerNames.stream() //
.map(x -> x.toUpperCase(Locale.ENGLISH)) //
.collect(Collectors.toSet());
}
public static void setLogger(Consumer<? super String> logger) {
SpeakeasyHTTPClient.logger = logger;
}
@Override
public HttpResponse<InputStream> send(HttpRequest request)
throws IOException, InterruptedException, URISyntaxException {
HttpClient client = HttpClient.newHttpClient();
return client.send(request, HttpResponse.BodyHandlers.ofInputStream());
if (debugEnabled) {
request = logRequest(request);
}
var response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());
if (debugEnabled) {
response = logResponse(response);
}
return response;
}
private HttpRequest logRequest(HttpRequest request) {
log("Sending request: " + request);
log("Request headers: " + redactHeaders(request.headers()));
// only log the body if it is present and the content type is JSON
if (request.bodyPublisher().isPresent() && request.headers() //
.firstValue("Content-Type") //
.filter(x -> x.equals("application/json") || x.equals("text/plain")).isPresent()) {
// we read the body and ensure that the BodyPublisher is rebuilt to pass to the
// http client
byte[] body = Helpers.bodyBytes(request);
request = Helpers //
.copy(request) //
.method(request.method(), BodyPublishers.ofByteArray(body)) //
.build();
// note that in the case of text/plain a different encoding from UTF-8
// may be in use but we just log the bytes as UTF-8. Unexpected encodings
// do not throw (substitution happens).
log("Request body:\n" + new String(body, StandardCharsets.UTF_8));
}
return request;
}
private static HttpResponse<InputStream> logResponse(HttpResponse<InputStream> response) throws IOException {
// make the response re-readable by loading the response body into a byte array
// and allowing the InputStream to be read many times
response = Utils.cache(response);
log("Received response: " + response);
log("Response headers: " + redactHeaders(response.headers()));
// only log the response body if it is present and the content type is JSON or plain text
if (response.headers() //
.firstValue("Content-Type") //
.filter(x -> x.equals("application/json") || x.equals("text/plain")) //
.isPresent()) {
// the response is re-readable so we can read and close it without
// affecting later processing of the response.
// note that in the case of text/plain a different encoding from UTF-8
// may be in use but we just log the bytes as UTF-8. Unexpected encodings
// do not throw (substitution happens).
log("Response body:\n" + Utils.toUtf8AndClose(response.body()));
}
return response;
}
private static String redactHeaders(HttpHeaders headers) {
return "{" + headers.map() //
.entrySet() //
.stream() //
.map(entry -> {
final String value;
if (redactedHeaders.contains(entry.getKey().toUpperCase(Locale.ENGLISH))) {
value = "[******]";
} else {
value = String.valueOf(entry.getValue());
}
return entry.getKey() + "=" + value;
}) //
.collect(Collectors.joining(", ")) + "}";
}
private static void log(String message) {
logger.accept(message);
}
}

View File

@@ -1368,20 +1368,32 @@ public final class Utils {
}
return list;
}
public static <T> T valueOrNull(T value) {
return value;
public static <T> T valueOrElse(T value, T valueIfNotPresent) {
return value != null ? value : valueIfNotPresent;
}
public static <T> T valueOrElse(Optional<T> value, T valueIfNotPresent) {
return value.orElse(valueIfNotPresent);
}
public static <T> T valueOrNull(Optional<T> value) {
return value.orElse(null);
}
public static <T> T valueOrNull(JsonNullable<T> value) {
public static <T> T valueOrElse(JsonNullable<T> value, T valueIfNotPresent) {
if (value.isPresent()) {
return value.get();
} else {
return null;
return valueIfNotPresent;
}
}
public static <T> T valueOrNull(T value) {
return valueOrElse(value, null);
}
public static <T> T valueOrNull(Optional<T> value) {
return valueOrElse(value, null);
}
public static <T> T valueOrNull(JsonNullable<T> value) {
return valueOrElse(value, null);
}
}