mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-09 20:47:47 +00:00
141 lines
4.1 KiB
TypeScript
141 lines
4.1 KiB
TypeScript
/*
|
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
*/
|
|
|
|
import { PlexAPICore } from "../core.js";
|
|
import { encodeSimple as encodeSimple$ } from "../lib/encodings.js";
|
|
import * as m$ from "../lib/matchers.js";
|
|
import * as schemas$ from "../lib/schemas.js";
|
|
import { RequestOptions } from "../lib/sdks.js";
|
|
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
import { pathToFunc } from "../lib/url.js";
|
|
import {
|
|
ConnectionError,
|
|
InvalidRequestError,
|
|
RequestAbortedError,
|
|
RequestTimeoutError,
|
|
UnexpectedClientError,
|
|
} from "../sdk/models/errors/httpclienterrors.js";
|
|
import * as errors from "../sdk/models/errors/index.js";
|
|
import { SDKError } from "../sdk/models/errors/sdkerror.js";
|
|
import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js";
|
|
import * as operations from "../sdk/models/operations/index.js";
|
|
import { Result } from "../sdk/types/fp.js";
|
|
|
|
/**
|
|
* Delete Library Section
|
|
*
|
|
* @remarks
|
|
* Delete a library using a specific section id
|
|
*/
|
|
export async function libraryDeleteLibrary(
|
|
client$: PlexAPICore,
|
|
sectionKey: number,
|
|
options?: RequestOptions
|
|
): Promise<
|
|
Result<
|
|
operations.DeleteLibraryResponse,
|
|
| errors.DeleteLibraryResponseBody
|
|
| SDKError
|
|
| SDKValidationError
|
|
| UnexpectedClientError
|
|
| InvalidRequestError
|
|
| RequestAbortedError
|
|
| RequestTimeoutError
|
|
| ConnectionError
|
|
>
|
|
> {
|
|
const input$: operations.DeleteLibraryRequest = {
|
|
sectionKey: sectionKey,
|
|
};
|
|
|
|
const parsed$ = schemas$.safeParse(
|
|
input$,
|
|
(value$) => operations.DeleteLibraryRequest$outboundSchema.parse(value$),
|
|
"Input validation failed"
|
|
);
|
|
if (!parsed$.ok) {
|
|
return parsed$;
|
|
}
|
|
const payload$ = parsed$.value;
|
|
const body$ = null;
|
|
|
|
const pathParams$ = {
|
|
sectionKey: encodeSimple$("sectionKey", payload$.sectionKey, {
|
|
explode: false,
|
|
charEncoding: "percent",
|
|
}),
|
|
};
|
|
|
|
const path$ = pathToFunc("/library/sections/{sectionKey}")(pathParams$);
|
|
|
|
const headers$ = new Headers({
|
|
Accept: "application/json",
|
|
});
|
|
|
|
const accessToken$ = await extractSecurity(client$.options$.accessToken);
|
|
const security$ = accessToken$ == null ? {} : { accessToken: accessToken$ };
|
|
const context = {
|
|
operationID: "deleteLibrary",
|
|
oAuth2Scopes: [],
|
|
securitySource: client$.options$.accessToken,
|
|
};
|
|
const securitySettings$ = resolveGlobalSecurity(security$);
|
|
|
|
const requestRes = client$.createRequest$(
|
|
context,
|
|
{
|
|
security: securitySettings$,
|
|
method: "DELETE",
|
|
path: path$,
|
|
headers: headers$,
|
|
body: body$,
|
|
timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1,
|
|
},
|
|
options
|
|
);
|
|
if (!requestRes.ok) {
|
|
return requestRes;
|
|
}
|
|
const request$ = requestRes.value;
|
|
|
|
const doResult = await client$.do$(request$, {
|
|
context,
|
|
errorCodes: ["400", "401", "4XX", "5XX"],
|
|
retryConfig: options?.retries || client$.options$.retryConfig,
|
|
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
});
|
|
if (!doResult.ok) {
|
|
return doResult;
|
|
}
|
|
const response = doResult.value;
|
|
|
|
const responseFields$ = {
|
|
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
StatusCode: response.status,
|
|
RawResponse: response,
|
|
Headers: {},
|
|
};
|
|
|
|
const [result$] = await m$.match<
|
|
operations.DeleteLibraryResponse,
|
|
| errors.DeleteLibraryResponseBody
|
|
| SDKError
|
|
| SDKValidationError
|
|
| UnexpectedClientError
|
|
| InvalidRequestError
|
|
| RequestAbortedError
|
|
| RequestTimeoutError
|
|
| ConnectionError
|
|
>(
|
|
m$.nil(200, operations.DeleteLibraryResponse$inboundSchema),
|
|
m$.fail([400, "4XX", "5XX"]),
|
|
m$.jsonErr(401, errors.DeleteLibraryResponseBody$inboundSchema)
|
|
)(response, { extraFields: responseFields$ });
|
|
if (!result$.ok) {
|
|
return result$;
|
|
}
|
|
|
|
return result$;
|
|
}
|