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:
152
src/sdk/activities.ts
Normal file
152
src/sdk/activities.ts
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* 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 Activities extends ClientSDK {
|
||||
private readonly options$: SDKOptions;
|
||||
|
||||
constructor(options: SDKOptions = {}) {
|
||||
super({
|
||||
client: options.httpClient || new HTTPClient(),
|
||||
baseURL: serverURLFromOptions(options),
|
||||
});
|
||||
|
||||
this.options$ = options;
|
||||
void this.options$;
|
||||
}
|
||||
/**
|
||||
* Get Server Activities
|
||||
*
|
||||
* @remarks
|
||||
* Get Server Activities
|
||||
*/
|
||||
async getServerActivities(
|
||||
options?: RequestOptions
|
||||
): Promise<operations.GetServerActivitiesResponse> {
|
||||
const headers$ = new Headers();
|
||||
headers$.set("user-agent", SDK_METADATA.userAgent);
|
||||
headers$.set("Accept", "application/json");
|
||||
|
||||
const path$ = this.templateURLComponent("/activities")();
|
||||
|
||||
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.matchResponse(response, 200, "application/json")) {
|
||||
const responseBody = await response.json();
|
||||
const result = operations.GetServerActivitiesResponse$.inboundSchema.parse({
|
||||
...responseFields$,
|
||||
object: responseBody,
|
||||
});
|
||||
return result;
|
||||
} else if (this.matchResponse(response, 401, "application/json")) {
|
||||
const responseBody = await response.json();
|
||||
const result = errors.GetServerActivitiesResponseBody$.inboundSchema.parse({
|
||||
...responseFields$,
|
||||
...responseBody,
|
||||
});
|
||||
throw result;
|
||||
} else {
|
||||
const responseBody = await response.text();
|
||||
throw new errors.SDKError("Unexpected API response", response, responseBody);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Server Activities
|
||||
*
|
||||
* @remarks
|
||||
* Cancel Server Activities
|
||||
*/
|
||||
async cancelServerActivities(
|
||||
activityUUID: string,
|
||||
options?: RequestOptions
|
||||
): Promise<operations.CancelServerActivitiesResponse> {
|
||||
const input$: operations.CancelServerActivitiesRequest = {
|
||||
activityUUID: activityUUID,
|
||||
};
|
||||
const headers$ = new Headers();
|
||||
headers$.set("user-agent", SDK_METADATA.userAgent);
|
||||
headers$.set("Accept", "application/json");
|
||||
|
||||
const payload$ = operations.CancelServerActivitiesRequest$.outboundSchema.parse(input$);
|
||||
const body$ = null;
|
||||
|
||||
const pathParams$ = {
|
||||
activityUUID: enc$.encodeSimple("activityUUID", payload$.activityUUID, {
|
||||
explode: false,
|
||||
charEncoding: "percent",
|
||||
}),
|
||||
};
|
||||
|
||||
const path$ = this.templateURLComponent("/activities/{activityUUID}")(pathParams$);
|
||||
|
||||
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: "delete",
|
||||
path: path$,
|
||||
headers: headers$,
|
||||
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.CancelServerActivitiesResponseBody$.inboundSchema.parse({
|
||||
...responseFields$,
|
||||
...responseBody,
|
||||
});
|
||||
throw result;
|
||||
} else {
|
||||
const responseBody = await response.text();
|
||||
throw new errors.SDKError("Unexpected API response", response, responseBody);
|
||||
}
|
||||
|
||||
return operations.CancelServerActivitiesResponse$.inboundSchema.parse(responseFields$);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user