mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-10 04:20:58 +00:00
ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.129.1
This commit is contained in:
210
src/sdk/log.ts
Normal file
210
src/sdk/log.ts
Normal file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
||||
*/
|
||||
|
||||
import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config";
|
||||
import * as enc$ from "../lib/encodings";
|
||||
import { HTTPClient } from "../lib/http";
|
||||
import { ClientSDK, RequestOptions } from "../lib/sdks";
|
||||
import * as errors from "../models/errors";
|
||||
import * as operations from "../models/operations";
|
||||
|
||||
export class Log extends ClientSDK {
|
||||
private readonly options$: SDKOptions;
|
||||
|
||||
constructor(options: SDKOptions = {}) {
|
||||
super({
|
||||
client: options.httpClient || new HTTPClient(),
|
||||
baseURL: serverURLFromOptions(options),
|
||||
});
|
||||
|
||||
this.options$ = options;
|
||||
void this.options$;
|
||||
}
|
||||
/**
|
||||
* Logging a single line message.
|
||||
*
|
||||
* @remarks
|
||||
* This endpoint will write a single-line log message, including a level and source to the main Plex Media Server log.
|
||||
*
|
||||
*/
|
||||
async logLine(
|
||||
level: operations.Level,
|
||||
message: string,
|
||||
source: string,
|
||||
options?: RequestOptions
|
||||
): Promise<operations.LogLineResponse> {
|
||||
const input$: operations.LogLineRequest = {
|
||||
level: level,
|
||||
message: message,
|
||||
source: source,
|
||||
};
|
||||
const headers$ = new Headers();
|
||||
headers$.set("user-agent", SDK_METADATA.userAgent);
|
||||
headers$.set("Accept", "application/json");
|
||||
|
||||
const payload$ = operations.LogLineRequest$.outboundSchema.parse(input$);
|
||||
const body$ = null;
|
||||
|
||||
const path$ = this.templateURLComponent("/log")();
|
||||
|
||||
const query$ = [
|
||||
enc$.encodeForm("level", payload$.level, { explode: true, charEncoding: "percent" }),
|
||||
enc$.encodeForm("message", payload$.message, {
|
||||
explode: true,
|
||||
charEncoding: "percent",
|
||||
}),
|
||||
enc$.encodeForm("source", payload$.source, { explode: true, charEncoding: "percent" }),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join("&");
|
||||
|
||||
let security$;
|
||||
if (typeof this.options$.accessToken === "function") {
|
||||
security$ = { accessToken: await this.options$.accessToken() };
|
||||
} else if (this.options$.accessToken) {
|
||||
security$ = { accessToken: this.options$.accessToken };
|
||||
} else {
|
||||
security$ = {};
|
||||
}
|
||||
const securitySettings$ = this.resolveGlobalSecurity(security$);
|
||||
|
||||
const response = await this.fetch$(
|
||||
{
|
||||
security: securitySettings$,
|
||||
method: "get",
|
||||
path: path$,
|
||||
headers: headers$,
|
||||
query: query$,
|
||||
body: body$,
|
||||
},
|
||||
options
|
||||
);
|
||||
|
||||
const responseFields$ = {
|
||||
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
|
||||
StatusCode: response.status,
|
||||
RawResponse: response,
|
||||
};
|
||||
|
||||
if (this.matchStatusCode(response, 200)) {
|
||||
// fallthrough
|
||||
} else if (this.matchResponse(response, 401, "application/json")) {
|
||||
const responseBody = await response.json();
|
||||
const result = errors.LogLineResponseBody$.inboundSchema.parse({
|
||||
...responseFields$,
|
||||
...responseBody,
|
||||
});
|
||||
throw result;
|
||||
} else {
|
||||
const responseBody = await response.text();
|
||||
throw new errors.SDKError("Unexpected API response", response, responseBody);
|
||||
}
|
||||
|
||||
return operations.LogLineResponse$.inboundSchema.parse(responseFields$);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging a multi-line message
|
||||
*
|
||||
* @remarks
|
||||
* This endpoint will write multiple lines to the main Plex Media Server log in a single request. It takes a set of query strings as would normally sent to the above GET endpoint as a linefeed-separated block of POST data. The parameters for each query string match as above.
|
||||
*
|
||||
*/
|
||||
async logMultiLine(options?: RequestOptions): Promise<operations.LogMultiLineResponse> {
|
||||
const headers$ = new Headers();
|
||||
headers$.set("user-agent", SDK_METADATA.userAgent);
|
||||
headers$.set("Accept", "application/json");
|
||||
|
||||
const path$ = this.templateURLComponent("/log")();
|
||||
|
||||
let security$;
|
||||
if (typeof this.options$.accessToken === "function") {
|
||||
security$ = { accessToken: await this.options$.accessToken() };
|
||||
} else if (this.options$.accessToken) {
|
||||
security$ = { accessToken: this.options$.accessToken };
|
||||
} else {
|
||||
security$ = {};
|
||||
}
|
||||
const securitySettings$ = this.resolveGlobalSecurity(security$);
|
||||
|
||||
const response = await this.fetch$(
|
||||
{ security: securitySettings$, method: "post", path: path$, headers: headers$ },
|
||||
options
|
||||
);
|
||||
|
||||
const responseFields$ = {
|
||||
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
|
||||
StatusCode: response.status,
|
||||
RawResponse: response,
|
||||
};
|
||||
|
||||
if (this.matchStatusCode(response, 200)) {
|
||||
// fallthrough
|
||||
} else if (this.matchResponse(response, 401, "application/json")) {
|
||||
const responseBody = await response.json();
|
||||
const result = errors.LogMultiLineResponseBody$.inboundSchema.parse({
|
||||
...responseFields$,
|
||||
...responseBody,
|
||||
});
|
||||
throw result;
|
||||
} else {
|
||||
const responseBody = await response.text();
|
||||
throw new errors.SDKError("Unexpected API response", response, responseBody);
|
||||
}
|
||||
|
||||
return operations.LogMultiLineResponse$.inboundSchema.parse(responseFields$);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enabling Papertrail
|
||||
*
|
||||
* @remarks
|
||||
* This endpoint will enable all Plex Media Serverlogs to be sent to the Papertrail networked logging site for a period of time.
|
||||
*
|
||||
*/
|
||||
async enablePaperTrail(options?: RequestOptions): Promise<operations.EnablePaperTrailResponse> {
|
||||
const headers$ = new Headers();
|
||||
headers$.set("user-agent", SDK_METADATA.userAgent);
|
||||
headers$.set("Accept", "application/json");
|
||||
|
||||
const path$ = this.templateURLComponent("/log/networked")();
|
||||
|
||||
let security$;
|
||||
if (typeof this.options$.accessToken === "function") {
|
||||
security$ = { accessToken: await this.options$.accessToken() };
|
||||
} else if (this.options$.accessToken) {
|
||||
security$ = { accessToken: this.options$.accessToken };
|
||||
} else {
|
||||
security$ = {};
|
||||
}
|
||||
const securitySettings$ = this.resolveGlobalSecurity(security$);
|
||||
|
||||
const response = await this.fetch$(
|
||||
{ security: securitySettings$, method: "get", path: path$, headers: headers$ },
|
||||
options
|
||||
);
|
||||
|
||||
const responseFields$ = {
|
||||
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
|
||||
StatusCode: response.status,
|
||||
RawResponse: response,
|
||||
};
|
||||
|
||||
if (this.matchStatusCode(response, 200)) {
|
||||
// fallthrough
|
||||
} else if (this.matchResponse(response, 401, "application/json")) {
|
||||
const responseBody = await response.json();
|
||||
const result = errors.EnablePaperTrailResponseBody$.inboundSchema.parse({
|
||||
...responseFields$,
|
||||
...responseBody,
|
||||
});
|
||||
throw result;
|
||||
} else {
|
||||
const responseBody = await response.text();
|
||||
throw new errors.SDKError("Unexpected API response", response, responseBody);
|
||||
}
|
||||
|
||||
return operations.EnablePaperTrailResponse$.inboundSchema.parse(responseFields$);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user