From 18b64727c3245a5f2d624c018035fd970105b193 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Thu, 6 Feb 2025 00:11:16 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.484.1 --- .speakeasy/gen.lock | 56 +- .speakeasy/gen.yaml | 2 +- .speakeasy/workflow.lock | 12 +- README.md | 5 + RELEASES.md | 12 +- codeSamples.yaml | 32 + docs/sdk/models/errors/getusersbadrequest.md | 18 + docs/sdk/models/errors/getuserserrors.md | 21 + .../sdk/models/errors/getusersunauthorized.md | 18 + docs/sdk/models/errors/getusersuserserrors.md | 21 + docs/sdk/models/operations/alllibraries.md | 18 + .../models/operations/allowcameraupload.md | 18 + docs/sdk/models/operations/allowchannels.md | 18 + .../models/operations/allowsubtitleadmin.md | 18 + docs/sdk/models/operations/allowsync.md | 18 + docs/sdk/models/operations/allowtuners.md | 18 + .../gettopwatchedcontentmetadata.md | 2 +- .../operations/gettopwatchedcontentuser.md | 17 + .../operations/getusersmediacontainer.md | 53 + docs/sdk/models/operations/getusersrequest.md | 41 + .../sdk/models/operations/getusersresponse.md | 24 + .../models/operations/getusersresponsebody.md | 50 + docs/sdk/models/operations/getusersserver.md | 30 + docs/sdk/models/operations/home.md | 18 + docs/sdk/models/operations/owned.md | 18 + docs/sdk/models/operations/pending.md | 18 + docs/sdk/models/operations/protected.md | 18 + docs/sdk/models/operations/restricted.md | 18 + docs/sdk/models/operations/user.md | 47 +- docs/sdks/users/README.md | 107 ++ jsr.json | 2 +- package-lock.json | 4 +- package.json | 2 +- src/funcs/usersGetUsers.ts | 199 ++++ src/lib/config.ts | 4 +- src/sdk/models/errors/getusers.ts | 326 ++++++ src/sdk/models/errors/index.ts | 1 + .../models/operations/gettopwatchedcontent.ts | 66 +- src/sdk/models/operations/getusers.ts | 1039 +++++++++++++++++ src/sdk/models/operations/index.ts | 1 + src/sdk/sdk.ts | 6 + src/sdk/users.ts | 27 + 42 files changed, 2394 insertions(+), 49 deletions(-) create mode 100644 docs/sdk/models/errors/getusersbadrequest.md create mode 100644 docs/sdk/models/errors/getuserserrors.md create mode 100644 docs/sdk/models/errors/getusersunauthorized.md create mode 100644 docs/sdk/models/errors/getusersuserserrors.md create mode 100644 docs/sdk/models/operations/alllibraries.md create mode 100644 docs/sdk/models/operations/allowcameraupload.md create mode 100644 docs/sdk/models/operations/allowchannels.md create mode 100644 docs/sdk/models/operations/allowsubtitleadmin.md create mode 100644 docs/sdk/models/operations/allowsync.md create mode 100644 docs/sdk/models/operations/allowtuners.md create mode 100644 docs/sdk/models/operations/gettopwatchedcontentuser.md create mode 100644 docs/sdk/models/operations/getusersmediacontainer.md create mode 100644 docs/sdk/models/operations/getusersrequest.md create mode 100644 docs/sdk/models/operations/getusersresponse.md create mode 100644 docs/sdk/models/operations/getusersresponsebody.md create mode 100644 docs/sdk/models/operations/getusersserver.md create mode 100644 docs/sdk/models/operations/home.md create mode 100644 docs/sdk/models/operations/owned.md create mode 100644 docs/sdk/models/operations/pending.md create mode 100644 docs/sdk/models/operations/protected.md create mode 100644 docs/sdk/models/operations/restricted.md create mode 100644 docs/sdks/users/README.md create mode 100644 src/funcs/usersGetUsers.ts create mode 100644 src/sdk/models/errors/getusers.ts create mode 100644 src/sdk/models/operations/getusers.ts create mode 100644 src/sdk/users.ts diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index f4a12dba..9d8731dd 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 16f22cbf-f23f-4419-8924-3a4b06381947 management: - docChecksum: c43b19369db7bd8d09eade562cd4268f + docChecksum: 36c9d80c203ab86cde2de03991949259 docVersion: 0.0.3 speakeasyVersion: 1.484.1 generationVersion: 2.503.2 - releaseVersion: 0.32.4 - configChecksum: 6c86c5fcb9c283a387bf93aaf260bee6 + releaseVersion: 0.32.5 + configChecksum: df3297b335ae5be90b5d2d5181fc74ed repoURL: https://github.com/LukeHagar/plexjs.git repoSubDirectory: . installationURL: https://github.com/LukeHagar/plexjs @@ -276,6 +276,10 @@ generatedFiles: - docs/sdk/models/errors/getuserfriendserrors.md - docs/sdk/models/errors/getuserfriendsplexerrors.md - docs/sdk/models/errors/getuserfriendsunauthorized.md + - docs/sdk/models/errors/getusersbadrequest.md + - docs/sdk/models/errors/getuserserrors.md + - docs/sdk/models/errors/getusersunauthorized.md + - docs/sdk/models/errors/getusersuserserrors.md - docs/sdk/models/errors/getwatchlistbadrequest.md - docs/sdk/models/errors/getwatchlisterrors.md - docs/sdk/models/errors/getwatchlistunauthorized.md @@ -353,6 +357,12 @@ generatedFiles: - docs/sdk/models/operations/addplaylistcontentsrequest.md - docs/sdk/models/operations/addplaylistcontentsresponse.md - docs/sdk/models/operations/addplaylistcontentsresponsebody.md + - docs/sdk/models/operations/alllibraries.md + - docs/sdk/models/operations/allowcameraupload.md + - docs/sdk/models/operations/allowchannels.md + - docs/sdk/models/operations/allowsubtitleadmin.md + - docs/sdk/models/operations/allowsync.md + - docs/sdk/models/operations/allowtuners.md - docs/sdk/models/operations/applyupdatesrequest.md - docs/sdk/models/operations/applyupdatesresponse.md - docs/sdk/models/operations/autoselectsubtitle.md @@ -715,6 +725,7 @@ generatedFiles: - docs/sdk/models/operations/gettopwatchedcontentresponse.md - docs/sdk/models/operations/gettopwatchedcontentresponsebody.md - docs/sdk/models/operations/gettopwatchedcontentrole.md + - docs/sdk/models/operations/gettopwatchedcontentuser.md - docs/sdk/models/operations/gettranscodesessionsmediacontainer.md - docs/sdk/models/operations/gettranscodesessionsresponse.md - docs/sdk/models/operations/gettranscodesessionsresponsebody.md @@ -725,11 +736,17 @@ generatedFiles: - docs/sdk/models/operations/getupdatestatusresponse.md - docs/sdk/models/operations/getupdatestatusresponsebody.md - docs/sdk/models/operations/getuserfriendsresponse.md + - docs/sdk/models/operations/getusersmediacontainer.md + - docs/sdk/models/operations/getusersrequest.md + - docs/sdk/models/operations/getusersresponse.md + - docs/sdk/models/operations/getusersresponsebody.md + - docs/sdk/models/operations/getusersserver.md - docs/sdk/models/operations/getwatchlistrequest.md - docs/sdk/models/operations/getwatchlistresponse.md - docs/sdk/models/operations/getwatchlistresponsebody.md - docs/sdk/models/operations/guids.md - docs/sdk/models/operations/hasthumbnail.md + - docs/sdk/models/operations/home.md - docs/sdk/models/operations/hub.md - docs/sdk/models/operations/image.md - docs/sdk/models/operations/includecollections.md @@ -765,9 +782,11 @@ generatedFiles: - docs/sdk/models/operations/onlytransient.md - docs/sdk/models/operations/operator.md - docs/sdk/models/operations/optimizedforstreaming.md + - docs/sdk/models/operations/owned.md - docs/sdk/models/operations/part.md - docs/sdk/models/operations/pastsubscription.md - docs/sdk/models/operations/pathparamtaskname.md + - docs/sdk/models/operations/pending.md - docs/sdk/models/operations/performsearchrequest.md - docs/sdk/models/operations/performsearchresponse.md - docs/sdk/models/operations/performvoicesearchrequest.md @@ -795,6 +814,7 @@ generatedFiles: - docs/sdk/models/operations/postuserssignindatauserprofile.md - docs/sdk/models/operations/postuserssignindatawatchedindicator.md - docs/sdk/models/operations/producer.md + - docs/sdk/models/operations/protected.md - docs/sdk/models/operations/protocol.md - docs/sdk/models/operations/provider.md - docs/sdk/models/operations/queryparamfilter.md @@ -808,6 +828,7 @@ generatedFiles: - docs/sdk/models/operations/ratings.md - docs/sdk/models/operations/release.md - docs/sdk/models/operations/responsebody.md + - docs/sdk/models/operations/restricted.md - docs/sdk/models/operations/role.md - docs/sdk/models/operations/scope.md - docs/sdk/models/operations/searchresult.md @@ -873,6 +894,7 @@ generatedFiles: - docs/sdks/sessions/README.md - docs/sdks/statistics/README.md - docs/sdks/updater/README.md + - docs/sdks/users/README.md - docs/sdks/video/README.md - docs/sdks/watchlist/README.md - docs/types/rfcdate.md @@ -955,6 +977,7 @@ generatedFiles: - src/funcs/updaterApplyUpdates.ts - src/funcs/updaterCheckForUpdates.ts - src/funcs/updaterGetUpdateStatus.ts + - src/funcs/usersGetUsers.ts - src/funcs/videoGetTimeline.ts - src/funcs/videoStartUniversalTranscode.ts - src/funcs/watchlistGetWatchList.ts @@ -1045,6 +1068,7 @@ generatedFiles: - src/sdk/models/errors/gettransienttoken.ts - src/sdk/models/errors/getupdatestatus.ts - src/sdk/models/errors/getuserfriends.ts + - src/sdk/models/errors/getusers.ts - src/sdk/models/errors/getwatchlist.ts - src/sdk/models/errors/httpclienterrors.ts - src/sdk/models/errors/index.ts @@ -1127,6 +1151,7 @@ generatedFiles: - src/sdk/models/operations/gettransienttoken.ts - src/sdk/models/operations/getupdatestatus.ts - src/sdk/models/operations/getuserfriends.ts + - src/sdk/models/operations/getusers.ts - src/sdk/models/operations/getwatchlist.ts - src/sdk/models/operations/index.ts - src/sdk/models/operations/logline.ts @@ -1163,6 +1188,7 @@ generatedFiles: - src/sdk/types/rfcdate.ts - src/sdk/types/streams.ts - src/sdk/updater.ts + - src/sdk/users.ts - src/sdk/video.ts - src/sdk/watchlist.ts - tsconfig.json @@ -2176,5 +2202,29 @@ examples: application/json: {"errors": [{"code": 1000, "message": "X-Plex-Client-Identifier is missing", "status": 400}, {"code": 1000, "message": "X-Plex-Client-Identifier is missing", "status": 400}]} "401": application/json: {"errors": [{"code": 1001, "message": "User could not be authenticated", "status": 401}, {"code": 1001, "message": "User could not be authenticated", "status": 401}, {"code": 1001, "message": "User could not be authenticated", "status": 401}]} + get-users: + "": + parameters: + header: + X-Plex-Client-Identifier: "3381b62b-9ab7-4e37-827b-203e9809eb58" + X-Plex-Product: "Plex for Roku" + X-Plex-Device: "Roku 3" + X-Plex-Device-Name: "Chrome" + X-Plex-Device-Screen-Resolution: "1487x1165,2560x1440" + X-Plex-Version: "2.4.1" + X-Plex-Platform: "Roku" + X-Plex-Features: "external-media,indirect-media,hub-style-list" + X-Plex-Model: "4200X" + X-Plex-Session-Id: "97e136ef-4ddd-4ff3-89a7-a5820c96c2ca" + X-Plex-Language: "en" + X-Plex-Platform-Version: "4.3 build 1057" + X-Plex-Token: "CV5xoxjTpFKUzBTShsaf" + responses: + "200": + application/xml: "0xa9CdebeF9E" + "400": + application/json: {"errors": [{"code": 1000, "message": "X-Plex-Client-Identifier is missing", "status": 400}, {"code": 1000, "message": "X-Plex-Client-Identifier is missing", "status": 400}]} + "401": + application/json: {"errors": [{"code": 1001, "message": "User could not be authenticated", "status": 401}, {"code": 1001, "message": "User could not be authenticated", "status": 401}]} examplesVersion: 1.0.0 generatedTests: {} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 936c53a7..c9963e1c 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -13,7 +13,7 @@ generation: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: false typescript: - version: 0.32.4 + version: 0.32.5 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index e443fce4..39a641e3 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -9,20 +9,20 @@ sources: - main plexapi: sourceNamespace: plexapi - sourceRevisionDigest: sha256:0b88c8bfc41def63e19e91fdd4d51bab07cb947cc3d39d2b44e8523a209cec10 - sourceBlobDigest: sha256:89d5b8427d4fb61b25751aebbaf71f9613958e9e91073fc084fed2c2ec62ce55 + sourceRevisionDigest: sha256:e6ab335dd91a4165f4510e4a3af8a55819c6310b7e66251266d2384376f3ccae + sourceBlobDigest: sha256:89d1b1133e400c89f0d06efe5e5168f5ba25a413e1ab8380d442d6b233e2e5a9 tags: - latest - - speakeasy-sdk-regen-1738714216 + - speakeasy-sdk-regen-1738800605 - 0.0.3 targets: plexjs: source: plexapi sourceNamespace: plexapi - sourceRevisionDigest: sha256:0b88c8bfc41def63e19e91fdd4d51bab07cb947cc3d39d2b44e8523a209cec10 - sourceBlobDigest: sha256:89d5b8427d4fb61b25751aebbaf71f9613958e9e91073fc084fed2c2ec62ce55 + sourceRevisionDigest: sha256:e6ab335dd91a4165f4510e4a3af8a55819c6310b7e66251266d2384376f3ccae + sourceBlobDigest: sha256:89d1b1133e400c89f0d06efe5e5168f5ba25a413e1ab8380d442d6b233e2e5a9 codeSamplesNamespace: code-samples-typescript-plexjs - codeSamplesRevisionDigest: sha256:df7e2100185ec86a48b4f65f568ed638af71b9f8a978161e67b8c21d3f90817b + codeSamplesRevisionDigest: sha256:214b9a57e050598b3c15f0f8504a591973e8399cad8b8be2917772c3f75861a9 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index fe37a155..84af56e6 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,10 @@ run(); * [checkForUpdates](docs/sdks/updater/README.md#checkforupdates) - Checking for updates * [applyUpdates](docs/sdks/updater/README.md#applyupdates) - Apply Updates +### [users](docs/sdks/users/README.md) + +* [getUsers](docs/sdks/users/README.md#getusers) - Get list of all connected users + ### [video](docs/sdks/video/README.md) * [getTimeline](docs/sdks/video/README.md#gettimeline) - Get the timeline for a media item @@ -564,6 +568,7 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). - [`updaterApplyUpdates`](docs/sdks/updater/README.md#applyupdates) - Apply Updates - [`updaterCheckForUpdates`](docs/sdks/updater/README.md#checkforupdates) - Checking for updates - [`updaterGetUpdateStatus`](docs/sdks/updater/README.md#getupdatestatus) - Querying status of updates +- [`usersGetUsers`](docs/sdks/users/README.md#getusers) - Get list of all connected users - [`videoGetTimeline`](docs/sdks/video/README.md#gettimeline) - Get the timeline for a media item - [`videoStartUniversalTranscode`](docs/sdks/video/README.md#startuniversaltranscode) - Start Universal Transcode - [`watchlistGetWatchList`](docs/sdks/watchlist/README.md#getwatchlist) - Get User Watchlist diff --git a/RELEASES.md b/RELEASES.md index 9aee81fc..a1f1dc69 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1198,4 +1198,14 @@ Based on: ### Generated - [typescript v0.32.4] . ### Releases -- [NPM v0.32.4] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.32.4 - . \ No newline at end of file +- [NPM v0.32.4] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.32.4 - . + +## 2025-02-06 00:09:46 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.484.1 (2.503.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.32.5] . +### Releases +- [NPM v0.32.5] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.32.5 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index 86576f4e..3941dd72 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -1621,6 +1621,38 @@ actions: console.log(result); } + run(); + - target: $["paths"]["/users"]["get"] + update: + x-codeSamples: + - lang: typescript + label: users + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI(); + + async function run() { + const result = await plexAPI.users.getUsers({ + clientID: "3381b62b-9ab7-4e37-827b-203e9809eb58", + clientName: "Plex for Roku", + deviceNickname: "Roku 3", + deviceName: "Chrome", + deviceScreenResolution: "1487x1165,2560x1440", + clientVersion: "2.4.1", + platform: "Roku", + clientFeatures: "external-media,indirect-media,hub-style-list", + model: "4200X", + xPlexSessionId: "97e136ef-4ddd-4ff3-89a7-a5820c96c2ca", + xPlexLanguage: "en", + platformVersion: "4.3 build 1057", + xPlexToken: "CV5xoxjTpFKUzBTShsaf", + }); + + // Handle the result + console.log(result); + } + run(); - target: $["paths"]["/users/signin"]["post"] update: diff --git a/docs/sdk/models/errors/getusersbadrequest.md b/docs/sdk/models/errors/getusersbadrequest.md new file mode 100644 index 00000000..a195cad5 --- /dev/null +++ b/docs/sdk/models/errors/getusersbadrequest.md @@ -0,0 +1,18 @@ +# GetUsersBadRequest + +Bad Request - A parameter was not specified, or was specified incorrectly. + +## Example Usage + +```typescript +import { GetUsersBadRequest } from "@lukehagar/plexjs/sdk/models/errors"; + +// No examples available for this model +``` + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | +| `errors` | [errors.GetUsersErrors](../../../sdk/models/errors/getuserserrors.md)[] | :heavy_minus_sign: | N/A | +| `rawResponse` | [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/docs/sdk/models/errors/getuserserrors.md b/docs/sdk/models/errors/getuserserrors.md new file mode 100644 index 00000000..d5dfca94 --- /dev/null +++ b/docs/sdk/models/errors/getuserserrors.md @@ -0,0 +1,21 @@ +# GetUsersErrors + +## Example Usage + +```typescript +import { GetUsersErrors } from "@lukehagar/plexjs/sdk/models/errors"; + +let value: GetUsersErrors = { + code: 1000, + message: "X-Plex-Client-Identifier is missing", + status: 400, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | +| `code` | *number* | :heavy_minus_sign: | N/A | 1000 | +| `message` | *string* | :heavy_minus_sign: | N/A | X-Plex-Client-Identifier is missing | +| `status` | *number* | :heavy_minus_sign: | N/A | 400 | \ No newline at end of file diff --git a/docs/sdk/models/errors/getusersunauthorized.md b/docs/sdk/models/errors/getusersunauthorized.md new file mode 100644 index 00000000..5be70093 --- /dev/null +++ b/docs/sdk/models/errors/getusersunauthorized.md @@ -0,0 +1,18 @@ +# GetUsersUnauthorized + +Unauthorized - Returned if the X-Plex-Token is missing from the header or query. + +## Example Usage + +```typescript +import { GetUsersUnauthorized } from "@lukehagar/plexjs/sdk/models/errors"; + +// No examples available for this model +``` + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `errors` | [errors.GetUsersUsersErrors](../../../sdk/models/errors/getusersuserserrors.md)[] | :heavy_minus_sign: | N/A | +| `rawResponse` | [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/docs/sdk/models/errors/getusersuserserrors.md b/docs/sdk/models/errors/getusersuserserrors.md new file mode 100644 index 00000000..e4a3fdba --- /dev/null +++ b/docs/sdk/models/errors/getusersuserserrors.md @@ -0,0 +1,21 @@ +# GetUsersUsersErrors + +## Example Usage + +```typescript +import { GetUsersUsersErrors } from "@lukehagar/plexjs/sdk/models/errors"; + +let value: GetUsersUsersErrors = { + code: 1001, + message: "User could not be authenticated", + status: 401, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------- | ------------------------------- | ------------------------------- | ------------------------------- | ------------------------------- | +| `code` | *number* | :heavy_minus_sign: | N/A | 1001 | +| `message` | *string* | :heavy_minus_sign: | N/A | User could not be authenticated | +| `status` | *number* | :heavy_minus_sign: | N/A | 401 | \ No newline at end of file diff --git a/docs/sdk/models/operations/alllibraries.md b/docs/sdk/models/operations/alllibraries.md new file mode 100644 index 00000000..1c585d09 --- /dev/null +++ b/docs/sdk/models/operations/alllibraries.md @@ -0,0 +1,18 @@ +# AllLibraries + +Indicates if the user has access to all libraries. + +## Example Usage + +```typescript +import { AllLibraries } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: AllLibraries = AllLibraries.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/allowcameraupload.md b/docs/sdk/models/operations/allowcameraupload.md new file mode 100644 index 00000000..83910ffd --- /dev/null +++ b/docs/sdk/models/operations/allowcameraupload.md @@ -0,0 +1,18 @@ +# AllowCameraUpload + +Indicates if the user is allowed to upload from a camera. + +## Example Usage + +```typescript +import { AllowCameraUpload } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: AllowCameraUpload = AllowCameraUpload.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/allowchannels.md b/docs/sdk/models/operations/allowchannels.md new file mode 100644 index 00000000..9a0560d9 --- /dev/null +++ b/docs/sdk/models/operations/allowchannels.md @@ -0,0 +1,18 @@ +# AllowChannels + +Indicates if the user has access to channels. + +## Example Usage + +```typescript +import { AllowChannels } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: AllowChannels = AllowChannels.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/allowsubtitleadmin.md b/docs/sdk/models/operations/allowsubtitleadmin.md new file mode 100644 index 00000000..e6342bb4 --- /dev/null +++ b/docs/sdk/models/operations/allowsubtitleadmin.md @@ -0,0 +1,18 @@ +# AllowSubtitleAdmin + +Indicates if the user can manage subtitles. + +## Example Usage + +```typescript +import { AllowSubtitleAdmin } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: AllowSubtitleAdmin = AllowSubtitleAdmin.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/allowsync.md b/docs/sdk/models/operations/allowsync.md new file mode 100644 index 00000000..93e4f80b --- /dev/null +++ b/docs/sdk/models/operations/allowsync.md @@ -0,0 +1,18 @@ +# AllowSync + +Indicates if the user is allowed to sync media. + +## Example Usage + +```typescript +import { AllowSync } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: AllowSync = AllowSync.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/allowtuners.md b/docs/sdk/models/operations/allowtuners.md new file mode 100644 index 00000000..8875b6c4 --- /dev/null +++ b/docs/sdk/models/operations/allowtuners.md @@ -0,0 +1,18 @@ +# AllowTuners + +Indicates if the user is allowed to use tuners. + +## Example Usage + +```typescript +import { AllowTuners } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: AllowTuners = AllowTuners.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/gettopwatchedcontentmetadata.md b/docs/sdk/models/operations/gettopwatchedcontentmetadata.md index 761ce1c1..2ed3da6c 100644 --- a/docs/sdk/models/operations/gettopwatchedcontentmetadata.md +++ b/docs/sdk/models/operations/gettopwatchedcontentmetadata.md @@ -108,4 +108,4 @@ let value: GetTopWatchedContentMetadata = { | `country` | [operations.GetTopWatchedContentCountry](../../../sdk/models/operations/gettopwatchedcontentcountry.md)[] | :heavy_minus_sign: | N/A | | | `guids` | [operations.GetTopWatchedContentGuids](../../../sdk/models/operations/gettopwatchedcontentguids.md)[] | :heavy_minus_sign: | N/A | | | `role` | [operations.GetTopWatchedContentRole](../../../sdk/models/operations/gettopwatchedcontentrole.md)[] | :heavy_minus_sign: | N/A | | -| `user` | [operations.User](../../../sdk/models/operations/user.md)[] | :heavy_minus_sign: | N/A | | \ No newline at end of file +| `user` | [operations.GetTopWatchedContentUser](../../../sdk/models/operations/gettopwatchedcontentuser.md)[] | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/docs/sdk/models/operations/gettopwatchedcontentuser.md b/docs/sdk/models/operations/gettopwatchedcontentuser.md new file mode 100644 index 00000000..ed12355a --- /dev/null +++ b/docs/sdk/models/operations/gettopwatchedcontentuser.md @@ -0,0 +1,17 @@ +# GetTopWatchedContentUser + +## Example Usage + +```typescript +import { GetTopWatchedContentUser } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: GetTopWatchedContentUser = { + id: 220, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | +| `id` | *number* | :heavy_minus_sign: | N/A | 220 | \ No newline at end of file diff --git a/docs/sdk/models/operations/getusersmediacontainer.md b/docs/sdk/models/operations/getusersmediacontainer.md new file mode 100644 index 00000000..e2bc8039 --- /dev/null +++ b/docs/sdk/models/operations/getusersmediacontainer.md @@ -0,0 +1,53 @@ +# GetUsersMediaContainer + +Container holding user and server details. + +## Example Usage + +```typescript +import { GetUsersMediaContainer } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: GetUsersMediaContainer = { + friendlyName: "myPlex", + identifier: "com.plexapp.plugins.myplex", + machineIdentifier: "3dff4c4da3b1229a649aa574a9e2b419a684a20e", + totalSize: 30, + size: 30, + user: [ + { + id: 22526914, + title: "Plex User", + username: "zgfuc7krcqfimrmb9lsl5j", + email: "zgfuc7krcqfimrmb9lsl5j@protonmail.com", + recommendationsPlaylistId: "", + thumb: "https://plex.tv/users/3346028014e93acd/avatar?c=1731605021", + filterAll: "", + filterMovies: "", + filterMusic: "", + filterPhotos: "", + filterTelevision: "", + server: [ + { + id: 907759180, + serverId: 9999999, + machineIdentifier: "fbb8aa6be6e0c997c6268bc2b4431c8807f70a3", + name: "ConnectedUserFlix", + lastSeenAt: 1556281940, + numLibraries: 16, + }, + ], + }, + ], +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | +| `friendlyName` | *string* | :heavy_check_mark: | The friendly name of the Plex instance. | myPlex | +| `identifier` | *string* | :heavy_check_mark: | N/A | com.plexapp.plugins.myplex | +| `machineIdentifier` | *string* | :heavy_check_mark: | Unique Machine identifier of the Plex server. | 3dff4c4da3b1229a649aa574a9e2b419a684a20e | +| `totalSize` | *number* | :heavy_check_mark: | Total number of users. | 30 | +| `size` | *number* | :heavy_check_mark: | Number of users in the current response. | 30 | +| `user` | [operations.User](../../../sdk/models/operations/user.md)[] | :heavy_check_mark: | List of users with access to the Plex server. | | \ No newline at end of file diff --git a/docs/sdk/models/operations/getusersrequest.md b/docs/sdk/models/operations/getusersrequest.md new file mode 100644 index 00000000..bd8a91ba --- /dev/null +++ b/docs/sdk/models/operations/getusersrequest.md @@ -0,0 +1,41 @@ +# GetUsersRequest + +## Example Usage + +```typescript +import { GetUsersRequest } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: GetUsersRequest = { + clientID: "3381b62b-9ab7-4e37-827b-203e9809eb58", + clientName: "Plex for Roku", + deviceNickname: "Roku 3", + deviceName: "Chrome", + deviceScreenResolution: "1487x1165,2560x1440", + clientVersion: "2.4.1", + platform: "Roku", + clientFeatures: "external-media,indirect-media,hub-style-list", + model: "4200X", + xPlexSessionId: "97e136ef-4ddd-4ff3-89a7-a5820c96c2ca", + xPlexLanguage: "en", + platformVersion: "4.3 build 1057", + xPlexToken: "CV5xoxjTpFKUzBTShsaf", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | +| `clientID` | *string* | :heavy_check_mark: | An opaque identifier unique to the client (UUID, serial number, or other unique device ID) | 3381b62b-9ab7-4e37-827b-203e9809eb58 | +| `clientName` | *string* | :heavy_minus_sign: | The name of the client application. (Plex Web, Plex Media Server, etc.) | Plex for Roku | +| `deviceNickname` | *string* | :heavy_minus_sign: | A relatively friendly name for the client device | Roku 3 | +| `deviceName` | *string* | :heavy_minus_sign: | The name of the device the client application is running on. This is used to track the client application and its usage. (Chrome, Safari, etc.) | Chrome | +| `deviceScreenResolution` | *string* | :heavy_minus_sign: | The resolution of the device the client application is running on. This is used to track the client application and its usage. (1487x1165,2560x1440) | 1487x1165,2560x1440 | +| `clientVersion` | *string* | :heavy_minus_sign: | The version of the client application. | 2.4.1 | +| `platform` | *string* | :heavy_minus_sign: | The platform of the client application. | Roku | +| `clientFeatures` | *string* | :heavy_minus_sign: | The features of the client application. This is used to track the client application and its usage. (external-media,indirect-media,hub-style-list) | external-media,indirect-media,hub-style-list | +| `model` | *string* | :heavy_minus_sign: | A potentially less friendly identifier for the device model | 4200X | +| `xPlexSessionId` | *string* | :heavy_minus_sign: | The session ID of the client application. This is used to track the client application and its usage. (97e136ef-4ddd-4ff3-89a7-a5820c96c2ca) | 97e136ef-4ddd-4ff3-89a7-a5820c96c2ca | +| `xPlexLanguage` | *string* | :heavy_minus_sign: | The language of the client application. | en | +| `platformVersion` | *string* | :heavy_minus_sign: | The version of the platform | 4.3 build 1057 | +| `xPlexToken` | *string* | :heavy_check_mark: | An authentication token, obtained from plex.tv | CV5xoxjTpFKUzBTShsaf | \ No newline at end of file diff --git a/docs/sdk/models/operations/getusersresponse.md b/docs/sdk/models/operations/getusersresponse.md new file mode 100644 index 00000000..2a5c769c --- /dev/null +++ b/docs/sdk/models/operations/getusersresponse.md @@ -0,0 +1,24 @@ +# GetUsersResponse + +## Example Usage + +```typescript +import { GetUsersResponse } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: GetUsersResponse = { + contentType: "", + statusCode: 101, + rawResponse: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), +}; +``` + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | +| `contentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `statusCode` | *number* | :heavy_check_mark: | HTTP response status code for this operation | +| `rawResponse` | [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `body` | *Uint8Array* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/sdk/models/operations/getusersresponsebody.md b/docs/sdk/models/operations/getusersresponsebody.md new file mode 100644 index 00000000..c0da9c6d --- /dev/null +++ b/docs/sdk/models/operations/getusersresponsebody.md @@ -0,0 +1,50 @@ +# GetUsersResponseBody + +Successful response with media container data in XML + +## Example Usage + +```typescript +import { GetUsersResponseBody } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: GetUsersResponseBody = { + mediaContainer: { + friendlyName: "myPlex", + identifier: "com.plexapp.plugins.myplex", + machineIdentifier: "3dff4c4da3b1229a649aa574a9e2b419a684a20e", + totalSize: 30, + size: 30, + user: [ + { + id: 22526914, + title: "Plex User", + username: "zgfuc7krcqfimrmb9lsl5j", + email: "zgfuc7krcqfimrmb9lsl5j@protonmail.com", + recommendationsPlaylistId: "", + thumb: "https://plex.tv/users/3346028014e93acd/avatar?c=1731605021", + filterAll: "", + filterMovies: "", + filterMusic: "", + filterPhotos: "", + filterTelevision: "", + server: [ + { + id: 907759180, + serverId: 9999999, + machineIdentifier: "fbb8aa6be6e0c997c6268bc2b4431c8807f70a3", + name: "ConnectedUserFlix", + lastSeenAt: 1556281940, + numLibraries: 16, + }, + ], + }, + ], + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | +| `mediaContainer` | [operations.GetUsersMediaContainer](../../../sdk/models/operations/getusersmediacontainer.md) | :heavy_minus_sign: | Container holding user and server details. | \ No newline at end of file diff --git a/docs/sdk/models/operations/getusersserver.md b/docs/sdk/models/operations/getusersserver.md new file mode 100644 index 00000000..cd5ac592 --- /dev/null +++ b/docs/sdk/models/operations/getusersserver.md @@ -0,0 +1,30 @@ +# GetUsersServer + +## Example Usage + +```typescript +import { GetUsersServer } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: GetUsersServer = { + id: 907759180, + serverId: 9999999, + machineIdentifier: "fbb8aa6be6e0c997c6268bc2b4431c8807f70a3", + name: "ConnectedUserFlix", + lastSeenAt: 1556281940, + numLibraries: 16, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| `id` | *number* | :heavy_check_mark: | Unique ID of the server of the connected user | 907759180 | +| `serverId` | *number* | :heavy_check_mark: | ID of the actual Plex server. | 9999999 | +| `machineIdentifier` | *string* | :heavy_check_mark: | Machine identifier of the Plex server. | fbb8aa6be6e0c997c6268bc2b4431c8807f70a3 | +| `name` | *string* | :heavy_check_mark: | Name of the Plex server of the connected user. | ConnectedUserFlix | +| `lastSeenAt` | *number* | :heavy_check_mark: | N/A | 1556281940 | +| `numLibraries` | *number* | :heavy_check_mark: | Number of libraries in the server this user has access to. | 16 | +| `allLibraries` | [operations.AllLibraries](../../../sdk/models/operations/alllibraries.md) | :heavy_minus_sign: | N/A | 1 | +| `owned` | [operations.Owned](../../../sdk/models/operations/owned.md) | :heavy_minus_sign: | N/A | 1 | +| `pending` | [operations.Pending](../../../sdk/models/operations/pending.md) | :heavy_minus_sign: | N/A | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/home.md b/docs/sdk/models/operations/home.md new file mode 100644 index 00000000..2e1944dd --- /dev/null +++ b/docs/sdk/models/operations/home.md @@ -0,0 +1,18 @@ +# Home + +Indicates if the user is part of a home group. + +## Example Usage + +```typescript +import { Home } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: Home = Home.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/owned.md b/docs/sdk/models/operations/owned.md new file mode 100644 index 00000000..752c1432 --- /dev/null +++ b/docs/sdk/models/operations/owned.md @@ -0,0 +1,18 @@ +# Owned + +Indicates if the user owns the server. + +## Example Usage + +```typescript +import { Owned } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: Owned = Owned.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/pending.md b/docs/sdk/models/operations/pending.md new file mode 100644 index 00000000..df06536b --- /dev/null +++ b/docs/sdk/models/operations/pending.md @@ -0,0 +1,18 @@ +# Pending + +Indicates if the server is pending approval. + +## Example Usage + +```typescript +import { Pending } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: Pending = Pending.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/protected.md b/docs/sdk/models/operations/protected.md new file mode 100644 index 00000000..db456484 --- /dev/null +++ b/docs/sdk/models/operations/protected.md @@ -0,0 +1,18 @@ +# Protected + +Indicates whether the account is protected. + +## Example Usage + +```typescript +import { Protected } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: Protected = Protected.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/restricted.md b/docs/sdk/models/operations/restricted.md new file mode 100644 index 00000000..f149001b --- /dev/null +++ b/docs/sdk/models/operations/restricted.md @@ -0,0 +1,18 @@ +# Restricted + +Indicates if the user has restricted access. + +## Example Usage + +```typescript +import { Restricted } from "@lukehagar/plexjs/sdk/models/operations"; + +let value: Restricted = Restricted.Enable; +``` + +## Values + +| Name | Value | +| --------- | --------- | +| `Disable` | 0 | +| `Enable` | 1 | \ No newline at end of file diff --git a/docs/sdk/models/operations/user.md b/docs/sdk/models/operations/user.md index 27c0dc9d..ef270300 100644 --- a/docs/sdk/models/operations/user.md +++ b/docs/sdk/models/operations/user.md @@ -6,12 +6,51 @@ import { User } from "@lukehagar/plexjs/sdk/models/operations"; let value: User = { - id: 220, + id: 22526914, + title: "Plex User", + username: "zgfuc7krcqfimrmb9lsl5j", + email: "zgfuc7krcqfimrmb9lsl5j@protonmail.com", + recommendationsPlaylistId: "", + thumb: "https://plex.tv/users/3346028014e93acd/avatar?c=1731605021", + filterAll: "", + filterMovies: "", + filterMusic: "", + filterPhotos: "", + filterTelevision: "", + server: [ + { + id: 907759180, + serverId: 9999999, + machineIdentifier: "fbb8aa6be6e0c997c6268bc2b4431c8807f70a3", + name: "ConnectedUserFlix", + lastSeenAt: 1556281940, + numLibraries: 16, + }, + ], }; ``` ## Fields -| Field | Type | Required | Description | Example | -| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | -| `id` | *number* | :heavy_minus_sign: | N/A | 220 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `id` | *number* | :heavy_check_mark: | User's unique ID. | 22526914 | +| `title` | *string* | :heavy_check_mark: | User's display name. | Plex User | +| `username` | *string* | :heavy_check_mark: | User's username. | zgfuc7krcqfimrmb9lsl5j | +| `email` | *string* | :heavy_check_mark: | User's email address. | zgfuc7krcqfimrmb9lsl5j@protonmail.com | +| `recommendationsPlaylistId` | *string* | :heavy_minus_sign: | ID of the user's recommendation playlist. | | +| `thumb` | *string* | :heavy_check_mark: | URL to the user's avatar image. | https://plex.tv/users/3346028014e93acd/avatar?c=1731605021 | +| `protected` | [operations.Protected](../../../sdk/models/operations/protected.md) | :heavy_minus_sign: | N/A | 1 | +| `home` | [operations.Home](../../../sdk/models/operations/home.md) | :heavy_minus_sign: | N/A | 1 | +| `allowTuners` | [operations.AllowTuners](../../../sdk/models/operations/allowtuners.md) | :heavy_minus_sign: | N/A | 1 | +| `allowSync` | [operations.AllowSync](../../../sdk/models/operations/allowsync.md) | :heavy_minus_sign: | N/A | 1 | +| `allowCameraUpload` | [operations.AllowCameraUpload](../../../sdk/models/operations/allowcameraupload.md) | :heavy_minus_sign: | N/A | 1 | +| `allowChannels` | [operations.AllowChannels](../../../sdk/models/operations/allowchannels.md) | :heavy_minus_sign: | N/A | 1 | +| `allowSubtitleAdmin` | [operations.AllowSubtitleAdmin](../../../sdk/models/operations/allowsubtitleadmin.md) | :heavy_minus_sign: | N/A | 1 | +| `filterAll` | *string* | :heavy_minus_sign: | Filters applied for all content. | | +| `filterMovies` | *string* | :heavy_minus_sign: | Filters applied for movies. | | +| `filterMusic` | *string* | :heavy_minus_sign: | Filters applied for music. | | +| `filterPhotos` | *string* | :heavy_minus_sign: | Filters applied for photos. | | +| `filterTelevision` | *string* | :heavy_minus_sign: | Filters applied for television. | | +| `restricted` | [operations.Restricted](../../../sdk/models/operations/restricted.md) | :heavy_minus_sign: | N/A | 1 | +| `server` | [operations.GetUsersServer](../../../sdk/models/operations/getusersserver.md)[] | :heavy_check_mark: | List of servers owned by the user. | | \ No newline at end of file diff --git a/docs/sdks/users/README.md b/docs/sdks/users/README.md new file mode 100644 index 00000000..b4ebdffb --- /dev/null +++ b/docs/sdks/users/README.md @@ -0,0 +1,107 @@ +# Users +(*users*) + +## Overview + +### Available Operations + +* [getUsers](#getusers) - Get list of all connected users + +## getUsers + +Get list of all users that are friends and have library access with the provided Plex authentication token + +### Example Usage + +```typescript +import { PlexAPI } from "@lukehagar/plexjs"; + +const plexAPI = new PlexAPI(); + +async function run() { + const result = await plexAPI.users.getUsers({ + clientID: "3381b62b-9ab7-4e37-827b-203e9809eb58", + clientName: "Plex for Roku", + deviceNickname: "Roku 3", + deviceName: "Chrome", + deviceScreenResolution: "1487x1165,2560x1440", + clientVersion: "2.4.1", + platform: "Roku", + clientFeatures: "external-media,indirect-media,hub-style-list", + model: "4200X", + xPlexSessionId: "97e136ef-4ddd-4ff3-89a7-a5820c96c2ca", + xPlexLanguage: "en", + platformVersion: "4.3 build 1057", + xPlexToken: "CV5xoxjTpFKUzBTShsaf", + }); + + // Handle the result + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { PlexAPICore } from "@lukehagar/plexjs/core.js"; +import { usersGetUsers } from "@lukehagar/plexjs/funcs/usersGetUsers.js"; + +// Use `PlexAPICore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const plexAPI = new PlexAPICore(); + +async function run() { + const res = await usersGetUsers(plexAPI, { + clientID: "3381b62b-9ab7-4e37-827b-203e9809eb58", + clientName: "Plex for Roku", + deviceNickname: "Roku 3", + deviceName: "Chrome", + deviceScreenResolution: "1487x1165,2560x1440", + clientVersion: "2.4.1", + platform: "Roku", + clientFeatures: "external-media,indirect-media,hub-style-list", + model: "4200X", + xPlexSessionId: "97e136ef-4ddd-4ff3-89a7-a5820c96c2ca", + xPlexLanguage: "en", + platformVersion: "4.3 build 1057", + xPlexToken: "CV5xoxjTpFKUzBTShsaf", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [operations.GetUsersRequest](../../sdk/models/operations/getusersrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | +| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. | + +### Response + +**Promise\<[operations.GetUsersResponse](../../sdk/models/operations/getusersresponse.md)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| --------------------------- | --------------------------- | --------------------------- | +| errors.GetUsersBadRequest | 400 | application/json | +| errors.GetUsersUnauthorized | 401 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/jsr.json b/jsr.json index 63fbc61c..ac041b18 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@lukehagar/plexjs", - "version": "0.32.4", + "version": "0.32.5", "exports": { ".": "./src/index.ts", "./sdk/models/errors": "./src/sdk/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index 7f91e4c2..88e00820 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lukehagar/plexjs", - "version": "0.32.4", + "version": "0.32.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lukehagar/plexjs", - "version": "0.32.4", + "version": "0.32.5", "devDependencies": { "@eslint/js": "^9.19.0", "eslint": "^9.19.0", diff --git a/package.json b/package.json index 7b891794..93f30957 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lukehagar/plexjs", - "version": "0.32.4", + "version": "0.32.5", "author": "LukeHagar", "main": "./index.js", "sideEffects": false, diff --git a/src/funcs/usersGetUsers.ts b/src/funcs/usersGetUsers.ts new file mode 100644 index 00000000..b924a53f --- /dev/null +++ b/src/funcs/usersGetUsers.ts @@ -0,0 +1,199 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { PlexAPICore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.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 { GetUsersServerList } from "../sdk/models/operations/getusers.js"; +import * as operations from "../sdk/models/operations/index.js"; +import { Result } from "../sdk/types/fp.js"; + +/** + * Get list of all connected users + * + * @remarks + * Get list of all users that are friends and have library access with the provided Plex authentication token + */ +export async function usersGetUsers( + client: PlexAPICore, + request: operations.GetUsersRequest, + options?: RequestOptions, +): Promise< + Result< + operations.GetUsersResponse, + | errors.GetUsersBadRequest + | errors.GetUsersUnauthorized + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => operations.GetUsersRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const baseURL = options?.serverURL + || pathToFunc(GetUsersServerList[0], { charEncoding: "percent" })(); + + const path = pathToFunc("/users")(); + + const headers = new Headers(compactMap({ + Accept: "application/xml", + "X-Plex-Features": encodeSimple("X-Plex-Features", payload.ClientFeatures, { + explode: false, + charEncoding: "none", + }), + "X-Plex-Client-Identifier": encodeSimple( + "X-Plex-Client-Identifier", + payload.ClientID, + { explode: false, charEncoding: "none" }, + ), + "X-Plex-Product": encodeSimple("X-Plex-Product", payload.ClientName, { + explode: false, + charEncoding: "none", + }), + "X-Plex-Version": encodeSimple("X-Plex-Version", payload.ClientVersion, { + explode: false, + charEncoding: "none", + }), + "X-Plex-Device-Name": encodeSimple( + "X-Plex-Device-Name", + payload.DeviceName, + { explode: false, charEncoding: "none" }, + ), + "X-Plex-Device": encodeSimple("X-Plex-Device", payload.DeviceNickname, { + explode: false, + charEncoding: "none", + }), + "X-Plex-Device-Screen-Resolution": encodeSimple( + "X-Plex-Device-Screen-Resolution", + payload.DeviceScreenResolution, + { explode: false, charEncoding: "none" }, + ), + "X-Plex-Model": encodeSimple("X-Plex-Model", payload.Model, { + explode: false, + charEncoding: "none", + }), + "X-Plex-Platform": encodeSimple("X-Plex-Platform", payload.Platform, { + explode: false, + charEncoding: "none", + }), + "X-Plex-Platform-Version": encodeSimple( + "X-Plex-Platform-Version", + payload.PlatformVersion, + { explode: false, charEncoding: "none" }, + ), + "X-Plex-Language": encodeSimple( + "X-Plex-Language", + payload["X-Plex-Language"], + { explode: false, charEncoding: "none" }, + ), + "X-Plex-Session-Id": encodeSimple( + "X-Plex-Session-Id", + payload["X-Plex-Session-Id"], + { explode: false, charEncoding: "none" }, + ), + "X-Plex-Token": encodeSimple("X-Plex-Token", payload["X-Plex-Token"], { + explode: false, + charEncoding: "none", + }), + })); + + const context = { + operationID: "get-users", + oAuth2Scopes: [], + + resolvedSecurity: null, + + securitySource: null, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }; + + const requestRes = client._createRequest(context, { + method: "GET", + baseURL: baseURL, + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["400", "401", "4XX", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + 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.GetUsersResponse, + | errors.GetUsersBadRequest + | errors.GetUsersUnauthorized + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.bytes(200, operations.GetUsersResponse$inboundSchema, { + ctype: "application/xml", + key: "Body", + }), + M.jsonErr(400, errors.GetUsersBadRequest$inboundSchema), + M.jsonErr(401, errors.GetUsersUnauthorized$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/src/lib/config.ts b/src/lib/config.ts index 5f45f786..f9e9ee61 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -90,7 +90,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.3", - sdkVersion: "0.32.4", + sdkVersion: "0.32.5", genVersion: "2.503.2", - userAgent: "speakeasy-sdk/typescript 0.32.4 2.503.2 0.0.3 @lukehagar/plexjs", + userAgent: "speakeasy-sdk/typescript 0.32.5 2.503.2 0.0.3 @lukehagar/plexjs", } as const; diff --git a/src/sdk/models/errors/getusers.ts b/src/sdk/models/errors/getusers.ts new file mode 100644 index 00000000..1e2b022c --- /dev/null +++ b/src/sdk/models/errors/getusers.ts @@ -0,0 +1,326 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "./sdkvalidationerror.js"; + +export type GetUsersUsersErrors = { + code?: number | undefined; + message?: string | undefined; + status?: number | undefined; +}; + +/** + * Unauthorized - Returned if the X-Plex-Token is missing from the header or query. + */ +export type GetUsersUnauthorizedData = { + errors?: Array | undefined; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse?: Response | undefined; +}; + +/** + * Unauthorized - Returned if the X-Plex-Token is missing from the header or query. + */ +export class GetUsersUnauthorized extends Error { + errors?: Array | undefined; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse?: Response | undefined; + + /** The original data that was passed to this error instance. */ + data$: GetUsersUnauthorizedData; + + constructor(err: GetUsersUnauthorizedData) { + const message = "message" in err && typeof err.message === "string" + ? err.message + : `API error occurred: ${JSON.stringify(err)}`; + super(message); + this.data$ = err; + + if (err.errors != null) this.errors = err.errors; + if (err.rawResponse != null) this.rawResponse = err.rawResponse; + + this.name = "GetUsersUnauthorized"; + } +} + +export type GetUsersErrors = { + code?: number | undefined; + message?: string | undefined; + status?: number | undefined; +}; + +/** + * Bad Request - A parameter was not specified, or was specified incorrectly. + */ +export type GetUsersBadRequestData = { + errors?: Array | undefined; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse?: Response | undefined; +}; + +/** + * Bad Request - A parameter was not specified, or was specified incorrectly. + */ +export class GetUsersBadRequest extends Error { + errors?: Array | undefined; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse?: Response | undefined; + + /** The original data that was passed to this error instance. */ + data$: GetUsersBadRequestData; + + constructor(err: GetUsersBadRequestData) { + const message = "message" in err && typeof err.message === "string" + ? err.message + : `API error occurred: ${JSON.stringify(err)}`; + super(message); + this.data$ = err; + + if (err.errors != null) this.errors = err.errors; + if (err.rawResponse != null) this.rawResponse = err.rawResponse; + + this.name = "GetUsersBadRequest"; + } +} + +/** @internal */ +export const GetUsersUsersErrors$inboundSchema: z.ZodType< + GetUsersUsersErrors, + z.ZodTypeDef, + unknown +> = z.object({ + code: z.number().int().optional(), + message: z.string().optional(), + status: z.number().int().optional(), +}); + +/** @internal */ +export type GetUsersUsersErrors$Outbound = { + code?: number | undefined; + message?: string | undefined; + status?: number | undefined; +}; + +/** @internal */ +export const GetUsersUsersErrors$outboundSchema: z.ZodType< + GetUsersUsersErrors$Outbound, + z.ZodTypeDef, + GetUsersUsersErrors +> = z.object({ + code: z.number().int().optional(), + message: z.string().optional(), + status: z.number().int().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetUsersUsersErrors$ { + /** @deprecated use `GetUsersUsersErrors$inboundSchema` instead. */ + export const inboundSchema = GetUsersUsersErrors$inboundSchema; + /** @deprecated use `GetUsersUsersErrors$outboundSchema` instead. */ + export const outboundSchema = GetUsersUsersErrors$outboundSchema; + /** @deprecated use `GetUsersUsersErrors$Outbound` instead. */ + export type Outbound = GetUsersUsersErrors$Outbound; +} + +export function getUsersUsersErrorsToJSON( + getUsersUsersErrors: GetUsersUsersErrors, +): string { + return JSON.stringify( + GetUsersUsersErrors$outboundSchema.parse(getUsersUsersErrors), + ); +} + +export function getUsersUsersErrorsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetUsersUsersErrors$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetUsersUsersErrors' from JSON`, + ); +} + +/** @internal */ +export const GetUsersUnauthorized$inboundSchema: z.ZodType< + GetUsersUnauthorized, + z.ZodTypeDef, + unknown +> = z.object({ + errors: z.array(z.lazy(() => GetUsersUsersErrors$inboundSchema)).optional(), + RawResponse: z.instanceof(Response).optional(), +}) + .transform((v) => { + const remapped = remap$(v, { + "RawResponse": "rawResponse", + }); + + return new GetUsersUnauthorized(remapped); + }); + +/** @internal */ +export type GetUsersUnauthorized$Outbound = { + errors?: Array | undefined; + RawResponse?: never | undefined; +}; + +/** @internal */ +export const GetUsersUnauthorized$outboundSchema: z.ZodType< + GetUsersUnauthorized$Outbound, + z.ZodTypeDef, + GetUsersUnauthorized +> = z.instanceof(GetUsersUnauthorized) + .transform(v => v.data$) + .pipe( + z.object({ + errors: z.array(z.lazy(() => GetUsersUsersErrors$outboundSchema)) + .optional(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }).optional(), + }).transform((v) => { + return remap$(v, { + rawResponse: "RawResponse", + }); + }), + ); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetUsersUnauthorized$ { + /** @deprecated use `GetUsersUnauthorized$inboundSchema` instead. */ + export const inboundSchema = GetUsersUnauthorized$inboundSchema; + /** @deprecated use `GetUsersUnauthorized$outboundSchema` instead. */ + export const outboundSchema = GetUsersUnauthorized$outboundSchema; + /** @deprecated use `GetUsersUnauthorized$Outbound` instead. */ + export type Outbound = GetUsersUnauthorized$Outbound; +} + +/** @internal */ +export const GetUsersErrors$inboundSchema: z.ZodType< + GetUsersErrors, + z.ZodTypeDef, + unknown +> = z.object({ + code: z.number().int().optional(), + message: z.string().optional(), + status: z.number().int().optional(), +}); + +/** @internal */ +export type GetUsersErrors$Outbound = { + code?: number | undefined; + message?: string | undefined; + status?: number | undefined; +}; + +/** @internal */ +export const GetUsersErrors$outboundSchema: z.ZodType< + GetUsersErrors$Outbound, + z.ZodTypeDef, + GetUsersErrors +> = z.object({ + code: z.number().int().optional(), + message: z.string().optional(), + status: z.number().int().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetUsersErrors$ { + /** @deprecated use `GetUsersErrors$inboundSchema` instead. */ + export const inboundSchema = GetUsersErrors$inboundSchema; + /** @deprecated use `GetUsersErrors$outboundSchema` instead. */ + export const outboundSchema = GetUsersErrors$outboundSchema; + /** @deprecated use `GetUsersErrors$Outbound` instead. */ + export type Outbound = GetUsersErrors$Outbound; +} + +export function getUsersErrorsToJSON(getUsersErrors: GetUsersErrors): string { + return JSON.stringify(GetUsersErrors$outboundSchema.parse(getUsersErrors)); +} + +export function getUsersErrorsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetUsersErrors$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetUsersErrors' from JSON`, + ); +} + +/** @internal */ +export const GetUsersBadRequest$inboundSchema: z.ZodType< + GetUsersBadRequest, + z.ZodTypeDef, + unknown +> = z.object({ + errors: z.array(z.lazy(() => GetUsersErrors$inboundSchema)).optional(), + RawResponse: z.instanceof(Response).optional(), +}) + .transform((v) => { + const remapped = remap$(v, { + "RawResponse": "rawResponse", + }); + + return new GetUsersBadRequest(remapped); + }); + +/** @internal */ +export type GetUsersBadRequest$Outbound = { + errors?: Array | undefined; + RawResponse?: never | undefined; +}; + +/** @internal */ +export const GetUsersBadRequest$outboundSchema: z.ZodType< + GetUsersBadRequest$Outbound, + z.ZodTypeDef, + GetUsersBadRequest +> = z.instanceof(GetUsersBadRequest) + .transform(v => v.data$) + .pipe( + z.object({ + errors: z.array(z.lazy(() => GetUsersErrors$outboundSchema)).optional(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }).optional(), + }).transform((v) => { + return remap$(v, { + rawResponse: "RawResponse", + }); + }), + ); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetUsersBadRequest$ { + /** @deprecated use `GetUsersBadRequest$inboundSchema` instead. */ + export const inboundSchema = GetUsersBadRequest$inboundSchema; + /** @deprecated use `GetUsersBadRequest$outboundSchema` instead. */ + export const outboundSchema = GetUsersBadRequest$outboundSchema; + /** @deprecated use `GetUsersBadRequest$Outbound` instead. */ + export type Outbound = GetUsersBadRequest$Outbound; +} diff --git a/src/sdk/models/errors/index.ts b/src/sdk/models/errors/index.ts index 0221f644..d110ab42 100644 --- a/src/sdk/models/errors/index.ts +++ b/src/sdk/models/errors/index.ts @@ -62,6 +62,7 @@ export * from "./gettranscodesessions.js"; export * from "./gettransienttoken.js"; export * from "./getupdatestatus.js"; export * from "./getuserfriends.js"; +export * from "./getusers.js"; export * from "./getwatchlist.js"; export * from "./httpclienterrors.js"; export * from "./logline.js"; diff --git a/src/sdk/models/operations/gettopwatchedcontent.ts b/src/sdk/models/operations/gettopwatchedcontent.ts index 83b5302b..57f3cd10 100644 --- a/src/sdk/models/operations/gettopwatchedcontent.ts +++ b/src/sdk/models/operations/gettopwatchedcontent.ts @@ -74,7 +74,7 @@ export type GetTopWatchedContentRole = { thumb?: string | undefined; }; -export type User = { +export type GetTopWatchedContentUser = { id?: number | undefined; }; @@ -110,7 +110,7 @@ export type GetTopWatchedContentMetadata = { country?: Array | undefined; guids?: Array | undefined; role?: Array | undefined; - user?: Array | undefined; + user?: Array | undefined; }; export type GetTopWatchedContentMediaContainer = { @@ -475,46 +475,56 @@ export function getTopWatchedContentRoleFromJSON( } /** @internal */ -export const User$inboundSchema: z.ZodType = z - .object({ - id: z.number().int().optional(), - }); +export const GetTopWatchedContentUser$inboundSchema: z.ZodType< + GetTopWatchedContentUser, + z.ZodTypeDef, + unknown +> = z.object({ + id: z.number().int().optional(), +}); /** @internal */ -export type User$Outbound = { +export type GetTopWatchedContentUser$Outbound = { id?: number | undefined; }; /** @internal */ -export const User$outboundSchema: z.ZodType = - z.object({ - id: z.number().int().optional(), - }); +export const GetTopWatchedContentUser$outboundSchema: z.ZodType< + GetTopWatchedContentUser$Outbound, + z.ZodTypeDef, + GetTopWatchedContentUser +> = z.object({ + id: z.number().int().optional(), +}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ -export namespace User$ { - /** @deprecated use `User$inboundSchema` instead. */ - export const inboundSchema = User$inboundSchema; - /** @deprecated use `User$outboundSchema` instead. */ - export const outboundSchema = User$outboundSchema; - /** @deprecated use `User$Outbound` instead. */ - export type Outbound = User$Outbound; +export namespace GetTopWatchedContentUser$ { + /** @deprecated use `GetTopWatchedContentUser$inboundSchema` instead. */ + export const inboundSchema = GetTopWatchedContentUser$inboundSchema; + /** @deprecated use `GetTopWatchedContentUser$outboundSchema` instead. */ + export const outboundSchema = GetTopWatchedContentUser$outboundSchema; + /** @deprecated use `GetTopWatchedContentUser$Outbound` instead. */ + export type Outbound = GetTopWatchedContentUser$Outbound; } -export function userToJSON(user: User): string { - return JSON.stringify(User$outboundSchema.parse(user)); +export function getTopWatchedContentUserToJSON( + getTopWatchedContentUser: GetTopWatchedContentUser, +): string { + return JSON.stringify( + GetTopWatchedContentUser$outboundSchema.parse(getTopWatchedContentUser), + ); } -export function userFromJSON( +export function getTopWatchedContentUserFromJSON( jsonString: string, -): SafeParseResult { +): SafeParseResult { return safeParse( jsonString, - (x) => User$inboundSchema.parse(JSON.parse(x)), - `Failed to parse 'User' from JSON`, + (x) => GetTopWatchedContentUser$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetTopWatchedContentUser' from JSON`, ); } @@ -559,7 +569,8 @@ export const GetTopWatchedContentMetadata$inboundSchema: z.ZodType< .optional(), Role: z.array(z.lazy(() => GetTopWatchedContentRole$inboundSchema)) .optional(), - User: z.array(z.lazy(() => User$inboundSchema)).optional(), + User: z.array(z.lazy(() => GetTopWatchedContentUser$inboundSchema)) + .optional(), }).transform((v) => { return remap$(v, { "Genre": "genre", @@ -603,7 +614,7 @@ export type GetTopWatchedContentMetadata$Outbound = { Country?: Array | undefined; Guid?: Array | undefined; Role?: Array | undefined; - User?: Array | undefined; + User?: Array | undefined; }; /** @internal */ @@ -648,7 +659,8 @@ export const GetTopWatchedContentMetadata$outboundSchema: z.ZodType< .optional(), role: z.array(z.lazy(() => GetTopWatchedContentRole$outboundSchema)) .optional(), - user: z.array(z.lazy(() => User$outboundSchema)).optional(), + user: z.array(z.lazy(() => GetTopWatchedContentUser$outboundSchema)) + .optional(), }).transform((v) => { return remap$(v, { genre: "Genre", diff --git a/src/sdk/models/operations/getusers.ts b/src/sdk/models/operations/getusers.ts new file mode 100644 index 00000000..a97177e1 --- /dev/null +++ b/src/sdk/models/operations/getusers.ts @@ -0,0 +1,1039 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import * as b64$ from "../../../lib/base64.js"; +import { remap as remap$ } from "../../../lib/primitives.js"; +import { safeParse } from "../../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; + +export const GetUsersServerList = [ + "https://plex.tv/api", +] as const; + +export type GetUsersRequest = { + /** + * An opaque identifier unique to the client (UUID, serial number, or other unique device ID) + */ + clientID: string; + /** + * The name of the client application. (Plex Web, Plex Media Server, etc.) + */ + clientName?: string | undefined; + /** + * A relatively friendly name for the client device + */ + deviceNickname?: string | undefined; + /** + * The name of the device the client application is running on. This is used to track the client application and its usage. (Chrome, Safari, etc.) + */ + deviceName?: string | undefined; + /** + * The resolution of the device the client application is running on. This is used to track the client application and its usage. (1487x1165,2560x1440) + */ + deviceScreenResolution?: string | undefined; + /** + * The version of the client application. + */ + clientVersion?: string | undefined; + /** + * The platform of the client application. + */ + platform?: string | undefined; + /** + * The features of the client application. This is used to track the client application and its usage. (external-media,indirect-media,hub-style-list) + */ + clientFeatures?: string | undefined; + /** + * A potentially less friendly identifier for the device model + */ + model?: string | undefined; + /** + * The session ID of the client application. This is used to track the client application and its usage. (97e136ef-4ddd-4ff3-89a7-a5820c96c2ca) + */ + xPlexSessionId?: string | undefined; + /** + * The language of the client application. + */ + xPlexLanguage?: string | undefined; + /** + * The version of the platform + */ + platformVersion?: string | undefined; + /** + * An authentication token, obtained from plex.tv + */ + xPlexToken: string; +}; + +/** + * Indicates whether the account is protected. + */ +export enum Protected { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the user is part of a home group. + */ +export enum Home { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the user is allowed to use tuners. + */ +export enum AllowTuners { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the user is allowed to sync media. + */ +export enum AllowSync { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the user is allowed to upload from a camera. + */ +export enum AllowCameraUpload { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the user has access to channels. + */ +export enum AllowChannels { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the user can manage subtitles. + */ +export enum AllowSubtitleAdmin { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the user has restricted access. + */ +export enum Restricted { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the user has access to all libraries. + */ +export enum AllLibraries { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the user owns the server. + */ +export enum Owned { + Disable = 0, + Enable = 1, +} + +/** + * Indicates if the server is pending approval. + */ +export enum Pending { + Disable = 0, + Enable = 1, +} + +export type GetUsersServer = { + /** + * Unique ID of the server of the connected user + */ + id: number; + /** + * ID of the actual Plex server. + */ + serverId: number; + /** + * Machine identifier of the Plex server. + */ + machineIdentifier: string; + /** + * Name of the Plex server of the connected user. + */ + name: string; + lastSeenAt: number; + /** + * Number of libraries in the server this user has access to. + */ + numLibraries: number; + allLibraries?: AllLibraries | undefined; + owned?: Owned | undefined; + pending?: Pending | undefined; +}; + +export type User = { + /** + * User's unique ID. + */ + id: number; + /** + * User's display name. + */ + title: string; + /** + * User's username. + */ + username: string; + /** + * User's email address. + */ + email: string; + /** + * ID of the user's recommendation playlist. + */ + recommendationsPlaylistId?: string | null | undefined; + /** + * URL to the user's avatar image. + */ + thumb: string; + protected?: Protected | undefined; + home?: Home | undefined; + allowTuners?: AllowTuners | undefined; + allowSync?: AllowSync | undefined; + allowCameraUpload?: AllowCameraUpload | undefined; + allowChannels?: AllowChannels | undefined; + allowSubtitleAdmin?: AllowSubtitleAdmin | undefined; + /** + * Filters applied for all content. + */ + filterAll?: string | null | undefined; + /** + * Filters applied for movies. + */ + filterMovies?: string | null | undefined; + /** + * Filters applied for music. + */ + filterMusic?: string | null | undefined; + /** + * Filters applied for photos. + */ + filterPhotos?: string | null | undefined; + /** + * Filters applied for television. + */ + filterTelevision?: string | undefined; + restricted?: Restricted | undefined; + /** + * List of servers owned by the user. + */ + server: Array; +}; + +/** + * Container holding user and server details. + */ +export type GetUsersMediaContainer = { + /** + * The friendly name of the Plex instance. + */ + friendlyName: string; + identifier: string; + /** + * Unique Machine identifier of the Plex server. + */ + machineIdentifier: string; + /** + * Total number of users. + */ + totalSize: number; + /** + * Number of users in the current response. + */ + size: number; + /** + * List of users with access to the Plex server. + */ + user: Array; +}; + +/** + * Successful response with media container data in XML + */ +export type GetUsersResponseBody = { + /** + * Container holding user and server details. + */ + mediaContainer?: GetUsersMediaContainer | undefined; +}; + +export type GetUsersResponse = { + /** + * HTTP response content type for this operation + */ + contentType: string; + /** + * HTTP response status code for this operation + */ + statusCode: number; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse: Response; + body?: Uint8Array | string | undefined; +}; + +/** @internal */ +export const GetUsersRequest$inboundSchema: z.ZodType< + GetUsersRequest, + z.ZodTypeDef, + unknown +> = z.object({ + ClientID: z.string(), + ClientName: z.string().optional(), + DeviceNickname: z.string().optional(), + DeviceName: z.string().optional(), + DeviceScreenResolution: z.string().optional(), + ClientVersion: z.string().optional(), + Platform: z.string().optional(), + ClientFeatures: z.string().optional(), + Model: z.string().optional(), + "X-Plex-Session-Id": z.string().optional(), + "X-Plex-Language": z.string().optional(), + PlatformVersion: z.string().optional(), + "X-Plex-Token": z.string(), +}).transform((v) => { + return remap$(v, { + "ClientID": "clientID", + "ClientName": "clientName", + "DeviceNickname": "deviceNickname", + "DeviceName": "deviceName", + "DeviceScreenResolution": "deviceScreenResolution", + "ClientVersion": "clientVersion", + "Platform": "platform", + "ClientFeatures": "clientFeatures", + "Model": "model", + "X-Plex-Session-Id": "xPlexSessionId", + "X-Plex-Language": "xPlexLanguage", + "PlatformVersion": "platformVersion", + "X-Plex-Token": "xPlexToken", + }); +}); + +/** @internal */ +export type GetUsersRequest$Outbound = { + ClientID: string; + ClientName?: string | undefined; + DeviceNickname?: string | undefined; + DeviceName?: string | undefined; + DeviceScreenResolution?: string | undefined; + ClientVersion?: string | undefined; + Platform?: string | undefined; + ClientFeatures?: string | undefined; + Model?: string | undefined; + "X-Plex-Session-Id"?: string | undefined; + "X-Plex-Language"?: string | undefined; + PlatformVersion?: string | undefined; + "X-Plex-Token": string; +}; + +/** @internal */ +export const GetUsersRequest$outboundSchema: z.ZodType< + GetUsersRequest$Outbound, + z.ZodTypeDef, + GetUsersRequest +> = z.object({ + clientID: z.string(), + clientName: z.string().optional(), + deviceNickname: z.string().optional(), + deviceName: z.string().optional(), + deviceScreenResolution: z.string().optional(), + clientVersion: z.string().optional(), + platform: z.string().optional(), + clientFeatures: z.string().optional(), + model: z.string().optional(), + xPlexSessionId: z.string().optional(), + xPlexLanguage: z.string().optional(), + platformVersion: z.string().optional(), + xPlexToken: z.string(), +}).transform((v) => { + return remap$(v, { + clientID: "ClientID", + clientName: "ClientName", + deviceNickname: "DeviceNickname", + deviceName: "DeviceName", + deviceScreenResolution: "DeviceScreenResolution", + clientVersion: "ClientVersion", + platform: "Platform", + clientFeatures: "ClientFeatures", + model: "Model", + xPlexSessionId: "X-Plex-Session-Id", + xPlexLanguage: "X-Plex-Language", + platformVersion: "PlatformVersion", + xPlexToken: "X-Plex-Token", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetUsersRequest$ { + /** @deprecated use `GetUsersRequest$inboundSchema` instead. */ + export const inboundSchema = GetUsersRequest$inboundSchema; + /** @deprecated use `GetUsersRequest$outboundSchema` instead. */ + export const outboundSchema = GetUsersRequest$outboundSchema; + /** @deprecated use `GetUsersRequest$Outbound` instead. */ + export type Outbound = GetUsersRequest$Outbound; +} + +export function getUsersRequestToJSON( + getUsersRequest: GetUsersRequest, +): string { + return JSON.stringify(GetUsersRequest$outboundSchema.parse(getUsersRequest)); +} + +export function getUsersRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetUsersRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetUsersRequest' from JSON`, + ); +} + +/** @internal */ +export const Protected$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(Protected); + +/** @internal */ +export const Protected$outboundSchema: z.ZodNativeEnum = + Protected$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Protected$ { + /** @deprecated use `Protected$inboundSchema` instead. */ + export const inboundSchema = Protected$inboundSchema; + /** @deprecated use `Protected$outboundSchema` instead. */ + export const outboundSchema = Protected$outboundSchema; +} + +/** @internal */ +export const Home$inboundSchema: z.ZodNativeEnum = z.nativeEnum( + Home, +); + +/** @internal */ +export const Home$outboundSchema: z.ZodNativeEnum = + Home$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Home$ { + /** @deprecated use `Home$inboundSchema` instead. */ + export const inboundSchema = Home$inboundSchema; + /** @deprecated use `Home$outboundSchema` instead. */ + export const outboundSchema = Home$outboundSchema; +} + +/** @internal */ +export const AllowTuners$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(AllowTuners); + +/** @internal */ +export const AllowTuners$outboundSchema: z.ZodNativeEnum = + AllowTuners$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AllowTuners$ { + /** @deprecated use `AllowTuners$inboundSchema` instead. */ + export const inboundSchema = AllowTuners$inboundSchema; + /** @deprecated use `AllowTuners$outboundSchema` instead. */ + export const outboundSchema = AllowTuners$outboundSchema; +} + +/** @internal */ +export const AllowSync$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(AllowSync); + +/** @internal */ +export const AllowSync$outboundSchema: z.ZodNativeEnum = + AllowSync$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AllowSync$ { + /** @deprecated use `AllowSync$inboundSchema` instead. */ + export const inboundSchema = AllowSync$inboundSchema; + /** @deprecated use `AllowSync$outboundSchema` instead. */ + export const outboundSchema = AllowSync$outboundSchema; +} + +/** @internal */ +export const AllowCameraUpload$inboundSchema: z.ZodNativeEnum< + typeof AllowCameraUpload +> = z.nativeEnum(AllowCameraUpload); + +/** @internal */ +export const AllowCameraUpload$outboundSchema: z.ZodNativeEnum< + typeof AllowCameraUpload +> = AllowCameraUpload$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AllowCameraUpload$ { + /** @deprecated use `AllowCameraUpload$inboundSchema` instead. */ + export const inboundSchema = AllowCameraUpload$inboundSchema; + /** @deprecated use `AllowCameraUpload$outboundSchema` instead. */ + export const outboundSchema = AllowCameraUpload$outboundSchema; +} + +/** @internal */ +export const AllowChannels$inboundSchema: z.ZodNativeEnum< + typeof AllowChannels +> = z.nativeEnum(AllowChannels); + +/** @internal */ +export const AllowChannels$outboundSchema: z.ZodNativeEnum< + typeof AllowChannels +> = AllowChannels$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AllowChannels$ { + /** @deprecated use `AllowChannels$inboundSchema` instead. */ + export const inboundSchema = AllowChannels$inboundSchema; + /** @deprecated use `AllowChannels$outboundSchema` instead. */ + export const outboundSchema = AllowChannels$outboundSchema; +} + +/** @internal */ +export const AllowSubtitleAdmin$inboundSchema: z.ZodNativeEnum< + typeof AllowSubtitleAdmin +> = z.nativeEnum(AllowSubtitleAdmin); + +/** @internal */ +export const AllowSubtitleAdmin$outboundSchema: z.ZodNativeEnum< + typeof AllowSubtitleAdmin +> = AllowSubtitleAdmin$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AllowSubtitleAdmin$ { + /** @deprecated use `AllowSubtitleAdmin$inboundSchema` instead. */ + export const inboundSchema = AllowSubtitleAdmin$inboundSchema; + /** @deprecated use `AllowSubtitleAdmin$outboundSchema` instead. */ + export const outboundSchema = AllowSubtitleAdmin$outboundSchema; +} + +/** @internal */ +export const Restricted$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(Restricted); + +/** @internal */ +export const Restricted$outboundSchema: z.ZodNativeEnum = + Restricted$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Restricted$ { + /** @deprecated use `Restricted$inboundSchema` instead. */ + export const inboundSchema = Restricted$inboundSchema; + /** @deprecated use `Restricted$outboundSchema` instead. */ + export const outboundSchema = Restricted$outboundSchema; +} + +/** @internal */ +export const AllLibraries$inboundSchema: z.ZodNativeEnum = + z.nativeEnum(AllLibraries); + +/** @internal */ +export const AllLibraries$outboundSchema: z.ZodNativeEnum = + AllLibraries$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AllLibraries$ { + /** @deprecated use `AllLibraries$inboundSchema` instead. */ + export const inboundSchema = AllLibraries$inboundSchema; + /** @deprecated use `AllLibraries$outboundSchema` instead. */ + export const outboundSchema = AllLibraries$outboundSchema; +} + +/** @internal */ +export const Owned$inboundSchema: z.ZodNativeEnum = z.nativeEnum( + Owned, +); + +/** @internal */ +export const Owned$outboundSchema: z.ZodNativeEnum = + Owned$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Owned$ { + /** @deprecated use `Owned$inboundSchema` instead. */ + export const inboundSchema = Owned$inboundSchema; + /** @deprecated use `Owned$outboundSchema` instead. */ + export const outboundSchema = Owned$outboundSchema; +} + +/** @internal */ +export const Pending$inboundSchema: z.ZodNativeEnum = z + .nativeEnum(Pending); + +/** @internal */ +export const Pending$outboundSchema: z.ZodNativeEnum = + Pending$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Pending$ { + /** @deprecated use `Pending$inboundSchema` instead. */ + export const inboundSchema = Pending$inboundSchema; + /** @deprecated use `Pending$outboundSchema` instead. */ + export const outboundSchema = Pending$outboundSchema; +} + +/** @internal */ +export const GetUsersServer$inboundSchema: z.ZodType< + GetUsersServer, + z.ZodTypeDef, + unknown +> = z.object({ + id: z.number().int(), + serverId: z.number().int(), + machineIdentifier: z.string(), + name: z.string(), + lastSeenAt: z.number().int(), + numLibraries: z.number().int(), + allLibraries: AllLibraries$inboundSchema, + owned: Owned$inboundSchema, + pending: Pending$inboundSchema, +}); + +/** @internal */ +export type GetUsersServer$Outbound = { + id: number; + serverId: number; + machineIdentifier: string; + name: string; + lastSeenAt: number; + numLibraries: number; + allLibraries: number; + owned: number; + pending: number; +}; + +/** @internal */ +export const GetUsersServer$outboundSchema: z.ZodType< + GetUsersServer$Outbound, + z.ZodTypeDef, + GetUsersServer +> = z.object({ + id: z.number().int(), + serverId: z.number().int(), + machineIdentifier: z.string(), + name: z.string(), + lastSeenAt: z.number().int(), + numLibraries: z.number().int(), + allLibraries: AllLibraries$outboundSchema.default(AllLibraries.Disable), + owned: Owned$outboundSchema.default(Owned.Disable), + pending: Pending$outboundSchema.default(Pending.Disable), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetUsersServer$ { + /** @deprecated use `GetUsersServer$inboundSchema` instead. */ + export const inboundSchema = GetUsersServer$inboundSchema; + /** @deprecated use `GetUsersServer$outboundSchema` instead. */ + export const outboundSchema = GetUsersServer$outboundSchema; + /** @deprecated use `GetUsersServer$Outbound` instead. */ + export type Outbound = GetUsersServer$Outbound; +} + +export function getUsersServerToJSON(getUsersServer: GetUsersServer): string { + return JSON.stringify(GetUsersServer$outboundSchema.parse(getUsersServer)); +} + +export function getUsersServerFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetUsersServer$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetUsersServer' from JSON`, + ); +} + +/** @internal */ +export const User$inboundSchema: z.ZodType = z + .object({ + id: z.number().int(), + title: z.string(), + username: z.string(), + email: z.string(), + recommendationsPlaylistId: z.nullable(z.string()).optional(), + thumb: z.string(), + protected: Protected$inboundSchema, + home: Home$inboundSchema, + allowTuners: AllowTuners$inboundSchema, + allowSync: AllowSync$inboundSchema, + allowCameraUpload: AllowCameraUpload$inboundSchema, + allowChannels: AllowChannels$inboundSchema, + allowSubtitleAdmin: AllowSubtitleAdmin$inboundSchema, + filterAll: z.nullable(z.string()).optional(), + filterMovies: z.nullable(z.string()).optional(), + filterMusic: z.nullable(z.string()).optional(), + filterPhotos: z.nullable(z.string()).optional(), + filterTelevision: z.string().optional(), + restricted: Restricted$inboundSchema, + Server: z.array(z.lazy(() => GetUsersServer$inboundSchema)), + }).transform((v) => { + return remap$(v, { + "Server": "server", + }); + }); + +/** @internal */ +export type User$Outbound = { + id: number; + title: string; + username: string; + email: string; + recommendationsPlaylistId?: string | null | undefined; + thumb: string; + protected: number; + home: number; + allowTuners: number; + allowSync: number; + allowCameraUpload: number; + allowChannels: number; + allowSubtitleAdmin: number; + filterAll?: string | null | undefined; + filterMovies?: string | null | undefined; + filterMusic?: string | null | undefined; + filterPhotos?: string | null | undefined; + filterTelevision?: string | undefined; + restricted: number; + Server: Array; +}; + +/** @internal */ +export const User$outboundSchema: z.ZodType = + z.object({ + id: z.number().int(), + title: z.string(), + username: z.string(), + email: z.string(), + recommendationsPlaylistId: z.nullable(z.string()).optional(), + thumb: z.string(), + protected: Protected$outboundSchema.default(Protected.Disable), + home: Home$outboundSchema.default(Home.Disable), + allowTuners: AllowTuners$outboundSchema.default(AllowTuners.Disable), + allowSync: AllowSync$outboundSchema.default(AllowSync.Disable), + allowCameraUpload: AllowCameraUpload$outboundSchema.default( + AllowCameraUpload.Disable, + ), + allowChannels: AllowChannels$outboundSchema.default(AllowChannels.Disable), + allowSubtitleAdmin: AllowSubtitleAdmin$outboundSchema.default( + AllowSubtitleAdmin.Disable, + ), + filterAll: z.nullable(z.string()).optional(), + filterMovies: z.nullable(z.string()).optional(), + filterMusic: z.nullable(z.string()).optional(), + filterPhotos: z.nullable(z.string()).optional(), + filterTelevision: z.string().optional(), + restricted: Restricted$outboundSchema.default(Restricted.Disable), + server: z.array(z.lazy(() => GetUsersServer$outboundSchema)), + }).transform((v) => { + return remap$(v, { + server: "Server", + }); + }); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace User$ { + /** @deprecated use `User$inboundSchema` instead. */ + export const inboundSchema = User$inboundSchema; + /** @deprecated use `User$outboundSchema` instead. */ + export const outboundSchema = User$outboundSchema; + /** @deprecated use `User$Outbound` instead. */ + export type Outbound = User$Outbound; +} + +export function userToJSON(user: User): string { + return JSON.stringify(User$outboundSchema.parse(user)); +} + +export function userFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => User$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'User' from JSON`, + ); +} + +/** @internal */ +export const GetUsersMediaContainer$inboundSchema: z.ZodType< + GetUsersMediaContainer, + z.ZodTypeDef, + unknown +> = z.object({ + friendlyName: z.string(), + identifier: z.string(), + machineIdentifier: z.string(), + totalSize: z.number().int(), + size: z.number().int(), + User: z.array(z.lazy(() => User$inboundSchema)), +}).transform((v) => { + return remap$(v, { + "User": "user", + }); +}); + +/** @internal */ +export type GetUsersMediaContainer$Outbound = { + friendlyName: string; + identifier: string; + machineIdentifier: string; + totalSize: number; + size: number; + User: Array; +}; + +/** @internal */ +export const GetUsersMediaContainer$outboundSchema: z.ZodType< + GetUsersMediaContainer$Outbound, + z.ZodTypeDef, + GetUsersMediaContainer +> = z.object({ + friendlyName: z.string(), + identifier: z.string(), + machineIdentifier: z.string(), + totalSize: z.number().int(), + size: z.number().int(), + user: z.array(z.lazy(() => User$outboundSchema)), +}).transform((v) => { + return remap$(v, { + user: "User", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetUsersMediaContainer$ { + /** @deprecated use `GetUsersMediaContainer$inboundSchema` instead. */ + export const inboundSchema = GetUsersMediaContainer$inboundSchema; + /** @deprecated use `GetUsersMediaContainer$outboundSchema` instead. */ + export const outboundSchema = GetUsersMediaContainer$outboundSchema; + /** @deprecated use `GetUsersMediaContainer$Outbound` instead. */ + export type Outbound = GetUsersMediaContainer$Outbound; +} + +export function getUsersMediaContainerToJSON( + getUsersMediaContainer: GetUsersMediaContainer, +): string { + return JSON.stringify( + GetUsersMediaContainer$outboundSchema.parse(getUsersMediaContainer), + ); +} + +export function getUsersMediaContainerFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetUsersMediaContainer$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetUsersMediaContainer' from JSON`, + ); +} + +/** @internal */ +export const GetUsersResponseBody$inboundSchema: z.ZodType< + GetUsersResponseBody, + z.ZodTypeDef, + unknown +> = z.object({ + MediaContainer: z.lazy(() => GetUsersMediaContainer$inboundSchema).optional(), +}).transform((v) => { + return remap$(v, { + "MediaContainer": "mediaContainer", + }); +}); + +/** @internal */ +export type GetUsersResponseBody$Outbound = { + MediaContainer?: GetUsersMediaContainer$Outbound | undefined; +}; + +/** @internal */ +export const GetUsersResponseBody$outboundSchema: z.ZodType< + GetUsersResponseBody$Outbound, + z.ZodTypeDef, + GetUsersResponseBody +> = z.object({ + mediaContainer: z.lazy(() => GetUsersMediaContainer$outboundSchema) + .optional(), +}).transform((v) => { + return remap$(v, { + mediaContainer: "MediaContainer", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetUsersResponseBody$ { + /** @deprecated use `GetUsersResponseBody$inboundSchema` instead. */ + export const inboundSchema = GetUsersResponseBody$inboundSchema; + /** @deprecated use `GetUsersResponseBody$outboundSchema` instead. */ + export const outboundSchema = GetUsersResponseBody$outboundSchema; + /** @deprecated use `GetUsersResponseBody$Outbound` instead. */ + export type Outbound = GetUsersResponseBody$Outbound; +} + +export function getUsersResponseBodyToJSON( + getUsersResponseBody: GetUsersResponseBody, +): string { + return JSON.stringify( + GetUsersResponseBody$outboundSchema.parse(getUsersResponseBody), + ); +} + +export function getUsersResponseBodyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetUsersResponseBody$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetUsersResponseBody' from JSON`, + ); +} + +/** @internal */ +export const GetUsersResponse$inboundSchema: z.ZodType< + GetUsersResponse, + z.ZodTypeDef, + unknown +> = z.object({ + ContentType: z.string(), + StatusCode: z.number().int(), + RawResponse: z.instanceof(Response), + Body: b64$.zodInbound.optional(), +}).transform((v) => { + return remap$(v, { + "ContentType": "contentType", + "StatusCode": "statusCode", + "RawResponse": "rawResponse", + "Body": "body", + }); +}); + +/** @internal */ +export type GetUsersResponse$Outbound = { + ContentType: string; + StatusCode: number; + RawResponse: never; + Body?: Uint8Array | undefined; +}; + +/** @internal */ +export const GetUsersResponse$outboundSchema: z.ZodType< + GetUsersResponse$Outbound, + z.ZodTypeDef, + GetUsersResponse +> = z.object({ + contentType: z.string(), + statusCode: z.number().int(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), + body: b64$.zodOutbound.optional(), +}).transform((v) => { + return remap$(v, { + contentType: "ContentType", + statusCode: "StatusCode", + rawResponse: "RawResponse", + body: "Body", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GetUsersResponse$ { + /** @deprecated use `GetUsersResponse$inboundSchema` instead. */ + export const inboundSchema = GetUsersResponse$inboundSchema; + /** @deprecated use `GetUsersResponse$outboundSchema` instead. */ + export const outboundSchema = GetUsersResponse$outboundSchema; + /** @deprecated use `GetUsersResponse$Outbound` instead. */ + export type Outbound = GetUsersResponse$Outbound; +} + +export function getUsersResponseToJSON( + getUsersResponse: GetUsersResponse, +): string { + return JSON.stringify( + GetUsersResponse$outboundSchema.parse(getUsersResponse), + ); +} + +export function getUsersResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetUsersResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetUsersResponse' from JSON`, + ); +} diff --git a/src/sdk/models/operations/index.ts b/src/sdk/models/operations/index.ts index ac9b169b..074e821c 100644 --- a/src/sdk/models/operations/index.ts +++ b/src/sdk/models/operations/index.ts @@ -63,6 +63,7 @@ export * from "./gettranscodesessions.js"; export * from "./gettransienttoken.js"; export * from "./getupdatestatus.js"; export * from "./getuserfriends.js"; +export * from "./getusers.js"; export * from "./getwatchlist.js"; export * from "./logline.js"; export * from "./logmultiline.js"; diff --git a/src/sdk/sdk.ts b/src/sdk/sdk.ts index a3ab3b0c..215ac89e 100644 --- a/src/sdk/sdk.ts +++ b/src/sdk/sdk.ts @@ -17,6 +17,7 @@ import { Server } from "./server.js"; import { Sessions } from "./sessions.js"; import { Statistics } from "./statistics.js"; import { Updater } from "./updater.js"; +import { Users } from "./users.js"; import { Video } from "./video.js"; import { Watchlist } from "./watchlist.js"; @@ -100,4 +101,9 @@ export class PlexAPI extends ClientSDK { get updater(): Updater { return (this._updater ??= new Updater(this._options)); } + + private _users?: Users; + get users(): Users { + return (this._users ??= new Users(this._options)); + } } diff --git a/src/sdk/users.ts b/src/sdk/users.ts new file mode 100644 index 00000000..c76bfd77 --- /dev/null +++ b/src/sdk/users.ts @@ -0,0 +1,27 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { usersGetUsers } from "../funcs/usersGetUsers.js"; +import { ClientSDK, RequestOptions } from "../lib/sdks.js"; +import * as operations from "./models/operations/index.js"; +import { unwrapAsync } from "./types/fp.js"; + +export class Users extends ClientSDK { + /** + * Get list of all connected users + * + * @remarks + * Get list of all users that are friends and have library access with the provided Plex authentication token + */ + async getUsers( + request: operations.GetUsersRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(usersGetUsers( + this, + request, + options, + )); + } +}