mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 12:37:46 +00:00
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.377.1
This commit is contained in:
139
src/funcs/libraryDeleteLibrary.ts
Normal file
139
src/funcs/libraryDeleteLibrary.ts
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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 "../models/httpclienterrors.js";
|
||||
import * as models from "../models/index.js";
|
||||
import { SDKError } from "../models/sdkerror.js";
|
||||
import { SDKValidationError } from "../models/sdkvalidationerror.js";
|
||||
import { Result } from "../types/fp.js";
|
||||
|
||||
/**
|
||||
* Delete Library Section
|
||||
*
|
||||
* @remarks
|
||||
* Delate a library using a specific section
|
||||
*/
|
||||
export async function libraryDeleteLibrary(
|
||||
client$: PlexAPICore,
|
||||
sectionId: number,
|
||||
options?: RequestOptions
|
||||
): Promise<
|
||||
Result<
|
||||
models.DeleteLibraryResponse,
|
||||
| models.DeleteLibraryResponseBody
|
||||
| SDKError
|
||||
| SDKValidationError
|
||||
| UnexpectedClientError
|
||||
| InvalidRequestError
|
||||
| RequestAbortedError
|
||||
| RequestTimeoutError
|
||||
| ConnectionError
|
||||
>
|
||||
> {
|
||||
const input$: models.DeleteLibraryRequest = {
|
||||
sectionId: sectionId,
|
||||
};
|
||||
|
||||
const parsed$ = schemas$.safeParse(
|
||||
input$,
|
||||
(value$) => models.DeleteLibraryRequest$outboundSchema.parse(value$),
|
||||
"Input validation failed"
|
||||
);
|
||||
if (!parsed$.ok) {
|
||||
return parsed$;
|
||||
}
|
||||
const payload$ = parsed$.value;
|
||||
const body$ = null;
|
||||
|
||||
const pathParams$ = {
|
||||
sectionId: encodeSimple$("sectionId", payload$.sectionId, {
|
||||
explode: false,
|
||||
charEncoding: "percent",
|
||||
}),
|
||||
};
|
||||
|
||||
const path$ = pathToFunc("/library/sections/{sectionId}")(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<
|
||||
models.DeleteLibraryResponse,
|
||||
| models.DeleteLibraryResponseBody
|
||||
| SDKError
|
||||
| SDKValidationError
|
||||
| UnexpectedClientError
|
||||
| InvalidRequestError
|
||||
| RequestAbortedError
|
||||
| RequestTimeoutError
|
||||
| ConnectionError
|
||||
>(
|
||||
m$.nil(200, models.DeleteLibraryResponse$inboundSchema),
|
||||
m$.fail([400, "4XX", "5XX"]),
|
||||
m$.jsonErr(401, models.DeleteLibraryResponseBody$inboundSchema)
|
||||
)(response, { extraFields: responseFields$ });
|
||||
if (!result$.ok) {
|
||||
return result$;
|
||||
}
|
||||
|
||||
return result$;
|
||||
}
|
||||
Reference in New Issue
Block a user