mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-10 20:47:48 +00:00
ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.129.1
This commit is contained in:
230
src/sdk/updater.ts
Normal file
230
src/sdk/updater.ts
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* 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 Updater extends ClientSDK {
|
||||
private readonly options$: SDKOptions;
|
||||
|
||||
constructor(options: SDKOptions = {}) {
|
||||
super({
|
||||
client: options.httpClient || new HTTPClient(),
|
||||
baseURL: serverURLFromOptions(options),
|
||||
});
|
||||
|
||||
this.options$ = options;
|
||||
void this.options$;
|
||||
}
|
||||
/**
|
||||
* Querying status of updates
|
||||
*
|
||||
* @remarks
|
||||
* Querying status of updates
|
||||
*/
|
||||
async getUpdateStatus(options?: RequestOptions): Promise<operations.GetUpdateStatusResponse> {
|
||||
const headers$ = new Headers();
|
||||
headers$.set("user-agent", SDK_METADATA.userAgent);
|
||||
headers$.set("Accept", "application/json");
|
||||
|
||||
const path$ = this.templateURLComponent("/updater/status")();
|
||||
|
||||
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.GetUpdateStatusResponseBody$.inboundSchema.parse({
|
||||
...responseFields$,
|
||||
...responseBody,
|
||||
});
|
||||
throw result;
|
||||
} else {
|
||||
const responseBody = await response.text();
|
||||
throw new errors.SDKError("Unexpected API response", response, responseBody);
|
||||
}
|
||||
|
||||
return operations.GetUpdateStatusResponse$.inboundSchema.parse(responseFields$);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking for updates
|
||||
*
|
||||
* @remarks
|
||||
* Checking for updates
|
||||
*/
|
||||
async checkForUpdates(
|
||||
download?: operations.Download | undefined,
|
||||
options?: RequestOptions
|
||||
): Promise<operations.CheckForUpdatesResponse> {
|
||||
const input$: operations.CheckForUpdatesRequest = {
|
||||
download: download,
|
||||
};
|
||||
const headers$ = new Headers();
|
||||
headers$.set("user-agent", SDK_METADATA.userAgent);
|
||||
headers$.set("Accept", "application/json");
|
||||
|
||||
const payload$ = operations.CheckForUpdatesRequest$.outboundSchema.parse(input$);
|
||||
const body$ = null;
|
||||
|
||||
const path$ = this.templateURLComponent("/updater/check")();
|
||||
|
||||
const query$ = [
|
||||
enc$.encodeForm("download", payload$.download, {
|
||||
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: "put",
|
||||
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.CheckForUpdatesResponseBody$.inboundSchema.parse({
|
||||
...responseFields$,
|
||||
...responseBody,
|
||||
});
|
||||
throw result;
|
||||
} else {
|
||||
const responseBody = await response.text();
|
||||
throw new errors.SDKError("Unexpected API response", response, responseBody);
|
||||
}
|
||||
|
||||
return operations.CheckForUpdatesResponse$.inboundSchema.parse(responseFields$);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply Updates
|
||||
*
|
||||
* @remarks
|
||||
* Note that these two parameters are effectively mutually exclusive. The `tonight` parameter takes precedence and `skip` will be ignored if `tonight` is also passed
|
||||
*
|
||||
*/
|
||||
async applyUpdates(
|
||||
tonight?: operations.Tonight | undefined,
|
||||
skip?: operations.Skip | undefined,
|
||||
options?: RequestOptions
|
||||
): Promise<operations.ApplyUpdatesResponse> {
|
||||
const input$: operations.ApplyUpdatesRequest = {
|
||||
tonight: tonight,
|
||||
skip: skip,
|
||||
};
|
||||
const headers$ = new Headers();
|
||||
headers$.set("user-agent", SDK_METADATA.userAgent);
|
||||
headers$.set("Accept", "application/json");
|
||||
|
||||
const payload$ = operations.ApplyUpdatesRequest$.outboundSchema.parse(input$);
|
||||
const body$ = null;
|
||||
|
||||
const path$ = this.templateURLComponent("/updater/apply")();
|
||||
|
||||
const query$ = [
|
||||
enc$.encodeForm("skip", payload$.skip, { explode: true, charEncoding: "percent" }),
|
||||
enc$.encodeForm("tonight", payload$.tonight, {
|
||||
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: "put",
|
||||
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.ApplyUpdatesResponseBody$.inboundSchema.parse({
|
||||
...responseFields$,
|
||||
...responseBody,
|
||||
});
|
||||
throw result;
|
||||
} else {
|
||||
const responseBody = await response.text();
|
||||
throw new errors.SDKError("Unexpected API response", response, responseBody);
|
||||
}
|
||||
|
||||
return operations.ApplyUpdatesResponse$.inboundSchema.parse(responseFields$);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user