/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ package dev.plexapi.sdk; import com.fasterxml.jackson.core.type.TypeReference; import dev.plexapi.sdk.models.errors.EnablePaperTrailBadRequest; import dev.plexapi.sdk.models.errors.EnablePaperTrailUnauthorized; import dev.plexapi.sdk.models.errors.LogLineBadRequest; import dev.plexapi.sdk.models.errors.LogLineUnauthorized; import dev.plexapi.sdk.models.errors.LogMultiLineBadRequest; import dev.plexapi.sdk.models.errors.LogMultiLineUnauthorized; import dev.plexapi.sdk.models.errors.SDKError; import dev.plexapi.sdk.models.operations.EnablePaperTrailRequestBuilder; import dev.plexapi.sdk.models.operations.EnablePaperTrailResponse; import dev.plexapi.sdk.models.operations.Level; import dev.plexapi.sdk.models.operations.LogLineRequest; import dev.plexapi.sdk.models.operations.LogLineRequestBuilder; import dev.plexapi.sdk.models.operations.LogLineResponse; import dev.plexapi.sdk.models.operations.LogMultiLineRequestBuilder; import dev.plexapi.sdk.models.operations.LogMultiLineResponse; import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*; import dev.plexapi.sdk.utils.HTTPClient; import dev.plexapi.sdk.utils.HTTPRequest; import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl; import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl; import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl; import dev.plexapi.sdk.utils.SerializedBody; import dev.plexapi.sdk.utils.Utils.JsonShape; import dev.plexapi.sdk.utils.Utils; import java.io.InputStream; import java.lang.Exception; import java.lang.Object; import java.lang.String; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.util.List; import java.util.Optional; /** * Submit logs to the Log Handler for Plex Media Server */ public class Log implements MethodCallLogLine, MethodCallLogMultiLine, MethodCallEnablePaperTrail { private final SDKConfiguration sdkConfiguration; Log(SDKConfiguration sdkConfiguration) { this.sdkConfiguration = sdkConfiguration; } /** * Logging a single line message. * *
This endpoint will write a single-line log message, including a level and source to the main Plex Media Server log. * * @return The call builder */ public LogLineRequestBuilder logLine() { return new LogLineRequestBuilder(this); } /** * Logging a single line message. * *
This endpoint will write a single-line log message, including a level and source to the main Plex Media Server log.
*
* @param level An integer log level to write to the PMS log with.
* 0: Error
* 1: Warning
* 2: Info
* 3: Debug
* 4: Verbose
*
* @param message The text of the message to write to the log.
* @param source a string indicating the source of the message.
* @return The response from the API call
* @throws Exception if the API call fails
*/
public LogLineResponse logLine(
Level level,
String message,
String source) throws Exception {
LogLineRequest request =
LogLineRequest
.builder()
.level(level)
.message(message)
.source(source)
.build();
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl(), this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
_baseUrl,
"/log");
HTTPRequest _req = new HTTPRequest(_url, "GET");
_req.addHeader("Accept", "application/json")
.addHeader("user-agent",
SDKConfiguration.USER_AGENT);
_req.addQueryParams(Utils.getQueryParams(
LogLineRequest.class,
request,
null));
Optional This endpoint allows for the batch addition of log entries to the main Plex Media Server log.
* It accepts a text/plain request body, where each line represents a distinct log entry.
* Each log entry consists of URL-encoded key-value pairs, specifying log attributes such as 'level', 'message', and 'source'.
*
* Log entries are separated by a newline character (`\n`).
* Each entry's parameters should be URL-encoded to ensure accurate parsing and handling of special characters.
* This method is efficient for logging multiple entries in a single API call, reducing the overhead of multiple individual requests.
*
* The 'level' parameter specifies the log entry's severity or importance, with the following integer values:
* - `0`: Error - Critical issues that require immediate attention.
* - `1`: Warning - Important events that are not critical but may indicate potential issues.
* - `2`: Info - General informational messages about system operation.
* - `3`: Debug - Detailed information useful for debugging purposes.
* - `4`: Verbose - Highly detailed diagnostic information for in-depth analysis.
*
* The 'message' parameter contains the log text, and 'source' identifies the log message's origin (e.g., an application name or module).
*
* Example of a single log entry format:
* `level=4&message=Sample%20log%20entry&source=applicationName`
*
* Ensure each parameter is properly URL-encoded to avoid interpretation issues.
*
* @return The call builder
*/
public LogMultiLineRequestBuilder logMultiLine() {
return new LogMultiLineRequestBuilder(this);
}
/**
* Logging a multi-line message
*
* This endpoint allows for the batch addition of log entries to the main Plex Media Server log.
* It accepts a text/plain request body, where each line represents a distinct log entry.
* Each log entry consists of URL-encoded key-value pairs, specifying log attributes such as 'level', 'message', and 'source'.
*
* Log entries are separated by a newline character (`\n`).
* Each entry's parameters should be URL-encoded to ensure accurate parsing and handling of special characters.
* This method is efficient for logging multiple entries in a single API call, reducing the overhead of multiple individual requests.
*
* The 'level' parameter specifies the log entry's severity or importance, with the following integer values:
* - `0`: Error - Critical issues that require immediate attention.
* - `1`: Warning - Important events that are not critical but may indicate potential issues.
* - `2`: Info - General informational messages about system operation.
* - `3`: Debug - Detailed information useful for debugging purposes.
* - `4`: Verbose - Highly detailed diagnostic information for in-depth analysis.
*
* The 'message' parameter contains the log text, and 'source' identifies the log message's origin (e.g., an application name or module).
*
* Example of a single log entry format:
* `level=4&message=Sample%20log%20entry&source=applicationName`
*
* Ensure each parameter is properly URL-encoded to avoid interpretation issues.
*
* @param request The request object containing all of the parameters for the API call.
* @return The response from the API call
* @throws Exception if the API call fails
*/
public LogMultiLineResponse logMultiLine(
String request) throws Exception {
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl(), this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
_baseUrl,
"/log");
HTTPRequest _req = new HTTPRequest(_url, "POST");
Object _convertedRequest = Utils.convertToShape(
request,
JsonShape.DEFAULT,
new TypeReference This endpoint will enable all Plex Media Serverlogs to be sent to the Papertrail networked logging site for a period of time.
*
* @return The call builder
*/
public EnablePaperTrailRequestBuilder enablePaperTrail() {
return new EnablePaperTrailRequestBuilder(this);
}
/**
* Enabling Papertrail
*
* This endpoint will enable all Plex Media Serverlogs to be sent to the Papertrail networked logging site for a period of time.
*
* @return The response from the API call
* @throws Exception if the API call fails
*/
public EnablePaperTrailResponse enablePaperTrailDirect() throws Exception {
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl(), this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
_baseUrl,
"/log/networked");
HTTPRequest _req = new HTTPRequest(_url, "GET");
_req.addHeader("Accept", "application/json")
.addHeader("user-agent",
SDKConfiguration.USER_AGENT);
Optional