From 41d23df5b56d74a99bd59088095f5ba1fff68691 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Wed, 6 Aug 2025 00:02:39 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.598.0 --- .speakeasy/gen.lock | 247 +++- .speakeasy/gen.yaml | 6 +- .speakeasy/workflow.lock | 14 +- README.md | 226 +++- RELEASES.md | 12 +- codeSamples.yaml | 2 +- docs/sdks/activities/README.md | 2 + docs/sdks/authentication/README.md | 4 + docs/sdks/butler/README.md | 5 + docs/sdks/hubs/README.md | 3 + docs/sdks/library/README.md | 22 +- docs/sdks/log/README.md | 3 + docs/sdks/media/README.md | 5 + docs/sdks/playlists/README.md | 9 + docs/sdks/plex/README.md | 7 + docs/sdks/search/README.md | 3 + docs/sdks/server/README.md | 9 + docs/sdks/sessions/README.md | 4 + docs/sdks/statistics/README.md | 3 + docs/sdks/updater/README.md | 3 + docs/sdks/users/README.md | 1 + docs/sdks/video/README.md | 2 + docs/sdks/watchlist/README.md | 1 + pyproject.toml | 4 +- src/plex_api_client/_version.py | 6 +- src/plex_api_client/activities.py | 125 +- src/plex_api_client/authentication.py | 259 ++-- src/plex_api_client/basesdk.py | 8 +- src/plex_api_client/butler.py | 299 ++--- src/plex_api_client/hubs.py | 175 +-- src/plex_api_client/library.py | 1191 ++++++----------- src/plex_api_client/log.py | 175 +-- src/plex_api_client/media.py | 299 ++--- .../models/components/__init__.py | 5 +- src/plex_api_client/models/errors/__init__.py | 14 +- .../models/errors/addplaylistcontents.py | 30 +- .../models/errors/applyupdates.py | 30 +- .../models/errors/cancelserveractivities.py | 30 +- .../models/errors/checkforupdates.py | 30 +- .../models/errors/clearplaylistcontents.py | 30 +- .../models/errors/createplaylist.py | 30 +- .../models/errors/deletelibrary.py | 30 +- .../models/errors/deleteplaylist.py | 30 +- .../models/errors/enablepapertrail.py | 30 +- .../models/errors/get_actors_library.py | 30 +- .../models/errors/get_all_libraries.py | 30 +- .../models/errors/get_banner_image.py | 30 +- .../models/errors/get_countries_library.py | 30 +- .../models/errors/get_genres_library.py | 30 +- .../models/errors/get_library_details.py | 30 +- .../models/errors/get_library_items.py | 30 +- .../models/errors/get_library_sections_all.py | 30 +- .../models/errors/get_media_meta_data.py | 30 +- .../models/errors/get_media_providers.py | 30 +- .../errors/get_recently_added_library.py | 30 +- .../errors/get_refresh_library_metadata.py | 30 +- .../models/errors/get_search_all_libraries.py | 30 +- .../models/errors/get_search_library.py | 30 +- .../models/errors/get_server_identity.py | 16 +- .../models/errors/get_server_resources.py | 30 +- .../models/errors/get_thumb_image.py | 30 +- .../models/errors/get_users.py | 30 +- .../models/errors/get_watch_list.py | 30 +- .../models/errors/getavailableclients.py | 30 +- .../models/errors/getbandwidthstatistics.py | 30 +- .../models/errors/getbutlertasks.py | 30 +- .../models/errors/getcompanionsdata.py | 30 +- .../models/errors/getdevices.py | 30 +- .../models/errors/getfilehash.py | 30 +- .../models/errors/getgeodata.py | 30 +- .../models/errors/getglobalhubs.py | 30 +- .../models/errors/gethomedata.py | 30 +- .../models/errors/getlibraryhubs.py | 30 +- .../models/errors/getmetadatachildren.py | 30 +- .../models/errors/getmyplexaccount.py | 30 +- src/plex_api_client/models/errors/getpin.py | 16 +- .../models/errors/getplaylist.py | 30 +- .../models/errors/getplaylistcontents.py | 30 +- .../models/errors/getplaylists.py | 30 +- .../models/errors/getresizedphoto.py | 30 +- .../models/errors/getresourcesstatistics.py | 30 +- .../models/errors/getsearchresults.py | 30 +- .../models/errors/getserveractivities.py | 30 +- .../models/errors/getservercapabilities.py | 30 +- .../models/errors/getserverlist.py | 30 +- .../models/errors/getserverpreferences.py | 30 +- .../models/errors/getsessionhistory.py | 30 +- .../models/errors/getsessions.py | 30 +- .../errors/getsourceconnectioninformation.py | 34 +- .../models/errors/getstatistics.py | 30 +- .../models/errors/gettimeline.py | 30 +- .../models/errors/gettokenbypinid.py | 30 +- .../models/errors/gettokendetails.py | 30 +- .../models/errors/gettopwatchedcontent.py | 30 +- .../models/errors/gettranscodesessions.py | 30 +- .../models/errors/gettransienttoken.py | 30 +- .../models/errors/getupdatestatus.py | 30 +- .../models/errors/getuserfriends.py | 30 +- src/plex_api_client/models/errors/logline.py | 30 +- .../models/errors/logmultiline.py | 30 +- .../models/errors/markplayed.py | 30 +- .../models/errors/markunplayed.py | 30 +- .../models/errors/no_response_error.py | 13 + .../models/errors/performsearch.py | 30 +- .../models/errors/performvoicesearch.py | 30 +- .../models/errors/plexapierror.py | 26 + .../models/errors/post_users_sign_in_data.py | 30 +- .../models/errors/responsevalidationerror.py | 25 + src/plex_api_client/models/errors/sdkerror.py | 44 +- .../models/errors/startalltasks.py | 30 +- .../models/errors/starttask.py | 30 +- .../models/errors/startuniversaltranscode.py | 30 +- .../models/errors/stopalltasks.py | 30 +- src/plex_api_client/models/errors/stoptask.py | 30 +- .../models/errors/stoptranscodesession.py | 30 +- .../models/errors/updateplaylist.py | 30 +- .../models/errors/updateplayprogress.py | 30 +- .../models/errors/uploadplaylist.py | 30 +- .../models/operations/__init__.py | 5 +- src/plex_api_client/playlists.py | 563 +++----- src/plex_api_client/plex.py | 451 +++---- src/plex_api_client/search.py | 183 +-- src/plex_api_client/server.py | 577 +++----- src/plex_api_client/sessions.py | 257 ++-- src/plex_api_client/statistics.py | 203 +-- src/plex_api_client/updater.py | 183 +-- src/plex_api_client/users.py | 59 +- src/plex_api_client/utils/__init__.py | 5 +- src/plex_api_client/utils/forms.py | 79 +- src/plex_api_client/utils/serializers.py | 5 +- .../utils/unmarshal_json_response.py | 24 + src/plex_api_client/video.py | 117 +- src/plex_api_client/watchlist.py | 67 +- 133 files changed, 3915 insertions(+), 4470 deletions(-) create mode 100644 src/plex_api_client/models/errors/no_response_error.py create mode 100644 src/plex_api_client/models/errors/plexapierror.py create mode 100644 src/plex_api_client/models/errors/responsevalidationerror.py create mode 100644 src/plex_api_client/utils/unmarshal_json_response.py diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 3720304..fe84358 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: 3eeea668-4ef4-464e-a888-bdfa023bedf5 management: docChecksum: 77bdddd188d0778dc73b7f7906e1677c docVersion: 0.0.3 - speakeasyVersion: 1.558.1 - generationVersion: 2.623.4 - releaseVersion: 0.28.2 - configChecksum: c2b77fa004a60ce087dfa61844f66be9 + speakeasyVersion: 1.598.0 + generationVersion: 2.674.1 + releaseVersion: 0.29.0 + configChecksum: 3ffacf9e19a64bb4ce4211cf73d7ec53 repoURL: https://github.com/LukeHagar/plexpy.git repoSubDirectory: . installationURL: https://github.com/LukeHagar/plexpy.git @@ -15,14 +15,14 @@ features: python: additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.19.2 + core: 5.19.6 defaultEnabledRetries: 0.2.0 deprecations: 3.0.2 downloadStreams: 1.0.1 enumUnions: 0.1.0 enums: 3.1.2 envVarSecurityUsage: 0.3.2 - errors: 3.2.0 + errors: 3.3.1 flattening: 3.1.1 globalSecurity: 3.0.3 globalSecurityCallbacks: 1.0.0 @@ -39,7 +39,6 @@ features: uploadStreams: 1.0.0 generatedFiles: - .gitattributes - - .python-version - .vscode/settings.json - USAGE.md - docs/models/components/security.md @@ -1063,9 +1062,12 @@ generatedFiles: - src/plex_api_client/models/errors/logmultiline.py - src/plex_api_client/models/errors/markplayed.py - src/plex_api_client/models/errors/markunplayed.py + - src/plex_api_client/models/errors/no_response_error.py - src/plex_api_client/models/errors/performsearch.py - src/plex_api_client/models/errors/performvoicesearch.py + - src/plex_api_client/models/errors/plexapierror.py - src/plex_api_client/models/errors/post_users_sign_in_data.py + - src/plex_api_client/models/errors/responsevalidationerror.py - src/plex_api_client/models/errors/sdkerror.py - src/plex_api_client/models/errors/startalltasks.py - src/plex_api_client/models/errors/starttask.py @@ -1188,6 +1190,7 @@ generatedFiles: - src/plex_api_client/utils/retries.py - src/plex_api_client/utils/security.py - src/plex_api_client/utils/serializers.py + - src/plex_api_client/utils/unmarshal_json_response.py - src/plex_api_client/utils/url.py - src/plex_api_client/utils/values.py - src/plex_api_client/video.py @@ -1314,6 +1317,17 @@ 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}]} + speakeasy-default-update-play-progress: + parameters: + query: + key: "" + time: 90000 + state: "played" + responses: + "400": + application/json: {"errors": [{"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}]} get-banner-image: speakeasy-default-get-banner-image: parameters: @@ -1371,6 +1385,24 @@ 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}, {"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}]} + speakeasy-default-get-timeline: + parameters: + query: + ratingKey: 23409 + key: "/library/metadata/23409" + state: "playing" + hasMDE: 1 + time: 2000 + duration: 10000 + context: "home:hub.continueWatching" + playQueueItemID: 1 + playBackTime: 2000 + row: 1 + responses: + "400": + application/json: {"errors": [{"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}]} startUniversalTranscode: "": parameters: @@ -1396,6 +1428,30 @@ 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}, {"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}]} + speakeasy-default-start-universal-transcode: + parameters: + query: + hasMDE: 1 + path: "/library/metadata/23409" + mediaIndex: 0 + partIndex: 0 + protocol: "hls" + fastSeek: 0 + directPlay: 0 + directStream: 0 + subtitleSize: 100 + subtites: "burn" + audioBoost: 100 + location: "lan" + mediaBufferSize: 102400 + session: "zvcage8b7rkioqcm8f4uns4c" + addDebugOverlay: 0 + autoAdjustQuality: 0 + responses: + "400": + application/json: {"errors": [{"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}]} getServerActivities: speakeasy-default-get-server-activities: responses: @@ -1415,6 +1471,15 @@ 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}]} + speakeasy-default-cancel-server-activities: + parameters: + path: + activityUUID: "25b71ed5-0f9d-461c-baa7-d404e9e10d3e" + responses: + "400": + application/json: {"errors": [{"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}]} getButlerTasks: speakeasy-default-get-butler-tasks: responses: @@ -1510,6 +1575,21 @@ 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}, {"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}]} + speakeasy-default-get-server-resources: + parameters: + query: + includeHttps: 1 + includeRelay: 1 + includeIPv6: 1 + header: + X-Plex-Client-Identifier: "3381b62b-9ab7-4e37-827b-203e9809eb58" + responses: + "200": + application/json: [{"name": "", "product": "Ergonomic Plastic Hat", "productVersion": "", "platform": "", "platformVersion": "", "device": "Mobile", "clientIdentifier": "", "createdAt": "2019-06-24T11:38:02Z", "lastSeenAt": "2019-06-24T11:38:02Z", "provides": "", "ownerId": null, "sourceTitle": "", "publicAddress": "", "accessToken": "", "owned": true, "home": false, "synced": false, "relay": true, "presence": false, "httpsRequired": true, "publicAddressMatches": false, "dnsRebindingProtection": true, "natLoopbackSupported": false, "connections": [{"protocol": "http", "address": "5746 Mount Street", "port": 441996, "uri": "https://wide-kick.name/", "local": false, "relay": true, "IPv6": true}]}] + "400": + application/json: {"errors": [{"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}]} getPin: "": parameters: @@ -1526,6 +1606,21 @@ examples: application/json: {"id": 308667304, "code": "7RQZ", "product": "0", "trusted": false, "qr": "https://plex.tv/api/v2/pins/qr/7RQZ", "clientIdentifier": "string", "location": {"code": "VI", "continent_code": "NA", "country": "United States Virgin Islands", "city": "Amsterdam", "european_union_member": true, "time_zone": "America/St_Thomas", "postal_code": "802", "in_privacy_restricted_country": true, "in_privacy_restricted_region": true, "subdivisions": "Saint Thomas", "coordinates": "18.3381, -64.8941"}, "expiresIn": 876, "createdAt": "2024-07-16T17:03:05Z", "expiresAt": "2024-07-16T17:18:05Z", "authToken": null, "newRegistration": null} "400": application/json: {"errors": [{"code": 1000, "message": "X-Plex-Client-Identifier is missing", "status": 400}]} + speakeasy-default-get-pin: + parameters: + query: + strong: false + header: + X-Plex-Client-Identifier: "3381b62b-9ab7-4e37-827b-203e9809eb58" + X-Plex-Product: "Plex for Roku" + X-Plex-Device: "Roku 3" + X-Plex-Version: "2.4.1" + X-Plex-Platform: "Roku" + responses: + "201": + application/json: {"id": 308667304, "code": "7RQZ", "product": "0", "trusted": false, "qr": "https://plex.tv/api/v2/pins/qr/7RQZ", "clientIdentifier": "string", "location": {"code": "VI", "continent_code": "NA", "country": "United States Virgin Islands", "city": "Amsterdam", "european_union_member": true, "time_zone": "America/St_Thomas", "postal_code": "802", "in_privacy_restricted_country": true, "in_privacy_restricted_region": true, "subdivisions": "Saint Thomas", "coordinates": "18.3381, -64.8941"}, "expiresIn": 876, "createdAt": "2024-07-16T17:03:05Z", "expiresAt": "2024-07-16T17:18:05Z", "authToken": null, "newRegistration": null} + "400": + application/json: {"errors": [{"code": 1000, "message": "X-Plex-Client-Identifier is missing", "status": 400}]} getTokenByPinId: "": parameters: @@ -1540,6 +1635,23 @@ examples: responses: "404": application/json: {"errors": [{"code": 1020, "message": "Code not found or expired"}]} + speakeasy-default-get-token-by-pin-id: + parameters: + path: + pinID: 232248 + header: + X-Plex-Client-Identifier: "3381b62b-9ab7-4e37-827b-203e9809eb58" + X-Plex-Product: "Plex for Roku" + X-Plex-Device: "Roku 3" + X-Plex-Version: "2.4.1" + X-Plex-Platform: "Roku" + responses: + "200": + application/json: {"id": 308667304, "code": "7RQZ", "product": "0", "trusted": false, "qr": "https://plex.tv/api/v2/pins/qr/7RQZ", "clientIdentifier": "string", "location": {"code": "VI", "continent_code": "NA", "country": "United States Virgin Islands", "city": "Amsterdam", "european_union_member": true, "time_zone": "America/St_Thomas", "postal_code": "802", "in_privacy_restricted_country": true, "in_privacy_restricted_region": true, "subdivisions": "Saint Thomas", "coordinates": "18.3381, -64.8941"}, "expiresIn": 876, "createdAt": "2024-07-16T17:03:05Z", "expiresAt": "2024-07-16T17:18:05Z", "authToken": null, "newRegistration": null} + "400": + application/json: {"errors": [{"code": 1000, "message": "X-Plex-Client-Identifier is missing", "status": 400}]} + "404": + application/json: {"errors": [{"code": 1020, "message": "Code not found or expired"}]} getGlobalHubs: speakeasy-default-get-global-hubs: responses: @@ -1794,6 +1906,22 @@ examples: application/json: {"errors": [{"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}]} + speakeasy-default-get-search-all-libraries: + parameters: + query: + query: "" + searchTypes: ["people"] + includeCollections: 1 + includeExternalMedia: 1 + header: + X-Plex-Client-Identifier: "3381b62b-9ab7-4e37-827b-203e9809eb58" + responses: + "200": + application/json: {"MediaContainer": {"size": 50, "allowSync": false, "identifier": "com.plexapp.plugins.library", "librarySectionID": 2, "librarySectionTitle": "TV Series", "librarySectionUUID": "e69655a2-ef48-4aba-bb19-0cc34d1e7d36", "mediaTagPrefix": "/system/bundle/media/flags/", "mediaTagVersion": 1734362201, "SearchResult": [{"score": 0.92, "Directory": {"key": "/library/sections/3/all?actor=197429", "librarySectionID": 1, "librarySectionKey": "/library/sections/1", "librarySectionTitle": "Movies", "librarySectionType": 1, "type": "tag", "id": 197429, "filter": "actor=197429", "tag": "Ben Stiller", "tagType": 4, "tagKey": "5d776826999c64001ec2c606", "thumb": "https://metadata-static.plex.tv/5/people/57bd7c7d6c5c9e2881251b30e5603d3d.jpg", "count": 10}, "Metadata": {"ratingKey": "58683", "key": "/library/metadata/58683", "guid": "plex://movie/5d7768ba96b655001fdc0408", "slug": "4-for-texas", "studio": "20th Century Studios", "type": "movie", "title": "Avatar: The Way of Water", "banner": "/library/metadata/58683/banner/1703239236", "titleSort": "Whale", "contentRating": "PG-13", "summary": "Jake Sully lives with his newfound family formed on the extrasolar moon Pandora.\nOnce a familiar threat returns to finish what was previously started, Jake must\nwork with Neytiri and the army of the Na'vi race to protect their home.\n", "rating": 7.6, "audienceRating": 9.2, "year": 2022, "tagline": "Return to Pandora.", "thumb": "/library/metadata/58683/thumb/1703239236", "art": "/library/metadata/58683/art/1703239236", "theme": "/library/metadata/1/theme/1705636920", "index": 1, "leafCount": 14, "viewedLeafCount": 0, "childCount": 1, "seasonCount": 2022, "duration": 11558112, "originallyAvailableAt": "2022-12-14", "addedAt": 1556281940, "updatedAt": 1556281940, "parentYear": 2010, "audienceRatingImage": "rottentomatoes://image.rating.upright", "chapterSource": "media", "primaryExtraKey": "/library/metadata/58684", "originalTitle": "映画 ブラッククローバー 魔法帝の剣", "parentRatingKey": "66", "grandparentRatingKey": "66", "parentGuid": "plex://show/5d9c081b170e24001f2a7be4", "grandparentGuid": "plex://show/5d9c081b170e24001f2a7be4", "grandparentSlug": "alice-in-borderland-2020", "grandparentKey": "/library/metadata/66", "parentKey": "/library/metadata/66", "grandparentTitle": "Caprica", "grandparentThumb": "/library/metadata/66/thumb/1705716261", "grandparentTheme": "/library/metadata/66/theme/1705716261", "grandparentArt": "/library/metadata/66/art/1705716261", "parentTitle": "Caprica", "parentIndex": 1, "parentThumb": "/library/metadata/66/thumb/1705716261", "ratingImage": "rottentomatoes://image.rating.ripe", "viewCount": 1, "viewOffset": 5222500, "skipCount": 1, "subtype": "clip", "lastRatedAt": 1721813113, "createdAtAccuracy": "epoch,local", "createdAtTZOffset": "0", "lastViewedAt": 1682752242, "userRating": 10, "Image": [{"alt": "Episode 1", "type": "background", "url": "/library/metadata/45521/thumb/1644710589"}], "UltraBlurColors": {"topLeft": "11333b", "topRight": "0a232d", "bottomRight": "73958", "bottomLeft": "1f5066"}, "Guid": [{"id": "{\"imdbExample\":{\"summary\":\"IMDB example\",\"value\":\"imdb://tt13015952\"},\"tmdbExample\":{\"summary\":\"TMDB example\",\"value\":\"tmdb://2434012\"},\"tvdbExample\":{\"summary\":\"TVDB example\",\"value\":\"tvdb://7945991\"}}"}], "librarySectionID": 1, "librarySectionTitle": "Movies", "librarySectionKey": "/library/sections/1", "showOrdering": "absolute", "flattenSeasons": "1", "skipChildren": false, "Media": [{"id": 387322, "duration": 9610350, "bitrate": 25512, "width": 3840, "height": 1602, "aspectRatio": 2.35, "audioChannels": 6, "displayOffset": 50, "audioCodec": "aac", "videoCodec": "hevc", "videoResolution": "4k", "container": "mp4", "videoFrameRate": "24p", "videoProfile": "main 10", "hasVoiceActivity": false, "audioProfile": "dts", "has64bitOffsets": false, "Part": [{"accessible": true, "exists": true, "id": 418385, "key": "/library/parts/418385/1735864239/file.mkv", "indexes": "sd", "duration": 9610350, "file": "/mnt/Movies_1/W/Wicked (2024).mkv", "size": 30649952104, "packetLength": 188, "container": "mkv", "videoProfile": "main 10", "audioProfile": "dts", "has64bitOffsets": false, "hasThumbnail": "1"}]}], "Genre": [{"id": 259, "tag": "Crime"}], "Country": [{"id": 259, "tag": "United States of America"}], "Director": [{"id": 126522, "tag": "Danny Boyle", "thumb": "https://metadata-static.plex.tv/8/people/8d65fa96804802e08f2de09fe014408e.jpg"}], "Writer": [{"id": 126522, "tag": "Jamie P. Hanson", "thumb": "https://metadata-static.plex.tv/8/people/8d65fa96804802e08f2de09fe014408e.jpg"}], "Role": [{"id": 126522, "tag": "Teller", "role": "Self - Judge", "thumb": "https://metadata-static.plex.tv/7/people/708568fd018d7aa8b1032dcf867747e8.jpg"}], "Location": [{"path": "/TV Shows/Clarkson's Farm"}]}}]}} + "400": + application/json: {"errors": [{"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}]} get-media-meta-data: speakeasy-default-get-media-meta-data: parameters: @@ -2115,6 +2243,23 @@ 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}]} + speakeasy-default-post-users-sign-in-data: + parameters: + header: + X-Plex-Client-Identifier: "3381b62b-9ab7-4e37-827b-203e9809eb58" + X-Plex-Product: "Plex for Roku" + X-Plex-Device: "Roku 3" + X-Plex-Version: "2.4.1" + X-Plex-Platform: "Roku" + requestBody: + application/x-www-form-urlencoded: {"login": "username@email.com", "password": "password123", "rememberMe": false, "verificationCode": "123456"} + responses: + "201": + application/json: {"adsConsent": null, "adsConsentReminderAt": 1556281940, "adsConsentSetAt": 1556281940, "anonymous": false, "authToken": "CxoUzBTSV5hsxjTpFKaf", "backupCodesCreated": false, "confirmed": false, "country": "US", "email": "username@email.com", "emailOnlyAuth": false, "experimentalFeatures": false, "friendlyName": "friendlyUsername", "entitlements": ["[]"], "guest": false, "hasPassword": true, "home": false, "homeAdmin": false, "homeSize": 1, "id": 13692262, "joinedAt": 1556281940, "locale": "ru", "mailingListActive": false, "mailingListStatus": "active", "maxHomeSize": 15, "profile": {"autoSelectAudio": true, "defaultAudioLanguage": "ja", "defaultSubtitleLanguage": "en", "autoSelectSubtitle": 1, "defaultSubtitleAccessibility": 1, "defaultSubtitleForced": 1, "watchedIndicator": 1, "mediaReviewsVisibility": 1}, "protected": false, "rememberExpiresAt": 1556281940, "restricted": false, "scrobbleTypes": "", "services": [], "subscription": {"active": true, "subscribedAt": "2021-04-12T18:21:12Z", "status": "Inactive"}, "subscriptionDescription": "", "subscriptions": [{"active": true, "subscribedAt": "2021-04-12T18:21:12Z", "status": "Inactive"}], "thumb": "https://plex.tv/users/a4f43c1ebfde43a5/avatar?c=8372075101", "title": "UsernameTitle", "twoFactorEnabled": false, "username": "Username", "uuid": "dae343c1f45beb4f", "attributionPartner": null, "pastSubscriptions": [], "trials": []} + "400": + application/json: {"errors": [{"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}]} getStatistics: "": parameters: @@ -2127,6 +2272,17 @@ 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}]} + speakeasy-default-get-statistics: + parameters: + query: + timespan: 4 + responses: + "200": + application/json: {"MediaContainer": {"size": 5497, "Device": [{"id": 208, "name": "Roku Express", "platform": "Roku", "clientIdentifier": "793095d235660625108ef785cc7646e9", "createdAt": 1706470556}], "Account": [{"id": 238960586, "key": "/accounts/238960586", "name": "Diane", "defaultAudioLanguage": "en", "autoSelectAudio": true, "defaultSubtitleLanguage": "en", "subtitleMode": 1, "thumb": "https://plex.tv/users/50d83634246da1de/avatar?c=1707110967"}], "StatisticsMedia": [{"accountID": 1, "deviceID": 13, "timespan": 4, "at": 1707141600, "metadataType": 4, "count": 1, "duration": 1555}]}} + "400": + application/json: {"errors": [{"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}]} getResourcesStatistics: "": parameters: @@ -2139,6 +2295,17 @@ examples: application/json: {"errors": [{"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}]} + speakeasy-default-get-resources-statistics: + parameters: + query: + timespan: 4 + responses: + "200": + application/json: {"MediaContainer": {"size": 5497, "StatisticsResources": [{"timespan": 6, "at": 1718384427, "hostCpuUtilization": 1.276, "processCpuUtilization": 0.025, "hostMemoryUtilization": 17.026, "processMemoryUtilization": 0.493}]}} + "400": + application/json: {"errors": [{"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}]} getBandwidthStatistics: "": parameters: @@ -2151,6 +2318,17 @@ examples: application/json: {"errors": [{"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}]} + speakeasy-default-get-bandwidth-statistics: + parameters: + query: + timespan: 4 + responses: + "200": + application/json: {"MediaContainer": {"size": 5497, "Device": [{"id": 208, "name": "Roku Express", "platform": "Roku", "clientIdentifier": "793095d235660625108ef785cc7646e9", "createdAt": 1706470556}], "Account": [{"id": 238960586, "key": "/accounts/238960586", "name": "Diane", "defaultAudioLanguage": "en", "autoSelectAudio": true, "defaultSubtitleLanguage": "en", "subtitleMode": 1, "thumb": "https://plex.tv/users/50d83634246da1de/avatar?c=1707110967"}], "StatisticsBandwidth": [{"accountID": 238960586, "deviceID": 208, "timespan": 6, "at": 1718387650, "lan": true, "bytes": 22}]}} + "400": + application/json: {"errors": [{"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}]} getSessions: speakeasy-default-get-sessions: responses: @@ -2243,6 +2421,19 @@ examples: application/json: {"errors": [{"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}]} + speakeasy-default-get-session-history: + parameters: + query: + accountId: 1 + filter: {} + librarySectionID: 12 + responses: + "200": + application/json: {"MediaContainer": {"size": 10855, "Metadata": [{"historyKey": "/status/sessions/history/1", "key": "/library/metadata/32171", "ratingKey": "32171", "librarySectionID": "2", "parentKey": "/library/metadata/32170", "grandparentKey": "/library/metadata/32132", "title": "The Noise That Blue Makes", "grandparentTitle": "Taskmaster", "type": "episode", "thumb": "/library/metadata/32171/thumb/-1", "parentThumb": "/library/metadata/32170/thumb/1654134301", "grandparentThumb": "/library/metadata/32132/thumb/1703933346", "grandparentArt": "/library/metadata/32132/art/1703933346", "index": 1, "parentIndex": 13, "originallyAvailableAt": "2022-04-14T00:00:00Z", "viewedAt": 1654139223, "accountID": 1, "deviceID": 5}, {"historyKey": "/status/sessions/history/1", "key": "/library/metadata/32171", "ratingKey": "32171", "librarySectionID": "2", "parentKey": "/library/metadata/32170", "grandparentKey": "/library/metadata/32132", "title": "The Noise That Blue Makes", "grandparentTitle": "Taskmaster", "type": "episode", "thumb": "/library/metadata/32171/thumb/-1", "parentThumb": "/library/metadata/32170/thumb/1654134301", "grandparentThumb": "/library/metadata/32132/thumb/1703933346", "grandparentArt": "/library/metadata/32132/art/1703933346", "index": 1, "parentIndex": 13, "originallyAvailableAt": "2022-04-14T00:00:00Z", "viewedAt": 1654139223, "accountID": 1, "deviceID": 5}, {"historyKey": "/status/sessions/history/1", "key": "/library/metadata/32171", "ratingKey": "32171", "librarySectionID": "2", "parentKey": "/library/metadata/32170", "grandparentKey": "/library/metadata/32132", "title": "The Noise That Blue Makes", "grandparentTitle": "Taskmaster", "type": "episode", "thumb": "/library/metadata/32171/thumb/-1", "parentThumb": "/library/metadata/32170/thumb/1654134301", "grandparentThumb": "/library/metadata/32132/thumb/1703933346", "grandparentArt": "/library/metadata/32132/art/1703933346", "index": 1, "parentIndex": 13, "originallyAvailableAt": "2022-04-14T00:00:00Z", "viewedAt": 1654139223, "accountID": 1, "deviceID": 5}]}} + "400": + application/json: {"errors": [{"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}]} getTranscodeSessions: speakeasy-default-get-transcode-sessions: responses: @@ -2281,6 +2472,15 @@ 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}]} + speakeasy-default-check-for-updates: + parameters: + query: + download: 1 + responses: + "400": + application/json: {"errors": [{"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}]} applyUpdates: "": parameters: @@ -2292,6 +2492,16 @@ 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}]} + speakeasy-default-apply-updates: + parameters: + query: + tonight: 1 + skip: 1 + responses: + "400": + application/json: {"errors": [{"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}]} get-users: "": parameters: @@ -2316,6 +2526,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}]} + speakeasy-default-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: "0xfD5052DbD1" + "400": + application/json: {"errors": [{"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}]} get-library-sections-all: speakeasy-default-get-library-sections-all: parameters: diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index b55e7ef..600360a 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -16,8 +16,12 @@ generation: auth: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: false + tests: + generateTests: true + generateNewTests: false + skipResponseBodyAssertions: false python: - version: 0.28.2 + version: 0.29.0 additionalDependencies: dev: {} main: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 59d681e..5e24eb6 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,4 +1,4 @@ -speakeasyVersion: 1.558.1 +speakeasyVersion: 1.598.0 sources: my-source: sourceNamespace: my-source @@ -8,19 +8,19 @@ sources: - latest plexapi: sourceNamespace: plexapi - sourceRevisionDigest: sha256:dafcc1192236829b85bc924e0462432c0eb7318a17c542f46e3dd05a9a6265df - sourceBlobDigest: sha256:bc072115d585e1695cb8393db901a3d36be1dcd57a69bad2b91a1ba7ac3c9c4b + sourceRevisionDigest: sha256:b4fa89a3571fbdcb4228800772a5fe1c292170babcd3e055161ae54402f89577 + sourceBlobDigest: sha256:f84dd2bfdaea4074454cea3c7fbc6c9e05515c5e9e961abb4923b77f8faf48f1 tags: - latest - - speakeasy-sdk-regen-1749513686 + - speakeasy-sdk-regen-1754438487 targets: plexpy: source: plexapi sourceNamespace: plexapi - sourceRevisionDigest: sha256:dafcc1192236829b85bc924e0462432c0eb7318a17c542f46e3dd05a9a6265df - sourceBlobDigest: sha256:bc072115d585e1695cb8393db901a3d36be1dcd57a69bad2b91a1ba7ac3c9c4b + sourceRevisionDigest: sha256:b4fa89a3571fbdcb4228800772a5fe1c292170babcd3e055161ae54402f89577 + sourceBlobDigest: sha256:f84dd2bfdaea4074454cea3c7fbc6c9e05515c5e9e961abb4923b77f8faf48f1 codeSamplesNamespace: code-samples-python-plexpy - codeSamplesRevisionDigest: sha256:80b0bb2691ad853eb319483f842ded70eed016c74ac990ae8314ff6bf1a7e116 + codeSamplesRevisionDigest: sha256:7188a481e55bb01d0e3d949172712786cf2d0e51a86f37e97f0fc7d77b88f872 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 46d9f50..c06d241 100644 --- a/README.md +++ b/README.md @@ -400,27 +400,18 @@ with PlexAPI( ## Error Handling -Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception. +[`PlexAPIError`](./src/plex_api_client/models/errors/plexapierror.py) is the base class for all HTTP error responses. It has the following properties: -By default, an API error will raise a errors.SDKError exception, which has the following properties: - -| Property | Type | Description | -|-----------------|------------------|-----------------------| -| `.status_code` | *int* | The HTTP status code | -| `.message` | *str* | The error message | -| `.raw_response` | *httpx.Response* | The raw HTTP response | -| `.body` | *str* | The response content | - -When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `get_server_capabilities_async` method may raise the following exceptions: - -| Error Type | Status Code | Content Type | -| ---------------------------------------- | ----------- | ---------------- | -| errors.GetServerCapabilitiesBadRequest | 400 | application/json | -| errors.GetServerCapabilitiesUnauthorized | 401 | application/json | -| errors.SDKError | 4XX, 5XX | \*/\* | +| Property | Type | Description | +| ------------------ | ---------------- | --------------------------------------------------------------------------------------- | +| `err.message` | `str` | Error message | +| `err.status_code` | `int` | HTTP response status code eg `404` | +| `err.headers` | `httpx.Headers` | HTTP response headers | +| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. | +| `err.raw_response` | `httpx.Response` | Raw HTTP response | +| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). | ### Example - ```python from plex_api_client import PlexAPI from plex_api_client.models import errors @@ -439,16 +430,197 @@ with PlexAPI( # Handle response print(res.object) - except errors.GetServerCapabilitiesBadRequest as e: - # handle e.data: errors.GetServerCapabilitiesBadRequestData - raise(e) - except errors.GetServerCapabilitiesUnauthorized as e: - # handle e.data: errors.GetServerCapabilitiesUnauthorizedData - raise(e) - except errors.SDKError as e: - # handle exception - raise(e) + + except errors.PlexAPIError as e: + # The base class for HTTP error responses + print(e.message) + print(e.status_code) + print(e.body) + print(e.headers) + print(e.raw_response) + + # Depending on the method different errors may be thrown + if isinstance(e, errors.GetServerCapabilitiesBadRequest): + print(e.data.errors) # Optional[List[errors.Errors]] + print(e.data.raw_response) # Optional[httpx.Response] ``` + +### Error Classes +**Primary error:** +* [`PlexAPIError`](./src/plex_api_client/models/errors/plexapierror.py): The base class for HTTP error responses. + +
Less common errors (161) + +
+ +**Network errors:** +* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors. + * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server. + * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out. + + +**Inherit from [`PlexAPIError`](./src/plex_api_client/models/errors/plexapierror.py)**: +* [`GetServerCapabilitiesBadRequest`](./src/plex_api_client/models/errors/getservercapabilitiesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetServerPreferencesBadRequest`](./src/plex_api_client/models/errors/getserverpreferencesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetAvailableClientsBadRequest`](./src/plex_api_client/models/errors/getavailableclientsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetDevicesBadRequest`](./src/plex_api_client/models/errors/getdevicesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetMyPlexAccountBadRequest`](./src/plex_api_client/models/errors/getmyplexaccountbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetResizedPhotoBadRequest`](./src/plex_api_client/models/errors/getresizedphotobadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetMediaProvidersBadRequest`](./src/plex_api_client/models/errors/getmediaprovidersbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetServerListBadRequest`](./src/plex_api_client/models/errors/getserverlistbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`MarkPlayedBadRequest`](./src/plex_api_client/models/errors/markplayedbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`MarkUnplayedBadRequest`](./src/plex_api_client/models/errors/markunplayedbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`UpdatePlayProgressBadRequest`](./src/plex_api_client/models/errors/updateplayprogressbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetBannerImageBadRequest`](./src/plex_api_client/models/errors/getbannerimagebadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetThumbImageBadRequest`](./src/plex_api_client/models/errors/getthumbimagebadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetTimelineBadRequest`](./src/plex_api_client/models/errors/gettimelinebadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`StartUniversalTranscodeBadRequest`](./src/plex_api_client/models/errors/startuniversaltranscodebadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetServerActivitiesBadRequest`](./src/plex_api_client/models/errors/getserveractivitiesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`CancelServerActivitiesBadRequest`](./src/plex_api_client/models/errors/cancelserveractivitiesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetButlerTasksBadRequest`](./src/plex_api_client/models/errors/getbutlertasksbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`StartAllTasksBadRequest`](./src/plex_api_client/models/errors/startalltasksbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`StopAllTasksBadRequest`](./src/plex_api_client/models/errors/stopalltasksbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`StartTaskBadRequest`](./src/plex_api_client/models/errors/starttaskbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`StopTaskBadRequest`](./src/plex_api_client/models/errors/stoptaskbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetCompanionsDataBadRequest`](./src/plex_api_client/models/errors/getcompanionsdatabadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetUserFriendsBadRequest`](./src/plex_api_client/models/errors/getuserfriendsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetGeoDataBadRequest`](./src/plex_api_client/models/errors/getgeodatabadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetHomeDataBadRequest`](./src/plex_api_client/models/errors/gethomedatabadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetServerResourcesBadRequest`](./src/plex_api_client/models/errors/getserverresourcesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetPinBadRequest`](./src/plex_api_client/models/errors/getpinbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetTokenByPinIDBadRequest`](./src/plex_api_client/models/errors/gettokenbypinidbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetGlobalHubsBadRequest`](./src/plex_api_client/models/errors/getglobalhubsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetLibraryHubsBadRequest`](./src/plex_api_client/models/errors/getlibraryhubsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`PerformSearchBadRequest`](./src/plex_api_client/models/errors/performsearchbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`PerformVoiceSearchBadRequest`](./src/plex_api_client/models/errors/performvoicesearchbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetSearchResultsBadRequest`](./src/plex_api_client/models/errors/getsearchresultsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetFileHashBadRequest`](./src/plex_api_client/models/errors/getfilehashbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetRecentlyAddedLibraryBadRequest`](./src/plex_api_client/models/errors/getrecentlyaddedlibrarybadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetAllLibrariesBadRequest`](./src/plex_api_client/models/errors/getalllibrariesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetLibraryDetailsBadRequest`](./src/plex_api_client/models/errors/getlibrarydetailsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`DeleteLibraryBadRequest`](./src/plex_api_client/models/errors/deletelibrarybadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetLibraryItemsBadRequest`](./src/plex_api_client/models/errors/getlibraryitemsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetLibrarySectionsAllBadRequest`](./src/plex_api_client/models/errors/getlibrarysectionsallbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetRefreshLibraryMetadataBadRequest`](./src/plex_api_client/models/errors/getrefreshlibrarymetadatabadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetSearchLibraryBadRequest`](./src/plex_api_client/models/errors/getsearchlibrarybadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetGenresLibraryBadRequest`](./src/plex_api_client/models/errors/getgenreslibrarybadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetCountriesLibraryBadRequest`](./src/plex_api_client/models/errors/getcountrieslibrarybadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetActorsLibraryBadRequest`](./src/plex_api_client/models/errors/getactorslibrarybadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetSearchAllLibrariesBadRequest`](./src/plex_api_client/models/errors/getsearchalllibrariesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetMediaMetaDataBadRequest`](./src/plex_api_client/models/errors/getmediametadatabadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetMetadataChildrenBadRequest`](./src/plex_api_client/models/errors/getmetadatachildrenbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetTopWatchedContentBadRequest`](./src/plex_api_client/models/errors/gettopwatchedcontentbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetWatchListBadRequest`](./src/plex_api_client/models/errors/getwatchlistbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`LogLineBadRequest`](./src/plex_api_client/models/errors/loglinebadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`LogMultiLineBadRequest`](./src/plex_api_client/models/errors/logmultilinebadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`EnablePaperTrailBadRequest`](./src/plex_api_client/models/errors/enablepapertrailbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`CreatePlaylistBadRequest`](./src/plex_api_client/models/errors/createplaylistbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetPlaylistsBadRequest`](./src/plex_api_client/models/errors/getplaylistsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetPlaylistBadRequest`](./src/plex_api_client/models/errors/getplaylistbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`DeletePlaylistBadRequest`](./src/plex_api_client/models/errors/deleteplaylistbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`UpdatePlaylistBadRequest`](./src/plex_api_client/models/errors/updateplaylistbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetPlaylistContentsBadRequest`](./src/plex_api_client/models/errors/getplaylistcontentsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`ClearPlaylistContentsBadRequest`](./src/plex_api_client/models/errors/clearplaylistcontentsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`AddPlaylistContentsBadRequest`](./src/plex_api_client/models/errors/addplaylistcontentsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`UploadPlaylistBadRequest`](./src/plex_api_client/models/errors/uploadplaylistbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetTransientTokenBadRequest`](./src/plex_api_client/models/errors/gettransienttokenbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetSourceConnectionInformationBadRequest`](./src/plex_api_client/models/errors/getsourceconnectioninformationbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetTokenDetailsBadRequest`](./src/plex_api_client/models/errors/gettokendetailsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`PostUsersSignInDataBadRequest`](./src/plex_api_client/models/errors/postuserssignindatabadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetStatisticsBadRequest`](./src/plex_api_client/models/errors/getstatisticsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetResourcesStatisticsBadRequest`](./src/plex_api_client/models/errors/getresourcesstatisticsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetBandwidthStatisticsBadRequest`](./src/plex_api_client/models/errors/getbandwidthstatisticsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetSessionsBadRequest`](./src/plex_api_client/models/errors/getsessionsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetSessionHistoryBadRequest`](./src/plex_api_client/models/errors/getsessionhistorybadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetTranscodeSessionsBadRequest`](./src/plex_api_client/models/errors/gettranscodesessionsbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`StopTranscodeSessionBadRequest`](./src/plex_api_client/models/errors/stoptranscodesessionbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetUpdateStatusBadRequest`](./src/plex_api_client/models/errors/getupdatestatusbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`CheckForUpdatesBadRequest`](./src/plex_api_client/models/errors/checkforupdatesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`ApplyUpdatesBadRequest`](./src/plex_api_client/models/errors/applyupdatesbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetUsersBadRequest`](./src/plex_api_client/models/errors/getusersbadrequest.py): Bad Request - A parameter was not specified, or was specified incorrectly. Status code `400`. Applicable to 1 of 84 methods.* +* [`GetServerCapabilitiesUnauthorized`](./src/plex_api_client/models/errors/getservercapabilitiesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetServerPreferencesUnauthorized`](./src/plex_api_client/models/errors/getserverpreferencesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetAvailableClientsUnauthorized`](./src/plex_api_client/models/errors/getavailableclientsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetDevicesUnauthorized`](./src/plex_api_client/models/errors/getdevicesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetMyPlexAccountUnauthorized`](./src/plex_api_client/models/errors/getmyplexaccountunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetResizedPhotoUnauthorized`](./src/plex_api_client/models/errors/getresizedphotounauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetMediaProvidersUnauthorized`](./src/plex_api_client/models/errors/getmediaprovidersunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetServerListUnauthorized`](./src/plex_api_client/models/errors/getserverlistunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`MarkPlayedUnauthorized`](./src/plex_api_client/models/errors/markplayedunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`MarkUnplayedUnauthorized`](./src/plex_api_client/models/errors/markunplayedunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`UpdatePlayProgressUnauthorized`](./src/plex_api_client/models/errors/updateplayprogressunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetBannerImageUnauthorized`](./src/plex_api_client/models/errors/getbannerimageunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetThumbImageUnauthorized`](./src/plex_api_client/models/errors/getthumbimageunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetTimelineUnauthorized`](./src/plex_api_client/models/errors/gettimelineunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`StartUniversalTranscodeUnauthorized`](./src/plex_api_client/models/errors/startuniversaltranscodeunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetServerActivitiesUnauthorized`](./src/plex_api_client/models/errors/getserveractivitiesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`CancelServerActivitiesUnauthorized`](./src/plex_api_client/models/errors/cancelserveractivitiesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetButlerTasksUnauthorized`](./src/plex_api_client/models/errors/getbutlertasksunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`StartAllTasksUnauthorized`](./src/plex_api_client/models/errors/startalltasksunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`StopAllTasksUnauthorized`](./src/plex_api_client/models/errors/stopalltasksunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`StartTaskUnauthorized`](./src/plex_api_client/models/errors/starttaskunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`StopTaskUnauthorized`](./src/plex_api_client/models/errors/stoptaskunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetCompanionsDataUnauthorized`](./src/plex_api_client/models/errors/getcompanionsdataunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetUserFriendsUnauthorized`](./src/plex_api_client/models/errors/getuserfriendsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetGeoDataUnauthorized`](./src/plex_api_client/models/errors/getgeodataunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetHomeDataUnauthorized`](./src/plex_api_client/models/errors/gethomedataunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetServerResourcesUnauthorized`](./src/plex_api_client/models/errors/getserverresourcesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetGlobalHubsUnauthorized`](./src/plex_api_client/models/errors/getglobalhubsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetLibraryHubsUnauthorized`](./src/plex_api_client/models/errors/getlibraryhubsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`PerformSearchUnauthorized`](./src/plex_api_client/models/errors/performsearchunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`PerformVoiceSearchUnauthorized`](./src/plex_api_client/models/errors/performvoicesearchunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetSearchResultsUnauthorized`](./src/plex_api_client/models/errors/getsearchresultsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetFileHashUnauthorized`](./src/plex_api_client/models/errors/getfilehashunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetRecentlyAddedLibraryUnauthorized`](./src/plex_api_client/models/errors/getrecentlyaddedlibraryunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetAllLibrariesUnauthorized`](./src/plex_api_client/models/errors/getalllibrariesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetLibraryDetailsUnauthorized`](./src/plex_api_client/models/errors/getlibrarydetailsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`DeleteLibraryUnauthorized`](./src/plex_api_client/models/errors/deletelibraryunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetLibraryItemsUnauthorized`](./src/plex_api_client/models/errors/getlibraryitemsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetLibrarySectionsAllUnauthorized`](./src/plex_api_client/models/errors/getlibrarysectionsallunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetRefreshLibraryMetadataUnauthorized`](./src/plex_api_client/models/errors/getrefreshlibrarymetadataunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetSearchLibraryUnauthorized`](./src/plex_api_client/models/errors/getsearchlibraryunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetGenresLibraryUnauthorized`](./src/plex_api_client/models/errors/getgenreslibraryunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetCountriesLibraryUnauthorized`](./src/plex_api_client/models/errors/getcountrieslibraryunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetActorsLibraryUnauthorized`](./src/plex_api_client/models/errors/getactorslibraryunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetSearchAllLibrariesUnauthorized`](./src/plex_api_client/models/errors/getsearchalllibrariesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetMediaMetaDataUnauthorized`](./src/plex_api_client/models/errors/getmediametadataunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetMetadataChildrenUnauthorized`](./src/plex_api_client/models/errors/getmetadatachildrenunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetTopWatchedContentUnauthorized`](./src/plex_api_client/models/errors/gettopwatchedcontentunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetWatchListUnauthorized`](./src/plex_api_client/models/errors/getwatchlistunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`LogLineUnauthorized`](./src/plex_api_client/models/errors/loglineunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`LogMultiLineUnauthorized`](./src/plex_api_client/models/errors/logmultilineunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`EnablePaperTrailUnauthorized`](./src/plex_api_client/models/errors/enablepapertrailunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`CreatePlaylistUnauthorized`](./src/plex_api_client/models/errors/createplaylistunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetPlaylistsUnauthorized`](./src/plex_api_client/models/errors/getplaylistsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetPlaylistUnauthorized`](./src/plex_api_client/models/errors/getplaylistunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`DeletePlaylistUnauthorized`](./src/plex_api_client/models/errors/deleteplaylistunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`UpdatePlaylistUnauthorized`](./src/plex_api_client/models/errors/updateplaylistunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetPlaylistContentsUnauthorized`](./src/plex_api_client/models/errors/getplaylistcontentsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`ClearPlaylistContentsUnauthorized`](./src/plex_api_client/models/errors/clearplaylistcontentsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`AddPlaylistContentsUnauthorized`](./src/plex_api_client/models/errors/addplaylistcontentsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`UploadPlaylistUnauthorized`](./src/plex_api_client/models/errors/uploadplaylistunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetTransientTokenUnauthorized`](./src/plex_api_client/models/errors/gettransienttokenunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetSourceConnectionInformationUnauthorized`](./src/plex_api_client/models/errors/getsourceconnectioninformationunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetTokenDetailsUnauthorized`](./src/plex_api_client/models/errors/gettokendetailsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`PostUsersSignInDataUnauthorized`](./src/plex_api_client/models/errors/postuserssignindataunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetStatisticsUnauthorized`](./src/plex_api_client/models/errors/getstatisticsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetResourcesStatisticsUnauthorized`](./src/plex_api_client/models/errors/getresourcesstatisticsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetBandwidthStatisticsUnauthorized`](./src/plex_api_client/models/errors/getbandwidthstatisticsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetSessionsUnauthorized`](./src/plex_api_client/models/errors/getsessionsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetSessionHistoryUnauthorized`](./src/plex_api_client/models/errors/getsessionhistoryunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetTranscodeSessionsUnauthorized`](./src/plex_api_client/models/errors/gettranscodesessionsunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`StopTranscodeSessionUnauthorized`](./src/plex_api_client/models/errors/stoptranscodesessionunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetUpdateStatusUnauthorized`](./src/plex_api_client/models/errors/getupdatestatusunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`CheckForUpdatesUnauthorized`](./src/plex_api_client/models/errors/checkforupdatesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`ApplyUpdatesUnauthorized`](./src/plex_api_client/models/errors/applyupdatesunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetUsersUnauthorized`](./src/plex_api_client/models/errors/getusersunauthorized.py): Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code `401`. Applicable to 1 of 84 methods.* +* [`GetTokenByPinIDResponseBody`](./src/plex_api_client/models/errors/gettokenbypinidresponsebody.py): Not Found or Expired. Status code `404`. Applicable to 1 of 84 methods.* +* [`GetServerIdentityRequestTimeout`](./src/plex_api_client/models/errors/getserveridentityrequesttimeout.py): Request Timeout. Status code `408`. Applicable to 1 of 84 methods.* +* [`ResponseValidationError`](./src/plex_api_client/models/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute. + +
+ +\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable. diff --git a/RELEASES.md b/RELEASES.md index 08ff91e..6b6f6e5 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1068,4 +1068,14 @@ Based on: ### Generated - [python v0.28.2] . ### Releases -- [PyPI v0.28.2] https://pypi.org/project/plex-api-client/0.28.2 - . \ No newline at end of file +- [PyPI v0.28.2] https://pypi.org/project/plex-api-client/0.28.2 - . + +## 2025-08-06 00:01:11 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.598.0 (2.674.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.29.0] . +### Releases +- [PyPI v0.29.0] https://pypi.org/project/plex-api-client/0.29.0 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index e17daad..aa69c33 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -527,7 +527,7 @@ actions: access_token="", ) as plex_api: - res = plex_api.library.get_file_hash(url="file://C:\Image.png&type=13") + res = plex_api.library.get_file_hash(url="file://C:\\Image.png&type=13") assert res is not None diff --git a/docs/sdks/activities/README.md b/docs/sdks/activities/README.md index 0f2c3ef..fe9b512 100644 --- a/docs/sdks/activities/README.md +++ b/docs/sdks/activities/README.md @@ -23,6 +23,7 @@ Get Server Activities ### Example Usage + ```python from plex_api_client import PlexAPI @@ -64,6 +65,7 @@ Cancel Server Activities ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/authentication/README.md b/docs/sdks/authentication/README.md index d02652d..6d1317e 100644 --- a/docs/sdks/authentication/README.md +++ b/docs/sdks/authentication/README.md @@ -20,6 +20,7 @@ This endpoint provides the caller with a temporary token with the same access le ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -66,6 +67,7 @@ Note: requires Plex Media Server >= 1.15.4. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -108,6 +110,7 @@ Get the User data from the provided X-Plex-Token ### Example Usage + ```python from plex_api_client import PlexAPI @@ -150,6 +153,7 @@ Sign in user with username and password and return user data with Plex authentic ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/butler/README.md b/docs/sdks/butler/README.md index e68666f..8711bce 100644 --- a/docs/sdks/butler/README.md +++ b/docs/sdks/butler/README.md @@ -20,6 +20,7 @@ Returns a list of butler tasks ### Example Usage + ```python from plex_api_client import PlexAPI @@ -66,6 +67,7 @@ This endpoint will attempt to start all Butler tasks that are enabled in the set ### Example Usage + ```python from plex_api_client import PlexAPI @@ -108,6 +110,7 @@ This endpoint will stop all currently running tasks and remove any scheduled tas ### Example Usage + ```python from plex_api_client import PlexAPI @@ -154,6 +157,7 @@ This endpoint will attempt to start a single Butler task that is enabled in the ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -198,6 +202,7 @@ This endpoint will stop a currently running task by name, or remove it from the ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations diff --git a/docs/sdks/hubs/README.md b/docs/sdks/hubs/README.md index cf9586d..32ab977 100644 --- a/docs/sdks/hubs/README.md +++ b/docs/sdks/hubs/README.md @@ -18,6 +18,7 @@ Get Global Hubs filtered by the parameters provided. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -62,6 +63,7 @@ This endpoint will return the recently added content. ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -109,6 +111,7 @@ This endpoint will return a list of library specific hubs ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/library/README.md b/docs/sdks/library/README.md index b415668..6133166 100644 --- a/docs/sdks/library/README.md +++ b/docs/sdks/library/README.md @@ -35,6 +35,7 @@ This resource returns hash values for local files ### Example Usage + ```python from plex_api_client import PlexAPI @@ -43,7 +44,7 @@ with PlexAPI( access_token="", ) as plex_api: - res = plex_api.library.get_file_hash(url="file://C:\Image.png&type=13") + res = plex_api.library.get_file_hash(url="file://C:\\Image.png&type=13") assert res is not None @@ -79,6 +80,7 @@ This endpoint will return the recently added content. ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -147,6 +149,7 @@ This allows a client to provide a rich interface around the media (e.g. allow so ### Example Usage + ```python from plex_api_client import PlexAPI @@ -227,6 +230,7 @@ Each type in the library comes with a set of filters and sorts, aiding in buildi ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -271,6 +275,7 @@ Delete a library using a specific section id ### Example Usage + ```python from plex_api_client import PlexAPI @@ -334,6 +339,7 @@ Fetches details from a specific section of the library identified by a section k ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -384,6 +390,7 @@ Retrieves a list of all general media data for this library. ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -436,6 +443,7 @@ This endpoint Refreshes all the Metadata of the library. ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -498,6 +506,7 @@ Each type in the library comes with a set of filters and sorts, aiding in buildi ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -543,6 +552,7 @@ Retrieves a list of all the genres that are found for the media in this library. ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -588,6 +598,7 @@ Retrieves a list of all the countries that are found for the media in this libra ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -633,6 +644,7 @@ Retrieves a list of all the actors that are found for the media in this library. ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -678,6 +690,7 @@ Search the provided query across all library sections, or a single section, and ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -731,6 +744,7 @@ Multiple rating keys can be provided as a comma-separated list (e.g., "21119,216 ### Example Usage + ```python from plex_api_client import PlexAPI @@ -788,6 +802,7 @@ Returns the background artwork for a library item. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -828,6 +843,7 @@ Uploads an image to use as the background artwork for a library item, either fro ### Example Usage + ```python from plex_api_client import PlexAPI @@ -870,6 +886,7 @@ Returns the available posters for a library item. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -910,6 +927,7 @@ Uploads a poster to a library item, either from a local file or a remote URL ### Example Usage + ```python from plex_api_client import PlexAPI @@ -953,6 +971,7 @@ This endpoint will return the children of of a library item specified with the r ### Example Usage + ```python from plex_api_client import PlexAPI @@ -997,6 +1016,7 @@ This endpoint will return the top watched content from libraries of a certain ty ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations diff --git a/docs/sdks/log/README.md b/docs/sdks/log/README.md index 48aad24..0a66b5c 100644 --- a/docs/sdks/log/README.md +++ b/docs/sdks/log/README.md @@ -19,6 +19,7 @@ This endpoint will write a single-line log message, including a level and source ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -85,6 +86,7 @@ Ensure each parameter is properly URL-encoded to avoid interpretation issues. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -130,6 +132,7 @@ This endpoint will enable all Plex Media Serverlogs to be sent to the Papertrail ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/media/README.md b/docs/sdks/media/README.md index 58a0759..787e28c 100644 --- a/docs/sdks/media/README.md +++ b/docs/sdks/media/README.md @@ -20,6 +20,7 @@ This will mark the provided media key as Played. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -62,6 +63,7 @@ This will mark the provided media key as Unplayed. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -105,6 +107,7 @@ This API command can be used to update the play progress of a media item. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -149,6 +152,7 @@ Gets the banner image of the media item ### Example Usage + ```python from plex_api_client import PlexAPI @@ -198,6 +202,7 @@ Gets the thumbnail image of the media item ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/playlists/README.md b/docs/sdks/playlists/README.md index f830cb8..4e1a94e 100644 --- a/docs/sdks/playlists/README.md +++ b/docs/sdks/playlists/README.md @@ -30,6 +30,7 @@ Create a new playlist. By default the playlist is blank. To create a playlist al ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -78,6 +79,7 @@ Get All Playlists given the specified filters. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -123,6 +125,7 @@ Smart playlist details contain the `content` attribute. This is the content URI ### Example Usage + ```python from plex_api_client import PlexAPI @@ -166,6 +169,7 @@ This endpoint will delete a playlist ### Example Usage + ```python from plex_api_client import PlexAPI @@ -209,6 +213,7 @@ From PMS version 1.9.1 clients can also edit playlist metadata using this endpoi ### Example Usage + ```python from plex_api_client import PlexAPI @@ -257,6 +262,7 @@ Note that for dumb playlists, items have a `playlistItemID` attribute which is u ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -302,6 +308,7 @@ Clears a playlist, only works with dumb playlists. Returns the playlist. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -346,6 +353,7 @@ With a smart playlist, passing a new `uri` parameter replaces the rules for the ### Example Usage + ```python from plex_api_client import PlexAPI @@ -391,6 +399,7 @@ Imports m3u playlists by passing a path on the server to scan for m3u-formatted ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations diff --git a/docs/sdks/plex/README.md b/docs/sdks/plex/README.md index 825dce7..6ddf77f 100644 --- a/docs/sdks/plex/README.md +++ b/docs/sdks/plex/README.md @@ -22,6 +22,7 @@ Get Companions Data ### Example Usage + ```python from plex_api_client import PlexAPI @@ -64,6 +65,7 @@ Get friends of provided auth token. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -106,6 +108,7 @@ Returns the geolocation and locale data of the caller ### Example Usage + ```python from plex_api_client import PlexAPI @@ -146,6 +149,7 @@ Retrieves the home data for the authenticated user, including details like home ### Example Usage + ```python from plex_api_client import PlexAPI @@ -187,6 +191,7 @@ Get Plex server access tokens and server connections ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -234,6 +239,7 @@ Retrieve a Pin ID from Plex.tv to use for authentication flows ### Example Usage + ```python from plex_api_client import PlexAPI @@ -280,6 +286,7 @@ Retrieve an Access Token from Plex.tv after the Pin has been authenticated ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/search/README.md b/docs/sdks/search/README.md index 9ecbfbe..76bf6bd 100644 --- a/docs/sdks/search/README.md +++ b/docs/sdks/search/README.md @@ -30,6 +30,7 @@ This request is intended to be very fast, and called as the user types. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -78,6 +79,7 @@ Results, as well as their containing per-type hubs, contain a `distance` attribu ### Example Usage + ```python from plex_api_client import PlexAPI @@ -122,6 +124,7 @@ This will search the database for the string provided. ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/server/README.md b/docs/sdks/server/README.md index 9c4d2dc..c03351d 100644 --- a/docs/sdks/server/README.md +++ b/docs/sdks/server/README.md @@ -24,6 +24,7 @@ Get Server Capabilities ### Example Usage + ```python from plex_api_client import PlexAPI @@ -65,6 +66,7 @@ Get Server Preferences ### Example Usage + ```python from plex_api_client import PlexAPI @@ -106,6 +108,7 @@ Get Available Clients ### Example Usage + ```python from plex_api_client import PlexAPI @@ -147,6 +150,7 @@ Get Devices ### Example Usage + ```python from plex_api_client import PlexAPI @@ -188,6 +192,7 @@ This request is useful to determine if the server is online or offline ### Example Usage + ```python from plex_api_client import PlexAPI @@ -226,6 +231,7 @@ Returns MyPlex Account Information ### Example Usage + ```python from plex_api_client import PlexAPI @@ -268,6 +274,7 @@ Plex's Photo transcoder is used throughout the service to serve images at specif ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -318,6 +325,7 @@ Retrieves media providers and their features from the Plex server. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -360,6 +368,7 @@ Get Server List ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/sessions/README.md b/docs/sdks/sessions/README.md index 71a14c0..8d43f8e 100644 --- a/docs/sdks/sessions/README.md +++ b/docs/sdks/sessions/README.md @@ -19,6 +19,7 @@ This will retrieve the "Now Playing" Information of the PMS. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -60,6 +61,7 @@ This will Retrieve a listing of all history views. ### Example Usage + ```python from plex_api_client import PlexAPI @@ -105,6 +107,7 @@ Get Transcode Sessions ### Example Usage + ```python from plex_api_client import PlexAPI @@ -146,6 +149,7 @@ Stop a Transcode Session ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/statistics/README.md b/docs/sdks/statistics/README.md index 28ee275..ae21e5c 100644 --- a/docs/sdks/statistics/README.md +++ b/docs/sdks/statistics/README.md @@ -18,6 +18,7 @@ This will return the media statistics for the server ### Example Usage + ```python from plex_api_client import PlexAPI @@ -60,6 +61,7 @@ This will return the resources for the server ### Example Usage + ```python from plex_api_client import PlexAPI @@ -102,6 +104,7 @@ This will return the bandwidth statistics for the server ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/updater/README.md b/docs/sdks/updater/README.md index 47dfcf2..21f4b06 100644 --- a/docs/sdks/updater/README.md +++ b/docs/sdks/updater/README.md @@ -19,6 +19,7 @@ Querying status of updates ### Example Usage + ```python from plex_api_client import PlexAPI @@ -60,6 +61,7 @@ Checking for updates ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -104,6 +106,7 @@ Note that these two parameters are effectively mutually exclusive. The `tonight` ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations diff --git a/docs/sdks/users/README.md b/docs/sdks/users/README.md index f12445a..2ad84bf 100644 --- a/docs/sdks/users/README.md +++ b/docs/sdks/users/README.md @@ -13,6 +13,7 @@ Get list of all users that are friends and have library access with the provided ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/video/README.md b/docs/sdks/video/README.md index 82eb72e..cd17013 100644 --- a/docs/sdks/video/README.md +++ b/docs/sdks/video/README.md @@ -17,6 +17,7 @@ Get the timeline for a media item ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations @@ -71,6 +72,7 @@ Begin a Universal Transcode Session ### Example Usage + ```python from plex_api_client import PlexAPI diff --git a/docs/sdks/watchlist/README.md b/docs/sdks/watchlist/README.md index 3b477e8..c13363a 100644 --- a/docs/sdks/watchlist/README.md +++ b/docs/sdks/watchlist/README.md @@ -16,6 +16,7 @@ Get User Watchlist ### Example Usage + ```python from plex_api_client import PlexAPI from plex_api_client.models import operations diff --git a/pyproject.toml b/pyproject.toml index 7786b7b..50e703a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "plex-api-client" -version = "0.28.2" +version = "0.29.0" description = "Python Client SDK Generated by Speakeasy" authors = [{ name = "Speakeasy" },] readme = "README-PYPI.md" @@ -38,6 +38,8 @@ pythonpath = ["src"] [tool.mypy] disable_error_code = "misc" +explicit_package_bases = true +mypy_path = "src" [[tool.mypy.overrides]] module = "typing_inspect" diff --git a/src/plex_api_client/_version.py b/src/plex_api_client/_version.py index ba725a3..e20b24f 100644 --- a/src/plex_api_client/_version.py +++ b/src/plex_api_client/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "plex-api-client" -__version__: str = "0.28.2" +__version__: str = "0.29.0" __openapi_doc_version__: str = "0.0.3" -__gen_version__: str = "2.623.4" -__user_agent__: str = "speakeasy-sdk/python 0.28.2 2.623.4 0.0.3 plex-api-client" +__gen_version__: str = "2.674.1" +__user_agent__: str = "speakeasy-sdk/python 0.29.0 2.674.1 0.0.3 plex-api-client" try: if __package__ is not None: diff --git a/src/plex_api_client/activities.py b/src/plex_api_client/activities.py index a0a0251..bc043ff 100644 --- a/src/plex_api_client/activities.py +++ b/src/plex_api_client/activities.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional @@ -85,44 +86,33 @@ class Activities(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerActivitiesResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetServerActivitiesResponseBody] + object=unmarshal_json_response( + Optional[operations.GetServerActivitiesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerActivitiesBadRequestData + response_data = unmarshal_json_response( + errors.GetServerActivitiesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerActivitiesBadRequest(data=response_data) + raise errors.GetServerActivitiesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerActivitiesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerActivitiesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerActivitiesUnauthorized(data=response_data) + raise errors.GetServerActivitiesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_server_activities_async( self, @@ -190,44 +180,33 @@ class Activities(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerActivitiesResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetServerActivitiesResponseBody] + object=unmarshal_json_response( + Optional[operations.GetServerActivitiesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerActivitiesBadRequestData + response_data = unmarshal_json_response( + errors.GetServerActivitiesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerActivitiesBadRequest(data=response_data) + raise errors.GetServerActivitiesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerActivitiesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerActivitiesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerActivitiesUnauthorized(data=response_data) + raise errors.GetServerActivitiesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def cancel_server_activities( self, @@ -307,36 +286,25 @@ class Activities(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CancelServerActivitiesBadRequestData + response_data = unmarshal_json_response( + errors.CancelServerActivitiesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.CancelServerActivitiesBadRequest(data=response_data) + raise errors.CancelServerActivitiesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CancelServerActivitiesUnauthorizedData + response_data = unmarshal_json_response( + errors.CancelServerActivitiesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.CancelServerActivitiesUnauthorized(data=response_data) + raise errors.CancelServerActivitiesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def cancel_server_activities_async( self, @@ -416,33 +384,22 @@ class Activities(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CancelServerActivitiesBadRequestData + response_data = unmarshal_json_response( + errors.CancelServerActivitiesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.CancelServerActivitiesBadRequest(data=response_data) + raise errors.CancelServerActivitiesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CancelServerActivitiesUnauthorizedData + response_data = unmarshal_json_response( + errors.CancelServerActivitiesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.CancelServerActivitiesUnauthorized(data=response_data) + raise errors.CancelServerActivitiesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/authentication.py b/src/plex_api_client/authentication.py index c2844c2..54f7a80 100644 --- a/src/plex_api_client/authentication.py +++ b/src/plex_api_client/authentication.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional, Union, cast @@ -93,36 +94,25 @@ class Authentication(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTransientTokenBadRequestData + response_data = unmarshal_json_response( + errors.GetTransientTokenBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTransientTokenBadRequest(data=response_data) + raise errors.GetTransientTokenBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTransientTokenUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTransientTokenUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTransientTokenUnauthorized(data=response_data) + raise errors.GetTransientTokenUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_transient_token_async( self, @@ -206,36 +196,25 @@ class Authentication(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTransientTokenBadRequestData + response_data = unmarshal_json_response( + errors.GetTransientTokenBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTransientTokenBadRequest(data=response_data) + raise errors.GetTransientTokenBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTransientTokenUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTransientTokenUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTransientTokenUnauthorized(data=response_data) + raise errors.GetTransientTokenUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_source_connection_information( self, @@ -317,36 +296,29 @@ class Authentication(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSourceConnectionInformationBadRequestData + response_data = unmarshal_json_response( + errors.GetSourceConnectionInformationBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSourceConnectionInformationBadRequest(data=response_data) + raise errors.GetSourceConnectionInformationBadRequest( + response_data, http_res + ) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSourceConnectionInformationUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSourceConnectionInformationUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSourceConnectionInformationUnauthorized(data=response_data) + raise errors.GetSourceConnectionInformationUnauthorized( + response_data, http_res + ) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_source_connection_information_async( self, @@ -428,36 +400,29 @@ class Authentication(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSourceConnectionInformationBadRequestData + response_data = unmarshal_json_response( + errors.GetSourceConnectionInformationBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSourceConnectionInformationBadRequest(data=response_data) + raise errors.GetSourceConnectionInformationBadRequest( + response_data, http_res + ) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSourceConnectionInformationUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSourceConnectionInformationUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSourceConnectionInformationUnauthorized(data=response_data) + raise errors.GetSourceConnectionInformationUnauthorized( + response_data, http_res + ) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_token_details( self, @@ -525,44 +490,33 @@ class Authentication(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetTokenDetailsResponse( - user_plex_account=utils.unmarshal_json( - http_res.text, Optional[operations.GetTokenDetailsUserPlexAccount] + user_plex_account=unmarshal_json_response( + Optional[operations.GetTokenDetailsUserPlexAccount], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTokenDetailsBadRequestData + response_data = unmarshal_json_response( + errors.GetTokenDetailsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTokenDetailsBadRequest(data=response_data) + raise errors.GetTokenDetailsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTokenDetailsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTokenDetailsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTokenDetailsUnauthorized(data=response_data) + raise errors.GetTokenDetailsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_token_details_async( self, @@ -630,44 +584,33 @@ class Authentication(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetTokenDetailsResponse( - user_plex_account=utils.unmarshal_json( - http_res.text, Optional[operations.GetTokenDetailsUserPlexAccount] + user_plex_account=unmarshal_json_response( + Optional[operations.GetTokenDetailsUserPlexAccount], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTokenDetailsBadRequestData + response_data = unmarshal_json_response( + errors.GetTokenDetailsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTokenDetailsBadRequest(data=response_data) + raise errors.GetTokenDetailsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTokenDetailsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTokenDetailsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTokenDetailsUnauthorized(data=response_data) + raise errors.GetTokenDetailsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def post_users_sign_in_data( self, @@ -751,45 +694,33 @@ class Authentication(BaseSDK): response_data: Any = None if utils.match_response(http_res, "201", "application/json"): return operations.PostUsersSignInDataResponse( - user_plex_account=utils.unmarshal_json( - http_res.text, - Optional[operations.PostUsersSignInDataUserPlexAccount], + user_plex_account=unmarshal_json_response( + Optional[operations.PostUsersSignInDataUserPlexAccount], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PostUsersSignInDataBadRequestData + response_data = unmarshal_json_response( + errors.PostUsersSignInDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.PostUsersSignInDataBadRequest(data=response_data) + raise errors.PostUsersSignInDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PostUsersSignInDataUnauthorizedData + response_data = unmarshal_json_response( + errors.PostUsersSignInDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.PostUsersSignInDataUnauthorized(data=response_data) + raise errors.PostUsersSignInDataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def post_users_sign_in_data_async( self, @@ -873,42 +804,30 @@ class Authentication(BaseSDK): response_data: Any = None if utils.match_response(http_res, "201", "application/json"): return operations.PostUsersSignInDataResponse( - user_plex_account=utils.unmarshal_json( - http_res.text, - Optional[operations.PostUsersSignInDataUserPlexAccount], + user_plex_account=unmarshal_json_response( + Optional[operations.PostUsersSignInDataUserPlexAccount], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PostUsersSignInDataBadRequestData + response_data = unmarshal_json_response( + errors.PostUsersSignInDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.PostUsersSignInDataBadRequest(data=response_data) + raise errors.PostUsersSignInDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PostUsersSignInDataUnauthorizedData + response_data = unmarshal_json_response( + errors.PostUsersSignInDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.PostUsersSignInDataUnauthorized(data=response_data) + raise errors.PostUsersSignInDataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/basesdk.py b/src/plex_api_client/basesdk.py index 8594a89..f6686d4 100644 --- a/src/plex_api_client/basesdk.py +++ b/src/plex_api_client/basesdk.py @@ -245,7 +245,7 @@ class BaseSDK: if http_res is None: logger.debug("Raising no response SDK error") - raise errors.SDKError("No response received") + raise errors.NoResponseError("No response received") logger.debug( "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s", @@ -266,7 +266,7 @@ class BaseSDK: http_res = result else: logger.debug("Raising unexpected SDK error") - raise errors.SDKError("Unexpected error occurred") + raise errors.SDKError("Unexpected error occurred", http_res) return http_res @@ -317,7 +317,7 @@ class BaseSDK: if http_res is None: logger.debug("Raising no response SDK error") - raise errors.SDKError("No response received") + raise errors.NoResponseError("No response received") logger.debug( "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s", @@ -338,7 +338,7 @@ class BaseSDK: http_res = result else: logger.debug("Raising unexpected SDK error") - raise errors.SDKError("Unexpected error occurred") + raise errors.SDKError("Unexpected error occurred", http_res) return http_res diff --git a/src/plex_api_client/butler.py b/src/plex_api_client/butler.py index 2949e3f..46bcfbc 100644 --- a/src/plex_api_client/butler.py +++ b/src/plex_api_client/butler.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional @@ -77,44 +78,33 @@ class Butler(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetButlerTasksResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetButlerTasksResponseBody] + object=unmarshal_json_response( + Optional[operations.GetButlerTasksResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetButlerTasksBadRequestData + response_data = unmarshal_json_response( + errors.GetButlerTasksBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetButlerTasksBadRequest(data=response_data) + raise errors.GetButlerTasksBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetButlerTasksUnauthorizedData + response_data = unmarshal_json_response( + errors.GetButlerTasksUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetButlerTasksUnauthorized(data=response_data) + raise errors.GetButlerTasksUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_butler_tasks_async( self, @@ -182,44 +172,33 @@ class Butler(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetButlerTasksResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetButlerTasksResponseBody] + object=unmarshal_json_response( + Optional[operations.GetButlerTasksResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetButlerTasksBadRequestData + response_data = unmarshal_json_response( + errors.GetButlerTasksBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetButlerTasksBadRequest(data=response_data) + raise errors.GetButlerTasksBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetButlerTasksUnauthorizedData + response_data = unmarshal_json_response( + errors.GetButlerTasksUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetButlerTasksUnauthorized(data=response_data) + raise errors.GetButlerTasksUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def start_all_tasks( self, @@ -297,36 +276,25 @@ class Butler(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartAllTasksBadRequestData + response_data = unmarshal_json_response( + errors.StartAllTasksBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StartAllTasksBadRequest(data=response_data) + raise errors.StartAllTasksBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartAllTasksUnauthorizedData + response_data = unmarshal_json_response( + errors.StartAllTasksUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StartAllTasksUnauthorized(data=response_data) + raise errors.StartAllTasksUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def start_all_tasks_async( self, @@ -404,36 +372,25 @@ class Butler(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartAllTasksBadRequestData + response_data = unmarshal_json_response( + errors.StartAllTasksBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StartAllTasksBadRequest(data=response_data) + raise errors.StartAllTasksBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartAllTasksUnauthorizedData + response_data = unmarshal_json_response( + errors.StartAllTasksUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StartAllTasksUnauthorized(data=response_data) + raise errors.StartAllTasksUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def stop_all_tasks( self, @@ -507,36 +464,25 @@ class Butler(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopAllTasksBadRequestData + response_data = unmarshal_json_response( + errors.StopAllTasksBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StopAllTasksBadRequest(data=response_data) + raise errors.StopAllTasksBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopAllTasksUnauthorizedData + response_data = unmarshal_json_response( + errors.StopAllTasksUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StopAllTasksUnauthorized(data=response_data) + raise errors.StopAllTasksUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def stop_all_tasks_async( self, @@ -610,36 +556,25 @@ class Butler(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopAllTasksBadRequestData + response_data = unmarshal_json_response( + errors.StopAllTasksBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StopAllTasksBadRequest(data=response_data) + raise errors.StopAllTasksBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopAllTasksUnauthorizedData + response_data = unmarshal_json_response( + errors.StopAllTasksUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StopAllTasksUnauthorized(data=response_data) + raise errors.StopAllTasksUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def start_task( self, @@ -724,36 +659,25 @@ class Butler(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartTaskBadRequestData + response_data = unmarshal_json_response( + errors.StartTaskBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StartTaskBadRequest(data=response_data) + raise errors.StartTaskBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartTaskUnauthorizedData + response_data = unmarshal_json_response( + errors.StartTaskUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StartTaskUnauthorized(data=response_data) + raise errors.StartTaskUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def start_task_async( self, @@ -838,36 +762,25 @@ class Butler(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartTaskBadRequestData + response_data = unmarshal_json_response( + errors.StartTaskBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StartTaskBadRequest(data=response_data) + raise errors.StartTaskBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartTaskUnauthorizedData + response_data = unmarshal_json_response( + errors.StartTaskUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StartTaskUnauthorized(data=response_data) + raise errors.StartTaskUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def stop_task( self, @@ -948,36 +861,25 @@ class Butler(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopTaskBadRequestData + response_data = unmarshal_json_response( + errors.StopTaskBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StopTaskBadRequest(data=response_data) + raise errors.StopTaskBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopTaskUnauthorizedData + response_data = unmarshal_json_response( + errors.StopTaskUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StopTaskUnauthorized(data=response_data) + raise errors.StopTaskUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def stop_task_async( self, @@ -1058,33 +960,22 @@ class Butler(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopTaskBadRequestData + response_data = unmarshal_json_response( + errors.StopTaskBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StopTaskBadRequest(data=response_data) + raise errors.StopTaskBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopTaskUnauthorizedData + response_data = unmarshal_json_response( + errors.StopTaskUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StopTaskUnauthorized(data=response_data) + raise errors.StopTaskUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/hubs.py b/src/plex_api_client/hubs.py index 4c0ea90..af7828a 100644 --- a/src/plex_api_client/hubs.py +++ b/src/plex_api_client/hubs.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional, Union, cast @@ -87,44 +88,33 @@ class Hubs(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetGlobalHubsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetGlobalHubsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetGlobalHubsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGlobalHubsBadRequestData + response_data = unmarshal_json_response( + errors.GetGlobalHubsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetGlobalHubsBadRequest(data=response_data) + raise errors.GetGlobalHubsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGlobalHubsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetGlobalHubsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetGlobalHubsUnauthorized(data=response_data) + raise errors.GetGlobalHubsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_global_hubs_async( self, @@ -202,44 +192,33 @@ class Hubs(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetGlobalHubsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetGlobalHubsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetGlobalHubsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGlobalHubsBadRequestData + response_data = unmarshal_json_response( + errors.GetGlobalHubsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetGlobalHubsBadRequest(data=response_data) + raise errors.GetGlobalHubsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGlobalHubsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetGlobalHubsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetGlobalHubsUnauthorized(data=response_data) + raise errors.GetGlobalHubsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_recently_added( self, @@ -317,8 +296,8 @@ class Hubs(BaseSDK): if utils.match_response(http_res, "200", "application/json"): return operations.GetRecentlyAddedResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetRecentlyAddedResponseBody] + object=unmarshal_json_response( + Optional[operations.GetRecentlyAddedResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", @@ -326,23 +305,12 @@ class Hubs(BaseSDK): ) if utils.match_response(http_res, ["400", "401", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_recently_added_async( self, @@ -420,8 +388,8 @@ class Hubs(BaseSDK): if utils.match_response(http_res, "200", "application/json"): return operations.GetRecentlyAddedResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetRecentlyAddedResponseBody] + object=unmarshal_json_response( + Optional[operations.GetRecentlyAddedResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", @@ -429,23 +397,12 @@ class Hubs(BaseSDK): ) if utils.match_response(http_res, ["400", "401", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_library_hubs( self, @@ -527,44 +484,33 @@ class Hubs(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetLibraryHubsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetLibraryHubsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetLibraryHubsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryHubsBadRequestData + response_data = unmarshal_json_response( + errors.GetLibraryHubsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryHubsBadRequest(data=response_data) + raise errors.GetLibraryHubsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryHubsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetLibraryHubsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryHubsUnauthorized(data=response_data) + raise errors.GetLibraryHubsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_library_hubs_async( self, @@ -646,41 +592,30 @@ class Hubs(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetLibraryHubsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetLibraryHubsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetLibraryHubsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryHubsBadRequestData + response_data = unmarshal_json_response( + errors.GetLibraryHubsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryHubsBadRequest(data=response_data) + raise errors.GetLibraryHubsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryHubsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetLibraryHubsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryHubsUnauthorized(data=response_data) + raise errors.GetLibraryHubsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/library.py b/src/plex_api_client/library.py index d9d8f1c..c567f76 100644 --- a/src/plex_api_client/library.py +++ b/src/plex_api_client/library.py @@ -6,6 +6,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, IO, Mapping, Optional, Union, cast @@ -93,36 +94,25 @@ class Library(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetFileHashBadRequestData + response_data = unmarshal_json_response( + errors.GetFileHashBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetFileHashBadRequest(data=response_data) + raise errors.GetFileHashBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetFileHashUnauthorizedData + response_data = unmarshal_json_response( + errors.GetFileHashUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetFileHashUnauthorized(data=response_data) + raise errors.GetFileHashUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_file_hash_async( self, @@ -205,36 +195,25 @@ class Library(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetFileHashBadRequestData + response_data = unmarshal_json_response( + errors.GetFileHashBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetFileHashBadRequest(data=response_data) + raise errors.GetFileHashBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetFileHashUnauthorizedData + response_data = unmarshal_json_response( + errors.GetFileHashUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetFileHashUnauthorized(data=response_data) + raise errors.GetFileHashUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_recently_added_library( self, @@ -315,45 +294,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetRecentlyAddedLibraryResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetRecentlyAddedLibraryResponseBody], + object=unmarshal_json_response( + Optional[operations.GetRecentlyAddedLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetRecentlyAddedLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetRecentlyAddedLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetRecentlyAddedLibraryBadRequest(data=response_data) + raise errors.GetRecentlyAddedLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetRecentlyAddedLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetRecentlyAddedLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetRecentlyAddedLibraryUnauthorized(data=response_data) + raise errors.GetRecentlyAddedLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_recently_added_library_async( self, @@ -434,45 +401,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetRecentlyAddedLibraryResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetRecentlyAddedLibraryResponseBody], + object=unmarshal_json_response( + Optional[operations.GetRecentlyAddedLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetRecentlyAddedLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetRecentlyAddedLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetRecentlyAddedLibraryBadRequest(data=response_data) + raise errors.GetRecentlyAddedLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetRecentlyAddedLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetRecentlyAddedLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetRecentlyAddedLibraryUnauthorized(data=response_data) + raise errors.GetRecentlyAddedLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_all_libraries( self, @@ -546,44 +501,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetAllLibrariesResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetAllLibrariesResponseBody] + object=unmarshal_json_response( + Optional[operations.GetAllLibrariesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetAllLibrariesBadRequestData + response_data = unmarshal_json_response( + errors.GetAllLibrariesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetAllLibrariesBadRequest(data=response_data) + raise errors.GetAllLibrariesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetAllLibrariesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetAllLibrariesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetAllLibrariesUnauthorized(data=response_data) + raise errors.GetAllLibrariesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_all_libraries_async( self, @@ -657,44 +601,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetAllLibrariesResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetAllLibrariesResponseBody] + object=unmarshal_json_response( + Optional[operations.GetAllLibrariesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetAllLibrariesBadRequestData + response_data = unmarshal_json_response( + errors.GetAllLibrariesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetAllLibrariesBadRequest(data=response_data) + raise errors.GetAllLibrariesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetAllLibrariesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetAllLibrariesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetAllLibrariesUnauthorized(data=response_data) + raise errors.GetAllLibrariesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_library_details( self, @@ -813,44 +746,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetLibraryDetailsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetLibraryDetailsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetLibraryDetailsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryDetailsBadRequestData + response_data = unmarshal_json_response( + errors.GetLibraryDetailsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryDetailsBadRequest(data=response_data) + raise errors.GetLibraryDetailsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryDetailsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetLibraryDetailsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryDetailsUnauthorized(data=response_data) + raise errors.GetLibraryDetailsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_library_details_async( self, @@ -969,44 +891,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetLibraryDetailsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetLibraryDetailsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetLibraryDetailsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryDetailsBadRequestData + response_data = unmarshal_json_response( + errors.GetLibraryDetailsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryDetailsBadRequest(data=response_data) + raise errors.GetLibraryDetailsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryDetailsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetLibraryDetailsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryDetailsUnauthorized(data=response_data) + raise errors.GetLibraryDetailsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def delete_library( self, @@ -1086,36 +997,25 @@ class Library(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.DeleteLibraryBadRequestData + response_data = unmarshal_json_response( + errors.DeleteLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.DeleteLibraryBadRequest(data=response_data) + raise errors.DeleteLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.DeleteLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.DeleteLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.DeleteLibraryUnauthorized(data=response_data) + raise errors.DeleteLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def delete_library_async( self, @@ -1195,36 +1095,25 @@ class Library(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.DeleteLibraryBadRequestData + response_data = unmarshal_json_response( + errors.DeleteLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.DeleteLibraryBadRequest(data=response_data) + raise errors.DeleteLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.DeleteLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.DeleteLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.DeleteLibraryUnauthorized(data=response_data) + raise errors.DeleteLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_library_items( self, @@ -1323,44 +1212,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetLibraryItemsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetLibraryItemsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetLibraryItemsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryItemsBadRequestData + response_data = unmarshal_json_response( + errors.GetLibraryItemsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryItemsBadRequest(data=response_data) + raise errors.GetLibraryItemsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryItemsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetLibraryItemsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryItemsUnauthorized(data=response_data) + raise errors.GetLibraryItemsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_library_items_async( self, @@ -1459,44 +1337,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetLibraryItemsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetLibraryItemsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetLibraryItemsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryItemsBadRequestData + response_data = unmarshal_json_response( + errors.GetLibraryItemsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryItemsBadRequest(data=response_data) + raise errors.GetLibraryItemsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibraryItemsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetLibraryItemsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetLibraryItemsUnauthorized(data=response_data) + raise errors.GetLibraryItemsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_library_sections_all( self, @@ -1575,45 +1442,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetLibrarySectionsAllResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetLibrarySectionsAllResponseBody], + object=unmarshal_json_response( + Optional[operations.GetLibrarySectionsAllResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibrarySectionsAllBadRequestData + response_data = unmarshal_json_response( + errors.GetLibrarySectionsAllBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetLibrarySectionsAllBadRequest(data=response_data) + raise errors.GetLibrarySectionsAllBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibrarySectionsAllUnauthorizedData + response_data = unmarshal_json_response( + errors.GetLibrarySectionsAllUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetLibrarySectionsAllUnauthorized(data=response_data) + raise errors.GetLibrarySectionsAllUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_library_sections_all_async( self, @@ -1692,45 +1547,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetLibrarySectionsAllResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetLibrarySectionsAllResponseBody], + object=unmarshal_json_response( + Optional[operations.GetLibrarySectionsAllResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibrarySectionsAllBadRequestData + response_data = unmarshal_json_response( + errors.GetLibrarySectionsAllBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetLibrarySectionsAllBadRequest(data=response_data) + raise errors.GetLibrarySectionsAllBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetLibrarySectionsAllUnauthorizedData + response_data = unmarshal_json_response( + errors.GetLibrarySectionsAllUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetLibrarySectionsAllUnauthorized(data=response_data) + raise errors.GetLibrarySectionsAllUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_refresh_library_metadata( self, @@ -1814,36 +1657,25 @@ class Library(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetRefreshLibraryMetadataBadRequestData + response_data = unmarshal_json_response( + errors.GetRefreshLibraryMetadataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetRefreshLibraryMetadataBadRequest(data=response_data) + raise errors.GetRefreshLibraryMetadataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetRefreshLibraryMetadataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetRefreshLibraryMetadataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetRefreshLibraryMetadataUnauthorized(data=response_data) + raise errors.GetRefreshLibraryMetadataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_refresh_library_metadata_async( self, @@ -1927,36 +1759,25 @@ class Library(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetRefreshLibraryMetadataBadRequestData + response_data = unmarshal_json_response( + errors.GetRefreshLibraryMetadataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetRefreshLibraryMetadataBadRequest(data=response_data) + raise errors.GetRefreshLibraryMetadataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetRefreshLibraryMetadataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetRefreshLibraryMetadataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetRefreshLibraryMetadataUnauthorized(data=response_data) + raise errors.GetRefreshLibraryMetadataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_search_library( self, @@ -2052,44 +1873,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSearchLibraryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetSearchLibraryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetSearchLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetSearchLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchLibraryBadRequest(data=response_data) + raise errors.GetSearchLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSearchLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchLibraryUnauthorized(data=response_data) + raise errors.GetSearchLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_search_library_async( self, @@ -2185,44 +1995,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSearchLibraryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetSearchLibraryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetSearchLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetSearchLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchLibraryBadRequest(data=response_data) + raise errors.GetSearchLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSearchLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchLibraryUnauthorized(data=response_data) + raise errors.GetSearchLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_genres_library( self, @@ -2301,44 +2100,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetGenresLibraryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetGenresLibraryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetGenresLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGenresLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetGenresLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetGenresLibraryBadRequest(data=response_data) + raise errors.GetGenresLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGenresLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetGenresLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetGenresLibraryUnauthorized(data=response_data) + raise errors.GetGenresLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_genres_library_async( self, @@ -2417,44 +2205,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetGenresLibraryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetGenresLibraryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetGenresLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGenresLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetGenresLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetGenresLibraryBadRequest(data=response_data) + raise errors.GetGenresLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGenresLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetGenresLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetGenresLibraryUnauthorized(data=response_data) + raise errors.GetGenresLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_countries_library( self, @@ -2533,44 +2310,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetCountriesLibraryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetCountriesLibraryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetCountriesLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetCountriesLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetCountriesLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetCountriesLibraryBadRequest(data=response_data) + raise errors.GetCountriesLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetCountriesLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetCountriesLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetCountriesLibraryUnauthorized(data=response_data) + raise errors.GetCountriesLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_countries_library_async( self, @@ -2649,44 +2415,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetCountriesLibraryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetCountriesLibraryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetCountriesLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetCountriesLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetCountriesLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetCountriesLibraryBadRequest(data=response_data) + raise errors.GetCountriesLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetCountriesLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetCountriesLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetCountriesLibraryUnauthorized(data=response_data) + raise errors.GetCountriesLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_actors_library( self, @@ -2765,44 +2520,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetActorsLibraryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetActorsLibraryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetActorsLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetActorsLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetActorsLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetActorsLibraryBadRequest(data=response_data) + raise errors.GetActorsLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetActorsLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetActorsLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetActorsLibraryUnauthorized(data=response_data) + raise errors.GetActorsLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_actors_library_async( self, @@ -2881,44 +2625,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetActorsLibraryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetActorsLibraryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetActorsLibraryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetActorsLibraryBadRequestData + response_data = unmarshal_json_response( + errors.GetActorsLibraryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetActorsLibraryBadRequest(data=response_data) + raise errors.GetActorsLibraryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetActorsLibraryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetActorsLibraryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetActorsLibraryUnauthorized(data=response_data) + raise errors.GetActorsLibraryUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_search_all_libraries( self, @@ -2997,45 +2730,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSearchAllLibrariesResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetSearchAllLibrariesResponseBody], + object=unmarshal_json_response( + Optional[operations.GetSearchAllLibrariesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchAllLibrariesBadRequestData + response_data = unmarshal_json_response( + errors.GetSearchAllLibrariesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchAllLibrariesBadRequest(data=response_data) + raise errors.GetSearchAllLibrariesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchAllLibrariesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSearchAllLibrariesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchAllLibrariesUnauthorized(data=response_data) + raise errors.GetSearchAllLibrariesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_search_all_libraries_async( self, @@ -3114,45 +2835,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSearchAllLibrariesResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetSearchAllLibrariesResponseBody], + object=unmarshal_json_response( + Optional[operations.GetSearchAllLibrariesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchAllLibrariesBadRequestData + response_data = unmarshal_json_response( + errors.GetSearchAllLibrariesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchAllLibrariesBadRequest(data=response_data) + raise errors.GetSearchAllLibrariesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchAllLibrariesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSearchAllLibrariesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchAllLibrariesUnauthorized(data=response_data) + raise errors.GetSearchAllLibrariesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_media_meta_data( self, @@ -3232,44 +2941,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetMediaMetaDataResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMediaMetaDataResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMediaMetaDataResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMediaMetaDataBadRequestData + response_data = unmarshal_json_response( + errors.GetMediaMetaDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetMediaMetaDataBadRequest(data=response_data) + raise errors.GetMediaMetaDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMediaMetaDataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetMediaMetaDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetMediaMetaDataUnauthorized(data=response_data) + raise errors.GetMediaMetaDataUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_media_meta_data_async( self, @@ -3349,44 +3047,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetMediaMetaDataResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMediaMetaDataResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMediaMetaDataResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMediaMetaDataBadRequestData + response_data = unmarshal_json_response( + errors.GetMediaMetaDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetMediaMetaDataBadRequest(data=response_data) + raise errors.GetMediaMetaDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMediaMetaDataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetMediaMetaDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetMediaMetaDataUnauthorized(data=response_data) + raise errors.GetMediaMetaDataUnauthorized(response_data, http_res) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_media_arts( self, @@ -3460,8 +3147,8 @@ class Library(BaseSDK): if utils.match_response(http_res, "200", "application/json"): return operations.GetMediaArtsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMediaArtsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMediaArtsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", @@ -3469,23 +3156,12 @@ class Library(BaseSDK): ) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_media_arts_async( self, @@ -3559,8 +3235,8 @@ class Library(BaseSDK): if utils.match_response(http_res, "200", "application/json"): return operations.GetMediaArtsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMediaArtsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMediaArtsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", @@ -3568,23 +3244,12 @@ class Library(BaseSDK): ) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def post_media_arts( self, @@ -3677,23 +3342,12 @@ class Library(BaseSDK): ) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def post_media_arts_async( self, @@ -3786,23 +3440,12 @@ class Library(BaseSDK): ) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_media_posters( self, @@ -3876,8 +3519,8 @@ class Library(BaseSDK): if utils.match_response(http_res, "200", "application/json"): return operations.GetMediaPostersResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMediaPostersResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMediaPostersResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", @@ -3885,23 +3528,12 @@ class Library(BaseSDK): ) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_media_posters_async( self, @@ -3975,8 +3607,8 @@ class Library(BaseSDK): if utils.match_response(http_res, "200", "application/json"): return operations.GetMediaPostersResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMediaPostersResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMediaPostersResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", @@ -3984,23 +3616,12 @@ class Library(BaseSDK): ) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def post_media_poster( self, @@ -4093,23 +3714,12 @@ class Library(BaseSDK): ) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def post_media_poster_async( self, @@ -4202,23 +3812,12 @@ class Library(BaseSDK): ) if utils.match_response(http_res, ["404", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_metadata_children( self, @@ -4297,44 +3896,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetMetadataChildrenResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMetadataChildrenResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMetadataChildrenResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMetadataChildrenBadRequestData + response_data = unmarshal_json_response( + errors.GetMetadataChildrenBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetMetadataChildrenBadRequest(data=response_data) + raise errors.GetMetadataChildrenBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMetadataChildrenUnauthorizedData + response_data = unmarshal_json_response( + errors.GetMetadataChildrenUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetMetadataChildrenUnauthorized(data=response_data) + raise errors.GetMetadataChildrenUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_metadata_children_async( self, @@ -4413,44 +4001,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetMetadataChildrenResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMetadataChildrenResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMetadataChildrenResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMetadataChildrenBadRequestData + response_data = unmarshal_json_response( + errors.GetMetadataChildrenBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetMetadataChildrenBadRequest(data=response_data) + raise errors.GetMetadataChildrenBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMetadataChildrenUnauthorizedData + response_data = unmarshal_json_response( + errors.GetMetadataChildrenUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetMetadataChildrenUnauthorized(data=response_data) + raise errors.GetMetadataChildrenUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_top_watched_content( self, @@ -4531,44 +4108,33 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetTopWatchedContentResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetTopWatchedContentResponseBody] + object=unmarshal_json_response( + Optional[operations.GetTopWatchedContentResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTopWatchedContentBadRequestData + response_data = unmarshal_json_response( + errors.GetTopWatchedContentBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTopWatchedContentBadRequest(data=response_data) + raise errors.GetTopWatchedContentBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTopWatchedContentUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTopWatchedContentUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTopWatchedContentUnauthorized(data=response_data) + raise errors.GetTopWatchedContentUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_top_watched_content_async( self, @@ -4649,41 +4215,30 @@ class Library(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetTopWatchedContentResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetTopWatchedContentResponseBody] + object=unmarshal_json_response( + Optional[operations.GetTopWatchedContentResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTopWatchedContentBadRequestData + response_data = unmarshal_json_response( + errors.GetTopWatchedContentBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTopWatchedContentBadRequest(data=response_data) + raise errors.GetTopWatchedContentBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTopWatchedContentUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTopWatchedContentUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTopWatchedContentUnauthorized(data=response_data) + raise errors.GetTopWatchedContentUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/log.py b/src/plex_api_client/log.py index f49aaee..b343664 100644 --- a/src/plex_api_client/log.py +++ b/src/plex_api_client/log.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional @@ -96,36 +97,25 @@ class Log(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.LogLineBadRequestData + response_data = unmarshal_json_response( + errors.LogLineBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.LogLineBadRequest(data=response_data) + raise errors.LogLineBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.LogLineUnauthorizedData + response_data = unmarshal_json_response( + errors.LogLineUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.LogLineUnauthorized(data=response_data) + raise errors.LogLineUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def log_line_async( self, @@ -212,36 +202,25 @@ class Log(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.LogLineBadRequestData + response_data = unmarshal_json_response( + errors.LogLineBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.LogLineBadRequest(data=response_data) + raise errors.LogLineBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.LogLineUnauthorizedData + response_data = unmarshal_json_response( + errors.LogLineUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.LogLineUnauthorized(data=response_data) + raise errors.LogLineUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def log_multi_line( self, @@ -341,36 +320,25 @@ class Log(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.LogMultiLineBadRequestData + response_data = unmarshal_json_response( + errors.LogMultiLineBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.LogMultiLineBadRequest(data=response_data) + raise errors.LogMultiLineBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.LogMultiLineUnauthorizedData + response_data = unmarshal_json_response( + errors.LogMultiLineUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.LogMultiLineUnauthorized(data=response_data) + raise errors.LogMultiLineUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def log_multi_line_async( self, @@ -470,36 +438,25 @@ class Log(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.LogMultiLineBadRequestData + response_data = unmarshal_json_response( + errors.LogMultiLineBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.LogMultiLineBadRequest(data=response_data) + raise errors.LogMultiLineBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.LogMultiLineUnauthorizedData + response_data = unmarshal_json_response( + errors.LogMultiLineUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.LogMultiLineUnauthorized(data=response_data) + raise errors.LogMultiLineUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def enable_paper_trail( self, @@ -573,36 +530,25 @@ class Log(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.EnablePaperTrailBadRequestData + response_data = unmarshal_json_response( + errors.EnablePaperTrailBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.EnablePaperTrailBadRequest(data=response_data) + raise errors.EnablePaperTrailBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.EnablePaperTrailUnauthorizedData + response_data = unmarshal_json_response( + errors.EnablePaperTrailUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.EnablePaperTrailUnauthorized(data=response_data) + raise errors.EnablePaperTrailUnauthorized(response_data, http_res) if utils.match_response(http_res, ["403", "4XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def enable_paper_trail_async( self, @@ -676,33 +622,22 @@ class Log(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.EnablePaperTrailBadRequestData + response_data = unmarshal_json_response( + errors.EnablePaperTrailBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.EnablePaperTrailBadRequest(data=response_data) + raise errors.EnablePaperTrailBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.EnablePaperTrailUnauthorizedData + response_data = unmarshal_json_response( + errors.EnablePaperTrailUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.EnablePaperTrailUnauthorized(data=response_data) + raise errors.EnablePaperTrailUnauthorized(response_data, http_res) if utils.match_response(http_res, ["403", "4XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/media.py b/src/plex_api_client/media.py index d2ae5df..9dabf0f 100644 --- a/src/plex_api_client/media.py +++ b/src/plex_api_client/media.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional, Union, cast @@ -89,36 +90,25 @@ class Media(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.MarkPlayedBadRequestData + response_data = unmarshal_json_response( + errors.MarkPlayedBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.MarkPlayedBadRequest(data=response_data) + raise errors.MarkPlayedBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.MarkPlayedUnauthorizedData + response_data = unmarshal_json_response( + errors.MarkPlayedUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.MarkPlayedUnauthorized(data=response_data) + raise errors.MarkPlayedUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def mark_played_async( self, @@ -198,36 +188,25 @@ class Media(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.MarkPlayedBadRequestData + response_data = unmarshal_json_response( + errors.MarkPlayedBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.MarkPlayedBadRequest(data=response_data) + raise errors.MarkPlayedBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.MarkPlayedUnauthorizedData + response_data = unmarshal_json_response( + errors.MarkPlayedUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.MarkPlayedUnauthorized(data=response_data) + raise errors.MarkPlayedUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def mark_unplayed( self, @@ -307,36 +286,25 @@ class Media(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.MarkUnplayedBadRequestData + response_data = unmarshal_json_response( + errors.MarkUnplayedBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.MarkUnplayedBadRequest(data=response_data) + raise errors.MarkUnplayedBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.MarkUnplayedUnauthorizedData + response_data = unmarshal_json_response( + errors.MarkUnplayedUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.MarkUnplayedUnauthorized(data=response_data) + raise errors.MarkUnplayedUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def mark_unplayed_async( self, @@ -416,36 +384,25 @@ class Media(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.MarkUnplayedBadRequestData + response_data = unmarshal_json_response( + errors.MarkUnplayedBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.MarkUnplayedBadRequest(data=response_data) + raise errors.MarkUnplayedBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.MarkUnplayedUnauthorizedData + response_data = unmarshal_json_response( + errors.MarkUnplayedUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.MarkUnplayedUnauthorized(data=response_data) + raise errors.MarkUnplayedUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def update_play_progress( self, @@ -532,36 +489,25 @@ class Media(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UpdatePlayProgressBadRequestData + response_data = unmarshal_json_response( + errors.UpdatePlayProgressBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.UpdatePlayProgressBadRequest(data=response_data) + raise errors.UpdatePlayProgressBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UpdatePlayProgressUnauthorizedData + response_data = unmarshal_json_response( + errors.UpdatePlayProgressUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.UpdatePlayProgressUnauthorized(data=response_data) + raise errors.UpdatePlayProgressUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def update_play_progress_async( self, @@ -648,36 +594,25 @@ class Media(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UpdatePlayProgressBadRequestData + response_data = unmarshal_json_response( + errors.UpdatePlayProgressBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.UpdatePlayProgressBadRequest(data=response_data) + raise errors.UpdatePlayProgressBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UpdatePlayProgressUnauthorizedData + response_data = unmarshal_json_response( + errors.UpdatePlayProgressUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.UpdatePlayProgressUnauthorized(data=response_data) + raise errors.UpdatePlayProgressUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_banner_image( self, @@ -763,37 +698,31 @@ class Media(BaseSDK): ) if utils.match_response(http_res, "400", "application/json"): http_res_text = utils.stream_to_text(http_res) - response_data = utils.unmarshal_json( - http_res_text, errors.GetBannerImageBadRequestData + response_data = unmarshal_json_response( + errors.GetBannerImageBadRequestData, http_res, http_res_text ) response_data.raw_response = http_res - raise errors.GetBannerImageBadRequest(data=response_data) + raise errors.GetBannerImageBadRequest( + response_data, http_res, http_res_text + ) if utils.match_response(http_res, "401", "application/json"): http_res_text = utils.stream_to_text(http_res) - response_data = utils.unmarshal_json( - http_res_text, errors.GetBannerImageUnauthorizedData + response_data = unmarshal_json_response( + errors.GetBannerImageUnauthorizedData, http_res, http_res_text ) response_data.raw_response = http_res - raise errors.GetBannerImageUnauthorized(data=response_data) + raise errors.GetBannerImageUnauthorized( + response_data, http_res, http_res_text + ) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res, http_res_text) async def get_banner_image_async( self, @@ -879,37 +808,31 @@ class Media(BaseSDK): ) if utils.match_response(http_res, "400", "application/json"): http_res_text = await utils.stream_to_text_async(http_res) - response_data = utils.unmarshal_json( - http_res_text, errors.GetBannerImageBadRequestData + response_data = unmarshal_json_response( + errors.GetBannerImageBadRequestData, http_res, http_res_text ) response_data.raw_response = http_res - raise errors.GetBannerImageBadRequest(data=response_data) + raise errors.GetBannerImageBadRequest( + response_data, http_res, http_res_text + ) if utils.match_response(http_res, "401", "application/json"): http_res_text = await utils.stream_to_text_async(http_res) - response_data = utils.unmarshal_json( - http_res_text, errors.GetBannerImageUnauthorizedData + response_data = unmarshal_json_response( + errors.GetBannerImageUnauthorizedData, http_res, http_res_text ) response_data.raw_response = http_res - raise errors.GetBannerImageUnauthorized(data=response_data) + raise errors.GetBannerImageUnauthorized( + response_data, http_res, http_res_text + ) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res, http_res_text) def get_thumb_image( self, @@ -995,37 +918,29 @@ class Media(BaseSDK): ) if utils.match_response(http_res, "400", "application/json"): http_res_text = utils.stream_to_text(http_res) - response_data = utils.unmarshal_json( - http_res_text, errors.GetThumbImageBadRequestData + response_data = unmarshal_json_response( + errors.GetThumbImageBadRequestData, http_res, http_res_text ) response_data.raw_response = http_res - raise errors.GetThumbImageBadRequest(data=response_data) + raise errors.GetThumbImageBadRequest(response_data, http_res, http_res_text) if utils.match_response(http_res, "401", "application/json"): http_res_text = utils.stream_to_text(http_res) - response_data = utils.unmarshal_json( - http_res_text, errors.GetThumbImageUnauthorizedData + response_data = unmarshal_json_response( + errors.GetThumbImageUnauthorizedData, http_res, http_res_text ) response_data.raw_response = http_res - raise errors.GetThumbImageUnauthorized(data=response_data) + raise errors.GetThumbImageUnauthorized( + response_data, http_res, http_res_text + ) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res, http_res_text) async def get_thumb_image_async( self, @@ -1111,34 +1026,26 @@ class Media(BaseSDK): ) if utils.match_response(http_res, "400", "application/json"): http_res_text = await utils.stream_to_text_async(http_res) - response_data = utils.unmarshal_json( - http_res_text, errors.GetThumbImageBadRequestData + response_data = unmarshal_json_response( + errors.GetThumbImageBadRequestData, http_res, http_res_text ) response_data.raw_response = http_res - raise errors.GetThumbImageBadRequest(data=response_data) + raise errors.GetThumbImageBadRequest(response_data, http_res, http_res_text) if utils.match_response(http_res, "401", "application/json"): http_res_text = await utils.stream_to_text_async(http_res) - response_data = utils.unmarshal_json( - http_res_text, errors.GetThumbImageUnauthorizedData + response_data = unmarshal_json_response( + errors.GetThumbImageUnauthorizedData, http_res, http_res_text ) response_data.raw_response = http_res - raise errors.GetThumbImageUnauthorized(data=response_data) + raise errors.GetThumbImageUnauthorized( + response_data, http_res, http_res_text + ) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res, http_res_text) diff --git a/src/plex_api_client/models/components/__init__.py b/src/plex_api_client/models/components/__init__.py index 0fca5ad..66c8506 100644 --- a/src/plex_api_client/models/components/__init__.py +++ b/src/plex_api_client/models/components/__init__.py @@ -2,6 +2,7 @@ from typing import TYPE_CHECKING from importlib import import_module +import builtins if TYPE_CHECKING: from .security import Security, SecurityTypedDict @@ -36,5 +37,5 @@ def __getattr__(attr_name: str) -> object: def __dir__(): - lazy_attrs = list(_dynamic_imports.keys()) - return sorted(lazy_attrs) + lazy_attrs = builtins.list(_dynamic_imports.keys()) + return builtins.sorted(lazy_attrs) diff --git a/src/plex_api_client/models/errors/__init__.py b/src/plex_api_client/models/errors/__init__.py index 483ed48..5e2d4ca 100644 --- a/src/plex_api_client/models/errors/__init__.py +++ b/src/plex_api_client/models/errors/__init__.py @@ -2,6 +2,7 @@ from typing import TYPE_CHECKING from importlib import import_module +import builtins if TYPE_CHECKING: from .addplaylistcontents import ( @@ -664,6 +665,7 @@ if TYPE_CHECKING: MarkUnplayedUnauthorized, MarkUnplayedUnauthorizedData, ) + from .no_response_error import NoResponseError from .performsearch import ( PerformSearchBadRequest, PerformSearchBadRequestData, @@ -684,6 +686,7 @@ if TYPE_CHECKING: PerformVoiceSearchUnauthorized, PerformVoiceSearchUnauthorizedData, ) + from .plexapierror import PlexAPIError from .post_users_sign_in_data import ( PostUsersSignInDataAuthenticationErrors, PostUsersSignInDataAuthenticationErrorsTypedDict, @@ -694,6 +697,7 @@ if TYPE_CHECKING: PostUsersSignInDataUnauthorized, PostUsersSignInDataUnauthorizedData, ) + from .responsevalidationerror import ResponseValidationError from .sdkerror import SDKError from .startalltasks import ( StartAllTasksBadRequest, @@ -1313,6 +1317,7 @@ __all__ = [ "MarkUnplayedMediaErrorsTypedDict", "MarkUnplayedUnauthorized", "MarkUnplayedUnauthorizedData", + "NoResponseError", "PerformSearchBadRequest", "PerformSearchBadRequestData", "PerformSearchErrors", @@ -1329,6 +1334,7 @@ __all__ = [ "PerformVoiceSearchSearchErrorsTypedDict", "PerformVoiceSearchUnauthorized", "PerformVoiceSearchUnauthorizedData", + "PlexAPIError", "PostUsersSignInDataAuthenticationErrors", "PostUsersSignInDataAuthenticationErrorsTypedDict", "PostUsersSignInDataBadRequest", @@ -1337,6 +1343,7 @@ __all__ = [ "PostUsersSignInDataErrorsTypedDict", "PostUsersSignInDataUnauthorized", "PostUsersSignInDataUnauthorizedData", + "ResponseValidationError", "SDKError", "StartAllTasksBadRequest", "StartAllTasksBadRequestData", @@ -1939,6 +1946,7 @@ _dynamic_imports: dict[str, str] = { "MarkUnplayedMediaErrorsTypedDict": ".markunplayed", "MarkUnplayedUnauthorized": ".markunplayed", "MarkUnplayedUnauthorizedData": ".markunplayed", + "NoResponseError": ".no_response_error", "PerformSearchBadRequest": ".performsearch", "PerformSearchBadRequestData": ".performsearch", "PerformSearchErrors": ".performsearch", @@ -1955,6 +1963,7 @@ _dynamic_imports: dict[str, str] = { "PerformVoiceSearchSearchErrorsTypedDict": ".performvoicesearch", "PerformVoiceSearchUnauthorized": ".performvoicesearch", "PerformVoiceSearchUnauthorizedData": ".performvoicesearch", + "PlexAPIError": ".plexapierror", "PostUsersSignInDataAuthenticationErrors": ".post_users_sign_in_data", "PostUsersSignInDataAuthenticationErrorsTypedDict": ".post_users_sign_in_data", "PostUsersSignInDataBadRequest": ".post_users_sign_in_data", @@ -1963,6 +1972,7 @@ _dynamic_imports: dict[str, str] = { "PostUsersSignInDataErrorsTypedDict": ".post_users_sign_in_data", "PostUsersSignInDataUnauthorized": ".post_users_sign_in_data", "PostUsersSignInDataUnauthorizedData": ".post_users_sign_in_data", + "ResponseValidationError": ".responsevalidationerror", "SDKError": ".sdkerror", "StartAllTasksBadRequest": ".startalltasks", "StartAllTasksBadRequestData": ".startalltasks", @@ -2061,5 +2071,5 @@ def __getattr__(attr_name: str) -> object: def __dir__(): - lazy_attrs = list(_dynamic_imports.keys()) - return sorted(lazy_attrs) + lazy_attrs = builtins.list(_dynamic_imports.keys()) + return builtins.sorted(lazy_attrs) diff --git a/src/plex_api_client/models/errors/addplaylistcontents.py b/src/plex_api_client/models/errors/addplaylistcontents.py index 80a4f4f..4aeb9be 100644 --- a/src/plex_api_client/models/errors/addplaylistcontents.py +++ b/src/plex_api_client/models/errors/addplaylistcontents.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class AddPlaylistContentsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class AddPlaylistContentsUnauthorized(Exception): +class AddPlaylistContentsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: AddPlaylistContentsUnauthorizedData - def __init__(self, data: AddPlaylistContentsUnauthorizedData): + def __init__( + self, + data: AddPlaylistContentsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, AddPlaylistContentsUnauthorizedData) - class AddPlaylistContentsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class AddPlaylistContentsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class AddPlaylistContentsBadRequest(Exception): +class AddPlaylistContentsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: AddPlaylistContentsBadRequestData - def __init__(self, data: AddPlaylistContentsBadRequestData): + def __init__( + self, + data: AddPlaylistContentsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, AddPlaylistContentsBadRequestData) diff --git a/src/plex_api_client/models/errors/applyupdates.py b/src/plex_api_client/models/errors/applyupdates.py index 055a5a2..434c5b0 100644 --- a/src/plex_api_client/models/errors/applyupdates.py +++ b/src/plex_api_client/models/errors/applyupdates.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class ApplyUpdatesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class ApplyUpdatesUnauthorized(Exception): +class ApplyUpdatesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: ApplyUpdatesUnauthorizedData - def __init__(self, data: ApplyUpdatesUnauthorizedData): + def __init__( + self, + data: ApplyUpdatesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, ApplyUpdatesUnauthorizedData) - class ApplyUpdatesErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class ApplyUpdatesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class ApplyUpdatesBadRequest(Exception): +class ApplyUpdatesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: ApplyUpdatesBadRequestData - def __init__(self, data: ApplyUpdatesBadRequestData): + def __init__( + self, + data: ApplyUpdatesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, ApplyUpdatesBadRequestData) diff --git a/src/plex_api_client/models/errors/cancelserveractivities.py b/src/plex_api_client/models/errors/cancelserveractivities.py index a6ba9b9..f16f85d 100644 --- a/src/plex_api_client/models/errors/cancelserveractivities.py +++ b/src/plex_api_client/models/errors/cancelserveractivities.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class CancelServerActivitiesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class CancelServerActivitiesUnauthorized(Exception): +class CancelServerActivitiesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: CancelServerActivitiesUnauthorizedData - def __init__(self, data: CancelServerActivitiesUnauthorizedData): + def __init__( + self, + data: CancelServerActivitiesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, CancelServerActivitiesUnauthorizedData) - class CancelServerActivitiesErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class CancelServerActivitiesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class CancelServerActivitiesBadRequest(Exception): +class CancelServerActivitiesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: CancelServerActivitiesBadRequestData - def __init__(self, data: CancelServerActivitiesBadRequestData): + def __init__( + self, + data: CancelServerActivitiesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, CancelServerActivitiesBadRequestData) diff --git a/src/plex_api_client/models/errors/checkforupdates.py b/src/plex_api_client/models/errors/checkforupdates.py index 3442ee8..db9c571 100644 --- a/src/plex_api_client/models/errors/checkforupdates.py +++ b/src/plex_api_client/models/errors/checkforupdates.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class CheckForUpdatesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class CheckForUpdatesUnauthorized(Exception): +class CheckForUpdatesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: CheckForUpdatesUnauthorizedData - def __init__(self, data: CheckForUpdatesUnauthorizedData): + def __init__( + self, + data: CheckForUpdatesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, CheckForUpdatesUnauthorizedData) - class CheckForUpdatesErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class CheckForUpdatesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class CheckForUpdatesBadRequest(Exception): +class CheckForUpdatesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: CheckForUpdatesBadRequestData - def __init__(self, data: CheckForUpdatesBadRequestData): + def __init__( + self, + data: CheckForUpdatesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, CheckForUpdatesBadRequestData) diff --git a/src/plex_api_client/models/errors/clearplaylistcontents.py b/src/plex_api_client/models/errors/clearplaylistcontents.py index ae801ca..ec7cbac 100644 --- a/src/plex_api_client/models/errors/clearplaylistcontents.py +++ b/src/plex_api_client/models/errors/clearplaylistcontents.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class ClearPlaylistContentsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class ClearPlaylistContentsUnauthorized(Exception): +class ClearPlaylistContentsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: ClearPlaylistContentsUnauthorizedData - def __init__(self, data: ClearPlaylistContentsUnauthorizedData): + def __init__( + self, + data: ClearPlaylistContentsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, ClearPlaylistContentsUnauthorizedData) - class ClearPlaylistContentsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class ClearPlaylistContentsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class ClearPlaylistContentsBadRequest(Exception): +class ClearPlaylistContentsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: ClearPlaylistContentsBadRequestData - def __init__(self, data: ClearPlaylistContentsBadRequestData): + def __init__( + self, + data: ClearPlaylistContentsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, ClearPlaylistContentsBadRequestData) diff --git a/src/plex_api_client/models/errors/createplaylist.py b/src/plex_api_client/models/errors/createplaylist.py index c7c248b..8dfbd9a 100644 --- a/src/plex_api_client/models/errors/createplaylist.py +++ b/src/plex_api_client/models/errors/createplaylist.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class CreatePlaylistUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class CreatePlaylistUnauthorized(Exception): +class CreatePlaylistUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: CreatePlaylistUnauthorizedData - def __init__(self, data: CreatePlaylistUnauthorizedData): + def __init__( + self, + data: CreatePlaylistUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, CreatePlaylistUnauthorizedData) - class CreatePlaylistErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class CreatePlaylistBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class CreatePlaylistBadRequest(Exception): +class CreatePlaylistBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: CreatePlaylistBadRequestData - def __init__(self, data: CreatePlaylistBadRequestData): + def __init__( + self, + data: CreatePlaylistBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, CreatePlaylistBadRequestData) diff --git a/src/plex_api_client/models/errors/deletelibrary.py b/src/plex_api_client/models/errors/deletelibrary.py index 517cdfc..14fc2bc 100644 --- a/src/plex_api_client/models/errors/deletelibrary.py +++ b/src/plex_api_client/models/errors/deletelibrary.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class DeleteLibraryUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class DeleteLibraryUnauthorized(Exception): +class DeleteLibraryUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: DeleteLibraryUnauthorizedData - def __init__(self, data: DeleteLibraryUnauthorizedData): + def __init__( + self, + data: DeleteLibraryUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, DeleteLibraryUnauthorizedData) - class DeleteLibraryErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class DeleteLibraryBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class DeleteLibraryBadRequest(Exception): +class DeleteLibraryBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: DeleteLibraryBadRequestData - def __init__(self, data: DeleteLibraryBadRequestData): + def __init__( + self, + data: DeleteLibraryBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, DeleteLibraryBadRequestData) diff --git a/src/plex_api_client/models/errors/deleteplaylist.py b/src/plex_api_client/models/errors/deleteplaylist.py index 3cdb437..8ad089c 100644 --- a/src/plex_api_client/models/errors/deleteplaylist.py +++ b/src/plex_api_client/models/errors/deleteplaylist.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class DeletePlaylistUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class DeletePlaylistUnauthorized(Exception): +class DeletePlaylistUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: DeletePlaylistUnauthorizedData - def __init__(self, data: DeletePlaylistUnauthorizedData): + def __init__( + self, + data: DeletePlaylistUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, DeletePlaylistUnauthorizedData) - class DeletePlaylistErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class DeletePlaylistBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class DeletePlaylistBadRequest(Exception): +class DeletePlaylistBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: DeletePlaylistBadRequestData - def __init__(self, data: DeletePlaylistBadRequestData): + def __init__( + self, + data: DeletePlaylistBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, DeletePlaylistBadRequestData) diff --git a/src/plex_api_client/models/errors/enablepapertrail.py b/src/plex_api_client/models/errors/enablepapertrail.py index 2f4ecb0..cc21ef0 100644 --- a/src/plex_api_client/models/errors/enablepapertrail.py +++ b/src/plex_api_client/models/errors/enablepapertrail.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class EnablePaperTrailUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class EnablePaperTrailUnauthorized(Exception): +class EnablePaperTrailUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: EnablePaperTrailUnauthorizedData - def __init__(self, data: EnablePaperTrailUnauthorizedData): + def __init__( + self, + data: EnablePaperTrailUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, EnablePaperTrailUnauthorizedData) - class EnablePaperTrailErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class EnablePaperTrailBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class EnablePaperTrailBadRequest(Exception): +class EnablePaperTrailBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: EnablePaperTrailBadRequestData - def __init__(self, data: EnablePaperTrailBadRequestData): + def __init__( + self, + data: EnablePaperTrailBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, EnablePaperTrailBadRequestData) diff --git a/src/plex_api_client/models/errors/get_actors_library.py b/src/plex_api_client/models/errors/get_actors_library.py index 708ce9c..48a5c5d 100644 --- a/src/plex_api_client/models/errors/get_actors_library.py +++ b/src/plex_api_client/models/errors/get_actors_library.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetActorsLibraryUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetActorsLibraryUnauthorized(Exception): +class GetActorsLibraryUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetActorsLibraryUnauthorizedData - def __init__(self, data: GetActorsLibraryUnauthorizedData): + def __init__( + self, + data: GetActorsLibraryUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetActorsLibraryUnauthorizedData) - class GetActorsLibraryErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetActorsLibraryBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetActorsLibraryBadRequest(Exception): +class GetActorsLibraryBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetActorsLibraryBadRequestData - def __init__(self, data: GetActorsLibraryBadRequestData): + def __init__( + self, + data: GetActorsLibraryBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetActorsLibraryBadRequestData) diff --git a/src/plex_api_client/models/errors/get_all_libraries.py b/src/plex_api_client/models/errors/get_all_libraries.py index 9839375..507f8bc 100644 --- a/src/plex_api_client/models/errors/get_all_libraries.py +++ b/src/plex_api_client/models/errors/get_all_libraries.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetAllLibrariesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetAllLibrariesUnauthorized(Exception): +class GetAllLibrariesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetAllLibrariesUnauthorizedData - def __init__(self, data: GetAllLibrariesUnauthorizedData): + def __init__( + self, + data: GetAllLibrariesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetAllLibrariesUnauthorizedData) - class GetAllLibrariesErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetAllLibrariesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetAllLibrariesBadRequest(Exception): +class GetAllLibrariesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetAllLibrariesBadRequestData - def __init__(self, data: GetAllLibrariesBadRequestData): + def __init__( + self, + data: GetAllLibrariesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetAllLibrariesBadRequestData) diff --git a/src/plex_api_client/models/errors/get_banner_image.py b/src/plex_api_client/models/errors/get_banner_image.py index 47739a9..31dfcc6 100644 --- a/src/plex_api_client/models/errors/get_banner_image.py +++ b/src/plex_api_client/models/errors/get_banner_image.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetBannerImageUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetBannerImageUnauthorized(Exception): +class GetBannerImageUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetBannerImageUnauthorizedData - def __init__(self, data: GetBannerImageUnauthorizedData): + def __init__( + self, + data: GetBannerImageUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetBannerImageUnauthorizedData) - class GetBannerImageErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetBannerImageBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetBannerImageBadRequest(Exception): +class GetBannerImageBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetBannerImageBadRequestData - def __init__(self, data: GetBannerImageBadRequestData): + def __init__( + self, + data: GetBannerImageBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetBannerImageBadRequestData) diff --git a/src/plex_api_client/models/errors/get_countries_library.py b/src/plex_api_client/models/errors/get_countries_library.py index 4d9b4f4..ea9a859 100644 --- a/src/plex_api_client/models/errors/get_countries_library.py +++ b/src/plex_api_client/models/errors/get_countries_library.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetCountriesLibraryUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetCountriesLibraryUnauthorized(Exception): +class GetCountriesLibraryUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetCountriesLibraryUnauthorizedData - def __init__(self, data: GetCountriesLibraryUnauthorizedData): + def __init__( + self, + data: GetCountriesLibraryUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetCountriesLibraryUnauthorizedData) - class GetCountriesLibraryErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetCountriesLibraryBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetCountriesLibraryBadRequest(Exception): +class GetCountriesLibraryBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetCountriesLibraryBadRequestData - def __init__(self, data: GetCountriesLibraryBadRequestData): + def __init__( + self, + data: GetCountriesLibraryBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetCountriesLibraryBadRequestData) diff --git a/src/plex_api_client/models/errors/get_genres_library.py b/src/plex_api_client/models/errors/get_genres_library.py index 628cb91..809b36f 100644 --- a/src/plex_api_client/models/errors/get_genres_library.py +++ b/src/plex_api_client/models/errors/get_genres_library.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetGenresLibraryUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetGenresLibraryUnauthorized(Exception): +class GetGenresLibraryUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetGenresLibraryUnauthorizedData - def __init__(self, data: GetGenresLibraryUnauthorizedData): + def __init__( + self, + data: GetGenresLibraryUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetGenresLibraryUnauthorizedData) - class GetGenresLibraryErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetGenresLibraryBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetGenresLibraryBadRequest(Exception): +class GetGenresLibraryBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetGenresLibraryBadRequestData - def __init__(self, data: GetGenresLibraryBadRequestData): + def __init__( + self, + data: GetGenresLibraryBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetGenresLibraryBadRequestData) diff --git a/src/plex_api_client/models/errors/get_library_details.py b/src/plex_api_client/models/errors/get_library_details.py index 1c15b2f..967fee0 100644 --- a/src/plex_api_client/models/errors/get_library_details.py +++ b/src/plex_api_client/models/errors/get_library_details.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetLibraryDetailsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetLibraryDetailsUnauthorized(Exception): +class GetLibraryDetailsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetLibraryDetailsUnauthorizedData - def __init__(self, data: GetLibraryDetailsUnauthorizedData): + def __init__( + self, + data: GetLibraryDetailsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetLibraryDetailsUnauthorizedData) - class GetLibraryDetailsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetLibraryDetailsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetLibraryDetailsBadRequest(Exception): +class GetLibraryDetailsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetLibraryDetailsBadRequestData - def __init__(self, data: GetLibraryDetailsBadRequestData): + def __init__( + self, + data: GetLibraryDetailsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetLibraryDetailsBadRequestData) diff --git a/src/plex_api_client/models/errors/get_library_items.py b/src/plex_api_client/models/errors/get_library_items.py index 6dee5c5..deab881 100644 --- a/src/plex_api_client/models/errors/get_library_items.py +++ b/src/plex_api_client/models/errors/get_library_items.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetLibraryItemsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetLibraryItemsUnauthorized(Exception): +class GetLibraryItemsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetLibraryItemsUnauthorizedData - def __init__(self, data: GetLibraryItemsUnauthorizedData): + def __init__( + self, + data: GetLibraryItemsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetLibraryItemsUnauthorizedData) - class GetLibraryItemsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetLibraryItemsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetLibraryItemsBadRequest(Exception): +class GetLibraryItemsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetLibraryItemsBadRequestData - def __init__(self, data: GetLibraryItemsBadRequestData): + def __init__( + self, + data: GetLibraryItemsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetLibraryItemsBadRequestData) diff --git a/src/plex_api_client/models/errors/get_library_sections_all.py b/src/plex_api_client/models/errors/get_library_sections_all.py index 6c8e4bf..0b65da9 100644 --- a/src/plex_api_client/models/errors/get_library_sections_all.py +++ b/src/plex_api_client/models/errors/get_library_sections_all.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetLibrarySectionsAllUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetLibrarySectionsAllUnauthorized(Exception): +class GetLibrarySectionsAllUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetLibrarySectionsAllUnauthorizedData - def __init__(self, data: GetLibrarySectionsAllUnauthorizedData): + def __init__( + self, + data: GetLibrarySectionsAllUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetLibrarySectionsAllUnauthorizedData) - class GetLibrarySectionsAllErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetLibrarySectionsAllBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetLibrarySectionsAllBadRequest(Exception): +class GetLibrarySectionsAllBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetLibrarySectionsAllBadRequestData - def __init__(self, data: GetLibrarySectionsAllBadRequestData): + def __init__( + self, + data: GetLibrarySectionsAllBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetLibrarySectionsAllBadRequestData) diff --git a/src/plex_api_client/models/errors/get_media_meta_data.py b/src/plex_api_client/models/errors/get_media_meta_data.py index 895afcd..0f04fa0 100644 --- a/src/plex_api_client/models/errors/get_media_meta_data.py +++ b/src/plex_api_client/models/errors/get_media_meta_data.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetMediaMetaDataUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetMediaMetaDataUnauthorized(Exception): +class GetMediaMetaDataUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetMediaMetaDataUnauthorizedData - def __init__(self, data: GetMediaMetaDataUnauthorizedData): + def __init__( + self, + data: GetMediaMetaDataUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetMediaMetaDataUnauthorizedData) - class GetMediaMetaDataErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetMediaMetaDataBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetMediaMetaDataBadRequest(Exception): +class GetMediaMetaDataBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetMediaMetaDataBadRequestData - def __init__(self, data: GetMediaMetaDataBadRequestData): + def __init__( + self, + data: GetMediaMetaDataBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetMediaMetaDataBadRequestData) diff --git a/src/plex_api_client/models/errors/get_media_providers.py b/src/plex_api_client/models/errors/get_media_providers.py index cde0182..8027d83 100644 --- a/src/plex_api_client/models/errors/get_media_providers.py +++ b/src/plex_api_client/models/errors/get_media_providers.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetMediaProvidersUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetMediaProvidersUnauthorized(Exception): +class GetMediaProvidersUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetMediaProvidersUnauthorizedData - def __init__(self, data: GetMediaProvidersUnauthorizedData): + def __init__( + self, + data: GetMediaProvidersUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetMediaProvidersUnauthorizedData) - class GetMediaProvidersErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetMediaProvidersBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetMediaProvidersBadRequest(Exception): +class GetMediaProvidersBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetMediaProvidersBadRequestData - def __init__(self, data: GetMediaProvidersBadRequestData): + def __init__( + self, + data: GetMediaProvidersBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetMediaProvidersBadRequestData) diff --git a/src/plex_api_client/models/errors/get_recently_added_library.py b/src/plex_api_client/models/errors/get_recently_added_library.py index bcbc5d2..743596a 100644 --- a/src/plex_api_client/models/errors/get_recently_added_library.py +++ b/src/plex_api_client/models/errors/get_recently_added_library.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetRecentlyAddedLibraryUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetRecentlyAddedLibraryUnauthorized(Exception): +class GetRecentlyAddedLibraryUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetRecentlyAddedLibraryUnauthorizedData - def __init__(self, data: GetRecentlyAddedLibraryUnauthorizedData): + def __init__( + self, + data: GetRecentlyAddedLibraryUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetRecentlyAddedLibraryUnauthorizedData) - class GetRecentlyAddedLibraryErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetRecentlyAddedLibraryBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetRecentlyAddedLibraryBadRequest(Exception): +class GetRecentlyAddedLibraryBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetRecentlyAddedLibraryBadRequestData - def __init__(self, data: GetRecentlyAddedLibraryBadRequestData): + def __init__( + self, + data: GetRecentlyAddedLibraryBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetRecentlyAddedLibraryBadRequestData) diff --git a/src/plex_api_client/models/errors/get_refresh_library_metadata.py b/src/plex_api_client/models/errors/get_refresh_library_metadata.py index 836e002..0037c5c 100644 --- a/src/plex_api_client/models/errors/get_refresh_library_metadata.py +++ b/src/plex_api_client/models/errors/get_refresh_library_metadata.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetRefreshLibraryMetadataUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetRefreshLibraryMetadataUnauthorized(Exception): +class GetRefreshLibraryMetadataUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetRefreshLibraryMetadataUnauthorizedData - def __init__(self, data: GetRefreshLibraryMetadataUnauthorizedData): + def __init__( + self, + data: GetRefreshLibraryMetadataUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetRefreshLibraryMetadataUnauthorizedData) - class GetRefreshLibraryMetadataErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetRefreshLibraryMetadataBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetRefreshLibraryMetadataBadRequest(Exception): +class GetRefreshLibraryMetadataBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetRefreshLibraryMetadataBadRequestData - def __init__(self, data: GetRefreshLibraryMetadataBadRequestData): + def __init__( + self, + data: GetRefreshLibraryMetadataBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetRefreshLibraryMetadataBadRequestData) diff --git a/src/plex_api_client/models/errors/get_search_all_libraries.py b/src/plex_api_client/models/errors/get_search_all_libraries.py index fea988b..186d7c7 100644 --- a/src/plex_api_client/models/errors/get_search_all_libraries.py +++ b/src/plex_api_client/models/errors/get_search_all_libraries.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetSearchAllLibrariesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSearchAllLibrariesUnauthorized(Exception): +class GetSearchAllLibrariesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetSearchAllLibrariesUnauthorizedData - def __init__(self, data: GetSearchAllLibrariesUnauthorizedData): + def __init__( + self, + data: GetSearchAllLibrariesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSearchAllLibrariesUnauthorizedData) - class GetSearchAllLibrariesErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetSearchAllLibrariesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSearchAllLibrariesBadRequest(Exception): +class GetSearchAllLibrariesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetSearchAllLibrariesBadRequestData - def __init__(self, data: GetSearchAllLibrariesBadRequestData): + def __init__( + self, + data: GetSearchAllLibrariesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSearchAllLibrariesBadRequestData) diff --git a/src/plex_api_client/models/errors/get_search_library.py b/src/plex_api_client/models/errors/get_search_library.py index c47288b..f6a2839 100644 --- a/src/plex_api_client/models/errors/get_search_library.py +++ b/src/plex_api_client/models/errors/get_search_library.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetSearchLibraryUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSearchLibraryUnauthorized(Exception): +class GetSearchLibraryUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetSearchLibraryUnauthorizedData - def __init__(self, data: GetSearchLibraryUnauthorizedData): + def __init__( + self, + data: GetSearchLibraryUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSearchLibraryUnauthorizedData) - class GetSearchLibraryErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetSearchLibraryBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSearchLibraryBadRequest(Exception): +class GetSearchLibraryBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetSearchLibraryBadRequestData - def __init__(self, data: GetSearchLibraryBadRequestData): + def __init__( + self, + data: GetSearchLibraryBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSearchLibraryBadRequestData) diff --git a/src/plex_api_client/models/errors/get_server_identity.py b/src/plex_api_client/models/errors/get_server_identity.py index 6097305..2592713 100644 --- a/src/plex_api_client/models/errors/get_server_identity.py +++ b/src/plex_api_client/models/errors/get_server_identity.py @@ -2,6 +2,7 @@ from __future__ import annotations import httpx +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import Optional @@ -19,13 +20,18 @@ class GetServerIdentityRequestTimeoutData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerIdentityRequestTimeout(Exception): +class GetServerIdentityRequestTimeout(PlexAPIError): r"""Request Timeout""" data: GetServerIdentityRequestTimeoutData - def __init__(self, data: GetServerIdentityRequestTimeoutData): + def __init__( + self, + data: GetServerIdentityRequestTimeoutData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.message) or fallback + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return self.data.message if self.data.message is not None else "unknown error" diff --git a/src/plex_api_client/models/errors/get_server_resources.py b/src/plex_api_client/models/errors/get_server_resources.py index f4df819..98beac5 100644 --- a/src/plex_api_client/models/errors/get_server_resources.py +++ b/src/plex_api_client/models/errors/get_server_resources.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetServerResourcesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerResourcesUnauthorized(Exception): +class GetServerResourcesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetServerResourcesUnauthorizedData - def __init__(self, data: GetServerResourcesUnauthorizedData): + def __init__( + self, + data: GetServerResourcesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerResourcesUnauthorizedData) - class GetServerResourcesErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetServerResourcesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerResourcesBadRequest(Exception): +class GetServerResourcesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetServerResourcesBadRequestData - def __init__(self, data: GetServerResourcesBadRequestData): + def __init__( + self, + data: GetServerResourcesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerResourcesBadRequestData) diff --git a/src/plex_api_client/models/errors/get_thumb_image.py b/src/plex_api_client/models/errors/get_thumb_image.py index 976a061..568e67f 100644 --- a/src/plex_api_client/models/errors/get_thumb_image.py +++ b/src/plex_api_client/models/errors/get_thumb_image.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetThumbImageUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetThumbImageUnauthorized(Exception): +class GetThumbImageUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetThumbImageUnauthorizedData - def __init__(self, data: GetThumbImageUnauthorizedData): + def __init__( + self, + data: GetThumbImageUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetThumbImageUnauthorizedData) - class GetThumbImageErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetThumbImageBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetThumbImageBadRequest(Exception): +class GetThumbImageBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetThumbImageBadRequestData - def __init__(self, data: GetThumbImageBadRequestData): + def __init__( + self, + data: GetThumbImageBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetThumbImageBadRequestData) diff --git a/src/plex_api_client/models/errors/get_users.py b/src/plex_api_client/models/errors/get_users.py index f964cdf..ce12235 100644 --- a/src/plex_api_client/models/errors/get_users.py +++ b/src/plex_api_client/models/errors/get_users.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetUsersUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetUsersUnauthorized(Exception): +class GetUsersUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetUsersUnauthorizedData - def __init__(self, data: GetUsersUnauthorizedData): + def __init__( + self, + data: GetUsersUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetUsersUnauthorizedData) - class GetUsersErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetUsersBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetUsersBadRequest(Exception): +class GetUsersBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetUsersBadRequestData - def __init__(self, data: GetUsersBadRequestData): + def __init__( + self, + data: GetUsersBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetUsersBadRequestData) diff --git a/src/plex_api_client/models/errors/get_watch_list.py b/src/plex_api_client/models/errors/get_watch_list.py index 58b4957..97c1640 100644 --- a/src/plex_api_client/models/errors/get_watch_list.py +++ b/src/plex_api_client/models/errors/get_watch_list.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetWatchListUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetWatchListUnauthorized(Exception): +class GetWatchListUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetWatchListUnauthorizedData - def __init__(self, data: GetWatchListUnauthorizedData): + def __init__( + self, + data: GetWatchListUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetWatchListUnauthorizedData) - class GetWatchListErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetWatchListBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetWatchListBadRequest(Exception): +class GetWatchListBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetWatchListBadRequestData - def __init__(self, data: GetWatchListBadRequestData): + def __init__( + self, + data: GetWatchListBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetWatchListBadRequestData) diff --git a/src/plex_api_client/models/errors/getavailableclients.py b/src/plex_api_client/models/errors/getavailableclients.py index 8652e70..226ec07 100644 --- a/src/plex_api_client/models/errors/getavailableclients.py +++ b/src/plex_api_client/models/errors/getavailableclients.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetAvailableClientsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetAvailableClientsUnauthorized(Exception): +class GetAvailableClientsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetAvailableClientsUnauthorizedData - def __init__(self, data: GetAvailableClientsUnauthorizedData): + def __init__( + self, + data: GetAvailableClientsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetAvailableClientsUnauthorizedData) - class GetAvailableClientsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetAvailableClientsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetAvailableClientsBadRequest(Exception): +class GetAvailableClientsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetAvailableClientsBadRequestData - def __init__(self, data: GetAvailableClientsBadRequestData): + def __init__( + self, + data: GetAvailableClientsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetAvailableClientsBadRequestData) diff --git a/src/plex_api_client/models/errors/getbandwidthstatistics.py b/src/plex_api_client/models/errors/getbandwidthstatistics.py index 9994b37..6ef0635 100644 --- a/src/plex_api_client/models/errors/getbandwidthstatistics.py +++ b/src/plex_api_client/models/errors/getbandwidthstatistics.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetBandwidthStatisticsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetBandwidthStatisticsUnauthorized(Exception): +class GetBandwidthStatisticsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetBandwidthStatisticsUnauthorizedData - def __init__(self, data: GetBandwidthStatisticsUnauthorizedData): + def __init__( + self, + data: GetBandwidthStatisticsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetBandwidthStatisticsUnauthorizedData) - class GetBandwidthStatisticsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetBandwidthStatisticsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetBandwidthStatisticsBadRequest(Exception): +class GetBandwidthStatisticsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetBandwidthStatisticsBadRequestData - def __init__(self, data: GetBandwidthStatisticsBadRequestData): + def __init__( + self, + data: GetBandwidthStatisticsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetBandwidthStatisticsBadRequestData) diff --git a/src/plex_api_client/models/errors/getbutlertasks.py b/src/plex_api_client/models/errors/getbutlertasks.py index 4ca84d2..6adc295 100644 --- a/src/plex_api_client/models/errors/getbutlertasks.py +++ b/src/plex_api_client/models/errors/getbutlertasks.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetButlerTasksUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetButlerTasksUnauthorized(Exception): +class GetButlerTasksUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetButlerTasksUnauthorizedData - def __init__(self, data: GetButlerTasksUnauthorizedData): + def __init__( + self, + data: GetButlerTasksUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetButlerTasksUnauthorizedData) - class GetButlerTasksErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetButlerTasksBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetButlerTasksBadRequest(Exception): +class GetButlerTasksBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetButlerTasksBadRequestData - def __init__(self, data: GetButlerTasksBadRequestData): + def __init__( + self, + data: GetButlerTasksBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetButlerTasksBadRequestData) diff --git a/src/plex_api_client/models/errors/getcompanionsdata.py b/src/plex_api_client/models/errors/getcompanionsdata.py index 01e2421..11b7f92 100644 --- a/src/plex_api_client/models/errors/getcompanionsdata.py +++ b/src/plex_api_client/models/errors/getcompanionsdata.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetCompanionsDataUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetCompanionsDataUnauthorized(Exception): +class GetCompanionsDataUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetCompanionsDataUnauthorizedData - def __init__(self, data: GetCompanionsDataUnauthorizedData): + def __init__( + self, + data: GetCompanionsDataUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetCompanionsDataUnauthorizedData) - class GetCompanionsDataErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetCompanionsDataBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetCompanionsDataBadRequest(Exception): +class GetCompanionsDataBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetCompanionsDataBadRequestData - def __init__(self, data: GetCompanionsDataBadRequestData): + def __init__( + self, + data: GetCompanionsDataBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetCompanionsDataBadRequestData) diff --git a/src/plex_api_client/models/errors/getdevices.py b/src/plex_api_client/models/errors/getdevices.py index f762ed7..0ec16eb 100644 --- a/src/plex_api_client/models/errors/getdevices.py +++ b/src/plex_api_client/models/errors/getdevices.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetDevicesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetDevicesUnauthorized(Exception): +class GetDevicesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetDevicesUnauthorizedData - def __init__(self, data: GetDevicesUnauthorizedData): + def __init__( + self, + data: GetDevicesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetDevicesUnauthorizedData) - class GetDevicesErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetDevicesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetDevicesBadRequest(Exception): +class GetDevicesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetDevicesBadRequestData - def __init__(self, data: GetDevicesBadRequestData): + def __init__( + self, + data: GetDevicesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetDevicesBadRequestData) diff --git a/src/plex_api_client/models/errors/getfilehash.py b/src/plex_api_client/models/errors/getfilehash.py index f860788..d8e56a0 100644 --- a/src/plex_api_client/models/errors/getfilehash.py +++ b/src/plex_api_client/models/errors/getfilehash.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetFileHashUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetFileHashUnauthorized(Exception): +class GetFileHashUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetFileHashUnauthorizedData - def __init__(self, data: GetFileHashUnauthorizedData): + def __init__( + self, + data: GetFileHashUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetFileHashUnauthorizedData) - class GetFileHashErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetFileHashBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetFileHashBadRequest(Exception): +class GetFileHashBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetFileHashBadRequestData - def __init__(self, data: GetFileHashBadRequestData): + def __init__( + self, + data: GetFileHashBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetFileHashBadRequestData) diff --git a/src/plex_api_client/models/errors/getgeodata.py b/src/plex_api_client/models/errors/getgeodata.py index f9c9abf..4ea33ae 100644 --- a/src/plex_api_client/models/errors/getgeodata.py +++ b/src/plex_api_client/models/errors/getgeodata.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetGeoDataUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetGeoDataUnauthorized(Exception): +class GetGeoDataUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetGeoDataUnauthorizedData - def __init__(self, data: GetGeoDataUnauthorizedData): + def __init__( + self, + data: GetGeoDataUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetGeoDataUnauthorizedData) - class GetGeoDataErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetGeoDataBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetGeoDataBadRequest(Exception): +class GetGeoDataBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetGeoDataBadRequestData - def __init__(self, data: GetGeoDataBadRequestData): + def __init__( + self, + data: GetGeoDataBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetGeoDataBadRequestData) diff --git a/src/plex_api_client/models/errors/getglobalhubs.py b/src/plex_api_client/models/errors/getglobalhubs.py index 2dcfde6..c3095d4 100644 --- a/src/plex_api_client/models/errors/getglobalhubs.py +++ b/src/plex_api_client/models/errors/getglobalhubs.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetGlobalHubsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetGlobalHubsUnauthorized(Exception): +class GetGlobalHubsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetGlobalHubsUnauthorizedData - def __init__(self, data: GetGlobalHubsUnauthorizedData): + def __init__( + self, + data: GetGlobalHubsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetGlobalHubsUnauthorizedData) - class GetGlobalHubsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetGlobalHubsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetGlobalHubsBadRequest(Exception): +class GetGlobalHubsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetGlobalHubsBadRequestData - def __init__(self, data: GetGlobalHubsBadRequestData): + def __init__( + self, + data: GetGlobalHubsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetGlobalHubsBadRequestData) diff --git a/src/plex_api_client/models/errors/gethomedata.py b/src/plex_api_client/models/errors/gethomedata.py index c957c25..446fd2b 100644 --- a/src/plex_api_client/models/errors/gethomedata.py +++ b/src/plex_api_client/models/errors/gethomedata.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetHomeDataUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetHomeDataUnauthorized(Exception): +class GetHomeDataUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetHomeDataUnauthorizedData - def __init__(self, data: GetHomeDataUnauthorizedData): + def __init__( + self, + data: GetHomeDataUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetHomeDataUnauthorizedData) - class GetHomeDataErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetHomeDataBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetHomeDataBadRequest(Exception): +class GetHomeDataBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetHomeDataBadRequestData - def __init__(self, data: GetHomeDataBadRequestData): + def __init__( + self, + data: GetHomeDataBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetHomeDataBadRequestData) diff --git a/src/plex_api_client/models/errors/getlibraryhubs.py b/src/plex_api_client/models/errors/getlibraryhubs.py index ce42172..28cbc73 100644 --- a/src/plex_api_client/models/errors/getlibraryhubs.py +++ b/src/plex_api_client/models/errors/getlibraryhubs.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetLibraryHubsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetLibraryHubsUnauthorized(Exception): +class GetLibraryHubsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetLibraryHubsUnauthorizedData - def __init__(self, data: GetLibraryHubsUnauthorizedData): + def __init__( + self, + data: GetLibraryHubsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetLibraryHubsUnauthorizedData) - class GetLibraryHubsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetLibraryHubsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetLibraryHubsBadRequest(Exception): +class GetLibraryHubsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetLibraryHubsBadRequestData - def __init__(self, data: GetLibraryHubsBadRequestData): + def __init__( + self, + data: GetLibraryHubsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetLibraryHubsBadRequestData) diff --git a/src/plex_api_client/models/errors/getmetadatachildren.py b/src/plex_api_client/models/errors/getmetadatachildren.py index 13105ec..06ffd5d 100644 --- a/src/plex_api_client/models/errors/getmetadatachildren.py +++ b/src/plex_api_client/models/errors/getmetadatachildren.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetMetadataChildrenUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetMetadataChildrenUnauthorized(Exception): +class GetMetadataChildrenUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetMetadataChildrenUnauthorizedData - def __init__(self, data: GetMetadataChildrenUnauthorizedData): + def __init__( + self, + data: GetMetadataChildrenUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetMetadataChildrenUnauthorizedData) - class GetMetadataChildrenErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetMetadataChildrenBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetMetadataChildrenBadRequest(Exception): +class GetMetadataChildrenBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetMetadataChildrenBadRequestData - def __init__(self, data: GetMetadataChildrenBadRequestData): + def __init__( + self, + data: GetMetadataChildrenBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetMetadataChildrenBadRequestData) diff --git a/src/plex_api_client/models/errors/getmyplexaccount.py b/src/plex_api_client/models/errors/getmyplexaccount.py index 9ecb127..25581bc 100644 --- a/src/plex_api_client/models/errors/getmyplexaccount.py +++ b/src/plex_api_client/models/errors/getmyplexaccount.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetMyPlexAccountUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetMyPlexAccountUnauthorized(Exception): +class GetMyPlexAccountUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetMyPlexAccountUnauthorizedData - def __init__(self, data: GetMyPlexAccountUnauthorizedData): + def __init__( + self, + data: GetMyPlexAccountUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetMyPlexAccountUnauthorizedData) - class GetMyPlexAccountErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetMyPlexAccountBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetMyPlexAccountBadRequest(Exception): +class GetMyPlexAccountBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetMyPlexAccountBadRequestData - def __init__(self, data: GetMyPlexAccountBadRequestData): + def __init__( + self, + data: GetMyPlexAccountBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetMyPlexAccountBadRequestData) diff --git a/src/plex_api_client/models/errors/getpin.py b/src/plex_api_client/models/errors/getpin.py index b33c0cc..086a02e 100644 --- a/src/plex_api_client/models/errors/getpin.py +++ b/src/plex_api_client/models/errors/getpin.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,13 +32,17 @@ class GetPinBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetPinBadRequest(Exception): +class GetPinBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetPinBadRequestData - def __init__(self, data: GetPinBadRequestData): + def __init__( + self, + data: GetPinBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetPinBadRequestData) diff --git a/src/plex_api_client/models/errors/getplaylist.py b/src/plex_api_client/models/errors/getplaylist.py index e7ec003..b0f7eed 100644 --- a/src/plex_api_client/models/errors/getplaylist.py +++ b/src/plex_api_client/models/errors/getplaylist.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetPlaylistUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetPlaylistUnauthorized(Exception): +class GetPlaylistUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetPlaylistUnauthorizedData - def __init__(self, data: GetPlaylistUnauthorizedData): + def __init__( + self, + data: GetPlaylistUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetPlaylistUnauthorizedData) - class GetPlaylistErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetPlaylistBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetPlaylistBadRequest(Exception): +class GetPlaylistBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetPlaylistBadRequestData - def __init__(self, data: GetPlaylistBadRequestData): + def __init__( + self, + data: GetPlaylistBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetPlaylistBadRequestData) diff --git a/src/plex_api_client/models/errors/getplaylistcontents.py b/src/plex_api_client/models/errors/getplaylistcontents.py index 8425e17..56d82d2 100644 --- a/src/plex_api_client/models/errors/getplaylistcontents.py +++ b/src/plex_api_client/models/errors/getplaylistcontents.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetPlaylistContentsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetPlaylistContentsUnauthorized(Exception): +class GetPlaylistContentsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetPlaylistContentsUnauthorizedData - def __init__(self, data: GetPlaylistContentsUnauthorizedData): + def __init__( + self, + data: GetPlaylistContentsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetPlaylistContentsUnauthorizedData) - class GetPlaylistContentsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetPlaylistContentsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetPlaylistContentsBadRequest(Exception): +class GetPlaylistContentsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetPlaylistContentsBadRequestData - def __init__(self, data: GetPlaylistContentsBadRequestData): + def __init__( + self, + data: GetPlaylistContentsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetPlaylistContentsBadRequestData) diff --git a/src/plex_api_client/models/errors/getplaylists.py b/src/plex_api_client/models/errors/getplaylists.py index 780f8a1..97cf2ca 100644 --- a/src/plex_api_client/models/errors/getplaylists.py +++ b/src/plex_api_client/models/errors/getplaylists.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetPlaylistsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetPlaylistsUnauthorized(Exception): +class GetPlaylistsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetPlaylistsUnauthorizedData - def __init__(self, data: GetPlaylistsUnauthorizedData): + def __init__( + self, + data: GetPlaylistsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetPlaylistsUnauthorizedData) - class GetPlaylistsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetPlaylistsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetPlaylistsBadRequest(Exception): +class GetPlaylistsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetPlaylistsBadRequestData - def __init__(self, data: GetPlaylistsBadRequestData): + def __init__( + self, + data: GetPlaylistsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetPlaylistsBadRequestData) diff --git a/src/plex_api_client/models/errors/getresizedphoto.py b/src/plex_api_client/models/errors/getresizedphoto.py index e1c81b8..986e9a5 100644 --- a/src/plex_api_client/models/errors/getresizedphoto.py +++ b/src/plex_api_client/models/errors/getresizedphoto.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetResizedPhotoUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetResizedPhotoUnauthorized(Exception): +class GetResizedPhotoUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetResizedPhotoUnauthorizedData - def __init__(self, data: GetResizedPhotoUnauthorizedData): + def __init__( + self, + data: GetResizedPhotoUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetResizedPhotoUnauthorizedData) - class GetResizedPhotoErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetResizedPhotoBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetResizedPhotoBadRequest(Exception): +class GetResizedPhotoBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetResizedPhotoBadRequestData - def __init__(self, data: GetResizedPhotoBadRequestData): + def __init__( + self, + data: GetResizedPhotoBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetResizedPhotoBadRequestData) diff --git a/src/plex_api_client/models/errors/getresourcesstatistics.py b/src/plex_api_client/models/errors/getresourcesstatistics.py index 26d46c1..2557ca9 100644 --- a/src/plex_api_client/models/errors/getresourcesstatistics.py +++ b/src/plex_api_client/models/errors/getresourcesstatistics.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetResourcesStatisticsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetResourcesStatisticsUnauthorized(Exception): +class GetResourcesStatisticsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetResourcesStatisticsUnauthorizedData - def __init__(self, data: GetResourcesStatisticsUnauthorizedData): + def __init__( + self, + data: GetResourcesStatisticsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetResourcesStatisticsUnauthorizedData) - class GetResourcesStatisticsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetResourcesStatisticsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetResourcesStatisticsBadRequest(Exception): +class GetResourcesStatisticsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetResourcesStatisticsBadRequestData - def __init__(self, data: GetResourcesStatisticsBadRequestData): + def __init__( + self, + data: GetResourcesStatisticsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetResourcesStatisticsBadRequestData) diff --git a/src/plex_api_client/models/errors/getsearchresults.py b/src/plex_api_client/models/errors/getsearchresults.py index c063be2..bc04493 100644 --- a/src/plex_api_client/models/errors/getsearchresults.py +++ b/src/plex_api_client/models/errors/getsearchresults.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetSearchResultsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSearchResultsUnauthorized(Exception): +class GetSearchResultsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetSearchResultsUnauthorizedData - def __init__(self, data: GetSearchResultsUnauthorizedData): + def __init__( + self, + data: GetSearchResultsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSearchResultsUnauthorizedData) - class GetSearchResultsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetSearchResultsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSearchResultsBadRequest(Exception): +class GetSearchResultsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetSearchResultsBadRequestData - def __init__(self, data: GetSearchResultsBadRequestData): + def __init__( + self, + data: GetSearchResultsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSearchResultsBadRequestData) diff --git a/src/plex_api_client/models/errors/getserveractivities.py b/src/plex_api_client/models/errors/getserveractivities.py index 38760da..d609f94 100644 --- a/src/plex_api_client/models/errors/getserveractivities.py +++ b/src/plex_api_client/models/errors/getserveractivities.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetServerActivitiesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerActivitiesUnauthorized(Exception): +class GetServerActivitiesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetServerActivitiesUnauthorizedData - def __init__(self, data: GetServerActivitiesUnauthorizedData): + def __init__( + self, + data: GetServerActivitiesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerActivitiesUnauthorizedData) - class GetServerActivitiesErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetServerActivitiesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerActivitiesBadRequest(Exception): +class GetServerActivitiesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetServerActivitiesBadRequestData - def __init__(self, data: GetServerActivitiesBadRequestData): + def __init__( + self, + data: GetServerActivitiesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerActivitiesBadRequestData) diff --git a/src/plex_api_client/models/errors/getservercapabilities.py b/src/plex_api_client/models/errors/getservercapabilities.py index eba994a..81abe5a 100644 --- a/src/plex_api_client/models/errors/getservercapabilities.py +++ b/src/plex_api_client/models/errors/getservercapabilities.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetServerCapabilitiesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerCapabilitiesUnauthorized(Exception): +class GetServerCapabilitiesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetServerCapabilitiesUnauthorizedData - def __init__(self, data: GetServerCapabilitiesUnauthorizedData): + def __init__( + self, + data: GetServerCapabilitiesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerCapabilitiesUnauthorizedData) - class ErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetServerCapabilitiesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerCapabilitiesBadRequest(Exception): +class GetServerCapabilitiesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetServerCapabilitiesBadRequestData - def __init__(self, data: GetServerCapabilitiesBadRequestData): + def __init__( + self, + data: GetServerCapabilitiesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerCapabilitiesBadRequestData) diff --git a/src/plex_api_client/models/errors/getserverlist.py b/src/plex_api_client/models/errors/getserverlist.py index e60cb75..cf7a992 100644 --- a/src/plex_api_client/models/errors/getserverlist.py +++ b/src/plex_api_client/models/errors/getserverlist.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetServerListUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerListUnauthorized(Exception): +class GetServerListUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetServerListUnauthorizedData - def __init__(self, data: GetServerListUnauthorizedData): + def __init__( + self, + data: GetServerListUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerListUnauthorizedData) - class GetServerListErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetServerListBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerListBadRequest(Exception): +class GetServerListBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetServerListBadRequestData - def __init__(self, data: GetServerListBadRequestData): + def __init__( + self, + data: GetServerListBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerListBadRequestData) diff --git a/src/plex_api_client/models/errors/getserverpreferences.py b/src/plex_api_client/models/errors/getserverpreferences.py index 7093aba..56da211 100644 --- a/src/plex_api_client/models/errors/getserverpreferences.py +++ b/src/plex_api_client/models/errors/getserverpreferences.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetServerPreferencesUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerPreferencesUnauthorized(Exception): +class GetServerPreferencesUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetServerPreferencesUnauthorizedData - def __init__(self, data: GetServerPreferencesUnauthorizedData): + def __init__( + self, + data: GetServerPreferencesUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerPreferencesUnauthorizedData) - class GetServerPreferencesErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetServerPreferencesBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetServerPreferencesBadRequest(Exception): +class GetServerPreferencesBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetServerPreferencesBadRequestData - def __init__(self, data: GetServerPreferencesBadRequestData): + def __init__( + self, + data: GetServerPreferencesBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetServerPreferencesBadRequestData) diff --git a/src/plex_api_client/models/errors/getsessionhistory.py b/src/plex_api_client/models/errors/getsessionhistory.py index 7442504..33a388c 100644 --- a/src/plex_api_client/models/errors/getsessionhistory.py +++ b/src/plex_api_client/models/errors/getsessionhistory.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetSessionHistoryUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSessionHistoryUnauthorized(Exception): +class GetSessionHistoryUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetSessionHistoryUnauthorizedData - def __init__(self, data: GetSessionHistoryUnauthorizedData): + def __init__( + self, + data: GetSessionHistoryUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSessionHistoryUnauthorizedData) - class GetSessionHistoryErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetSessionHistoryBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSessionHistoryBadRequest(Exception): +class GetSessionHistoryBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetSessionHistoryBadRequestData - def __init__(self, data: GetSessionHistoryBadRequestData): + def __init__( + self, + data: GetSessionHistoryBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSessionHistoryBadRequestData) diff --git a/src/plex_api_client/models/errors/getsessions.py b/src/plex_api_client/models/errors/getsessions.py index cd1f6c0..cb77038 100644 --- a/src/plex_api_client/models/errors/getsessions.py +++ b/src/plex_api_client/models/errors/getsessions.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetSessionsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSessionsUnauthorized(Exception): +class GetSessionsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetSessionsUnauthorizedData - def __init__(self, data: GetSessionsUnauthorizedData): + def __init__( + self, + data: GetSessionsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSessionsUnauthorizedData) - class GetSessionsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetSessionsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSessionsBadRequest(Exception): +class GetSessionsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetSessionsBadRequestData - def __init__(self, data: GetSessionsBadRequestData): + def __init__( + self, + data: GetSessionsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetSessionsBadRequestData) diff --git a/src/plex_api_client/models/errors/getsourceconnectioninformation.py b/src/plex_api_client/models/errors/getsourceconnectioninformation.py index dce9b25..11cde55 100644 --- a/src/plex_api_client/models/errors/getsourceconnectioninformation.py +++ b/src/plex_api_client/models/errors/getsourceconnectioninformation.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,19 +32,21 @@ class GetSourceConnectionInformationUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSourceConnectionInformationUnauthorized(Exception): +class GetSourceConnectionInformationUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetSourceConnectionInformationUnauthorizedData - def __init__(self, data: GetSourceConnectionInformationUnauthorizedData): + def __init__( + self, + data: GetSourceConnectionInformationUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json( - self.data, GetSourceConnectionInformationUnauthorizedData - ) - class GetSourceConnectionInformationErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -69,15 +71,17 @@ class GetSourceConnectionInformationBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetSourceConnectionInformationBadRequest(Exception): +class GetSourceConnectionInformationBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetSourceConnectionInformationBadRequestData - def __init__(self, data: GetSourceConnectionInformationBadRequestData): + def __init__( + self, + data: GetSourceConnectionInformationBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json( - self.data, GetSourceConnectionInformationBadRequestData - ) diff --git a/src/plex_api_client/models/errors/getstatistics.py b/src/plex_api_client/models/errors/getstatistics.py index 5d5713e..2700407 100644 --- a/src/plex_api_client/models/errors/getstatistics.py +++ b/src/plex_api_client/models/errors/getstatistics.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetStatisticsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetStatisticsUnauthorized(Exception): +class GetStatisticsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetStatisticsUnauthorizedData - def __init__(self, data: GetStatisticsUnauthorizedData): + def __init__( + self, + data: GetStatisticsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetStatisticsUnauthorizedData) - class GetStatisticsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetStatisticsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetStatisticsBadRequest(Exception): +class GetStatisticsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetStatisticsBadRequestData - def __init__(self, data: GetStatisticsBadRequestData): + def __init__( + self, + data: GetStatisticsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetStatisticsBadRequestData) diff --git a/src/plex_api_client/models/errors/gettimeline.py b/src/plex_api_client/models/errors/gettimeline.py index 26b81a7..fe3c1cf 100644 --- a/src/plex_api_client/models/errors/gettimeline.py +++ b/src/plex_api_client/models/errors/gettimeline.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetTimelineUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTimelineUnauthorized(Exception): +class GetTimelineUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetTimelineUnauthorizedData - def __init__(self, data: GetTimelineUnauthorizedData): + def __init__( + self, + data: GetTimelineUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTimelineUnauthorizedData) - class GetTimelineErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetTimelineBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTimelineBadRequest(Exception): +class GetTimelineBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetTimelineBadRequestData - def __init__(self, data: GetTimelineBadRequestData): + def __init__( + self, + data: GetTimelineBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTimelineBadRequestData) diff --git a/src/plex_api_client/models/errors/gettokenbypinid.py b/src/plex_api_client/models/errors/gettokenbypinid.py index 5531269..a52071a 100644 --- a/src/plex_api_client/models/errors/gettokenbypinid.py +++ b/src/plex_api_client/models/errors/gettokenbypinid.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -29,17 +29,21 @@ class GetTokenByPinIDResponseBodyData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTokenByPinIDResponseBody(Exception): +class GetTokenByPinIDResponseBody(PlexAPIError): r"""Not Found or Expired""" data: GetTokenByPinIDResponseBodyData - def __init__(self, data: GetTokenByPinIDResponseBodyData): + def __init__( + self, + data: GetTokenByPinIDResponseBodyData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTokenByPinIDResponseBodyData) - class GetTokenByPinIDErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -64,13 +68,17 @@ class GetTokenByPinIDBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTokenByPinIDBadRequest(Exception): +class GetTokenByPinIDBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetTokenByPinIDBadRequestData - def __init__(self, data: GetTokenByPinIDBadRequestData): + def __init__( + self, + data: GetTokenByPinIDBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTokenByPinIDBadRequestData) diff --git a/src/plex_api_client/models/errors/gettokendetails.py b/src/plex_api_client/models/errors/gettokendetails.py index a10d48e..da1c727 100644 --- a/src/plex_api_client/models/errors/gettokendetails.py +++ b/src/plex_api_client/models/errors/gettokendetails.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetTokenDetailsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTokenDetailsUnauthorized(Exception): +class GetTokenDetailsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetTokenDetailsUnauthorizedData - def __init__(self, data: GetTokenDetailsUnauthorizedData): + def __init__( + self, + data: GetTokenDetailsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTokenDetailsUnauthorizedData) - class GetTokenDetailsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetTokenDetailsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTokenDetailsBadRequest(Exception): +class GetTokenDetailsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetTokenDetailsBadRequestData - def __init__(self, data: GetTokenDetailsBadRequestData): + def __init__( + self, + data: GetTokenDetailsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTokenDetailsBadRequestData) diff --git a/src/plex_api_client/models/errors/gettopwatchedcontent.py b/src/plex_api_client/models/errors/gettopwatchedcontent.py index 7f2289b..173387e 100644 --- a/src/plex_api_client/models/errors/gettopwatchedcontent.py +++ b/src/plex_api_client/models/errors/gettopwatchedcontent.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetTopWatchedContentUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTopWatchedContentUnauthorized(Exception): +class GetTopWatchedContentUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetTopWatchedContentUnauthorizedData - def __init__(self, data: GetTopWatchedContentUnauthorizedData): + def __init__( + self, + data: GetTopWatchedContentUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTopWatchedContentUnauthorizedData) - class GetTopWatchedContentErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetTopWatchedContentBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTopWatchedContentBadRequest(Exception): +class GetTopWatchedContentBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetTopWatchedContentBadRequestData - def __init__(self, data: GetTopWatchedContentBadRequestData): + def __init__( + self, + data: GetTopWatchedContentBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTopWatchedContentBadRequestData) diff --git a/src/plex_api_client/models/errors/gettranscodesessions.py b/src/plex_api_client/models/errors/gettranscodesessions.py index e68f4d7..95a3200 100644 --- a/src/plex_api_client/models/errors/gettranscodesessions.py +++ b/src/plex_api_client/models/errors/gettranscodesessions.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetTranscodeSessionsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTranscodeSessionsUnauthorized(Exception): +class GetTranscodeSessionsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetTranscodeSessionsUnauthorizedData - def __init__(self, data: GetTranscodeSessionsUnauthorizedData): + def __init__( + self, + data: GetTranscodeSessionsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTranscodeSessionsUnauthorizedData) - class GetTranscodeSessionsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetTranscodeSessionsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTranscodeSessionsBadRequest(Exception): +class GetTranscodeSessionsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetTranscodeSessionsBadRequestData - def __init__(self, data: GetTranscodeSessionsBadRequestData): + def __init__( + self, + data: GetTranscodeSessionsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTranscodeSessionsBadRequestData) diff --git a/src/plex_api_client/models/errors/gettransienttoken.py b/src/plex_api_client/models/errors/gettransienttoken.py index 9fb24fd..7337fcb 100644 --- a/src/plex_api_client/models/errors/gettransienttoken.py +++ b/src/plex_api_client/models/errors/gettransienttoken.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetTransientTokenUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTransientTokenUnauthorized(Exception): +class GetTransientTokenUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetTransientTokenUnauthorizedData - def __init__(self, data: GetTransientTokenUnauthorizedData): + def __init__( + self, + data: GetTransientTokenUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTransientTokenUnauthorizedData) - class GetTransientTokenErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetTransientTokenBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetTransientTokenBadRequest(Exception): +class GetTransientTokenBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetTransientTokenBadRequestData - def __init__(self, data: GetTransientTokenBadRequestData): + def __init__( + self, + data: GetTransientTokenBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetTransientTokenBadRequestData) diff --git a/src/plex_api_client/models/errors/getupdatestatus.py b/src/plex_api_client/models/errors/getupdatestatus.py index 21b9028..235baae 100644 --- a/src/plex_api_client/models/errors/getupdatestatus.py +++ b/src/plex_api_client/models/errors/getupdatestatus.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetUpdateStatusUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetUpdateStatusUnauthorized(Exception): +class GetUpdateStatusUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetUpdateStatusUnauthorizedData - def __init__(self, data: GetUpdateStatusUnauthorizedData): + def __init__( + self, + data: GetUpdateStatusUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetUpdateStatusUnauthorizedData) - class GetUpdateStatusErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetUpdateStatusBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetUpdateStatusBadRequest(Exception): +class GetUpdateStatusBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetUpdateStatusBadRequestData - def __init__(self, data: GetUpdateStatusBadRequestData): + def __init__( + self, + data: GetUpdateStatusBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetUpdateStatusBadRequestData) diff --git a/src/plex_api_client/models/errors/getuserfriends.py b/src/plex_api_client/models/errors/getuserfriends.py index f410a88..8f4b0be 100644 --- a/src/plex_api_client/models/errors/getuserfriends.py +++ b/src/plex_api_client/models/errors/getuserfriends.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class GetUserFriendsUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetUserFriendsUnauthorized(Exception): +class GetUserFriendsUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: GetUserFriendsUnauthorizedData - def __init__(self, data: GetUserFriendsUnauthorizedData): + def __init__( + self, + data: GetUserFriendsUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, GetUserFriendsUnauthorizedData) - class GetUserFriendsErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class GetUserFriendsBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class GetUserFriendsBadRequest(Exception): +class GetUserFriendsBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: GetUserFriendsBadRequestData - def __init__(self, data: GetUserFriendsBadRequestData): + def __init__( + self, + data: GetUserFriendsBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, GetUserFriendsBadRequestData) diff --git a/src/plex_api_client/models/errors/logline.py b/src/plex_api_client/models/errors/logline.py index 2b9b80d..d7cfe6f 100644 --- a/src/plex_api_client/models/errors/logline.py +++ b/src/plex_api_client/models/errors/logline.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class LogLineUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class LogLineUnauthorized(Exception): +class LogLineUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: LogLineUnauthorizedData - def __init__(self, data: LogLineUnauthorizedData): + def __init__( + self, + data: LogLineUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, LogLineUnauthorizedData) - class LogLineErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class LogLineBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class LogLineBadRequest(Exception): +class LogLineBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: LogLineBadRequestData - def __init__(self, data: LogLineBadRequestData): + def __init__( + self, + data: LogLineBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, LogLineBadRequestData) diff --git a/src/plex_api_client/models/errors/logmultiline.py b/src/plex_api_client/models/errors/logmultiline.py index 8077d18..23cd62b 100644 --- a/src/plex_api_client/models/errors/logmultiline.py +++ b/src/plex_api_client/models/errors/logmultiline.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class LogMultiLineUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class LogMultiLineUnauthorized(Exception): +class LogMultiLineUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: LogMultiLineUnauthorizedData - def __init__(self, data: LogMultiLineUnauthorizedData): + def __init__( + self, + data: LogMultiLineUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, LogMultiLineUnauthorizedData) - class LogMultiLineErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class LogMultiLineBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class LogMultiLineBadRequest(Exception): +class LogMultiLineBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: LogMultiLineBadRequestData - def __init__(self, data: LogMultiLineBadRequestData): + def __init__( + self, + data: LogMultiLineBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, LogMultiLineBadRequestData) diff --git a/src/plex_api_client/models/errors/markplayed.py b/src/plex_api_client/models/errors/markplayed.py index 149c90a..39bdf05 100644 --- a/src/plex_api_client/models/errors/markplayed.py +++ b/src/plex_api_client/models/errors/markplayed.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class MarkPlayedUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class MarkPlayedUnauthorized(Exception): +class MarkPlayedUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: MarkPlayedUnauthorizedData - def __init__(self, data: MarkPlayedUnauthorizedData): + def __init__( + self, + data: MarkPlayedUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, MarkPlayedUnauthorizedData) - class MarkPlayedErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class MarkPlayedBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class MarkPlayedBadRequest(Exception): +class MarkPlayedBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: MarkPlayedBadRequestData - def __init__(self, data: MarkPlayedBadRequestData): + def __init__( + self, + data: MarkPlayedBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, MarkPlayedBadRequestData) diff --git a/src/plex_api_client/models/errors/markunplayed.py b/src/plex_api_client/models/errors/markunplayed.py index f361b05..9a9b76f 100644 --- a/src/plex_api_client/models/errors/markunplayed.py +++ b/src/plex_api_client/models/errors/markunplayed.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class MarkUnplayedUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class MarkUnplayedUnauthorized(Exception): +class MarkUnplayedUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: MarkUnplayedUnauthorizedData - def __init__(self, data: MarkUnplayedUnauthorizedData): + def __init__( + self, + data: MarkUnplayedUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, MarkUnplayedUnauthorizedData) - class MarkUnplayedErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class MarkUnplayedBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class MarkUnplayedBadRequest(Exception): +class MarkUnplayedBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: MarkUnplayedBadRequestData - def __init__(self, data: MarkUnplayedBadRequestData): + def __init__( + self, + data: MarkUnplayedBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, MarkUnplayedBadRequestData) diff --git a/src/plex_api_client/models/errors/no_response_error.py b/src/plex_api_client/models/errors/no_response_error.py new file mode 100644 index 0000000..f98beea --- /dev/null +++ b/src/plex_api_client/models/errors/no_response_error.py @@ -0,0 +1,13 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +class NoResponseError(Exception): + """Error raised when no HTTP response is received from the server.""" + + message: str + + def __init__(self, message: str = "No response received"): + self.message = message + super().__init__(message) + + def __str__(self): + return self.message diff --git a/src/plex_api_client/models/errors/performsearch.py b/src/plex_api_client/models/errors/performsearch.py index 154fe0e..d718ad5 100644 --- a/src/plex_api_client/models/errors/performsearch.py +++ b/src/plex_api_client/models/errors/performsearch.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class PerformSearchUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class PerformSearchUnauthorized(Exception): +class PerformSearchUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: PerformSearchUnauthorizedData - def __init__(self, data: PerformSearchUnauthorizedData): + def __init__( + self, + data: PerformSearchUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, PerformSearchUnauthorizedData) - class PerformSearchErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class PerformSearchBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class PerformSearchBadRequest(Exception): +class PerformSearchBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: PerformSearchBadRequestData - def __init__(self, data: PerformSearchBadRequestData): + def __init__( + self, + data: PerformSearchBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, PerformSearchBadRequestData) diff --git a/src/plex_api_client/models/errors/performvoicesearch.py b/src/plex_api_client/models/errors/performvoicesearch.py index bc31043..f7e710b 100644 --- a/src/plex_api_client/models/errors/performvoicesearch.py +++ b/src/plex_api_client/models/errors/performvoicesearch.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class PerformVoiceSearchUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class PerformVoiceSearchUnauthorized(Exception): +class PerformVoiceSearchUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: PerformVoiceSearchUnauthorizedData - def __init__(self, data: PerformVoiceSearchUnauthorizedData): + def __init__( + self, + data: PerformVoiceSearchUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, PerformVoiceSearchUnauthorizedData) - class PerformVoiceSearchErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class PerformVoiceSearchBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class PerformVoiceSearchBadRequest(Exception): +class PerformVoiceSearchBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: PerformVoiceSearchBadRequestData - def __init__(self, data: PerformVoiceSearchBadRequestData): + def __init__( + self, + data: PerformVoiceSearchBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, PerformVoiceSearchBadRequestData) diff --git a/src/plex_api_client/models/errors/plexapierror.py b/src/plex_api_client/models/errors/plexapierror.py new file mode 100644 index 0000000..be152d9 --- /dev/null +++ b/src/plex_api_client/models/errors/plexapierror.py @@ -0,0 +1,26 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import httpx +from typing import Optional + + +class PlexAPIError(Exception): + """The base class for all HTTP error responses.""" + + message: str + status_code: int + body: str + headers: httpx.Headers + raw_response: httpx.Response + + def __init__( + self, message: str, raw_response: httpx.Response, body: Optional[str] = None + ): + self.message = message + self.status_code = raw_response.status_code + self.body = body if body is not None else raw_response.text + self.headers = raw_response.headers + self.raw_response = raw_response + + def __str__(self): + return self.message diff --git a/src/plex_api_client/models/errors/post_users_sign_in_data.py b/src/plex_api_client/models/errors/post_users_sign_in_data.py index cd3c5e3..7d06a39 100644 --- a/src/plex_api_client/models/errors/post_users_sign_in_data.py +++ b/src/plex_api_client/models/errors/post_users_sign_in_data.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class PostUsersSignInDataUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class PostUsersSignInDataUnauthorized(Exception): +class PostUsersSignInDataUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: PostUsersSignInDataUnauthorizedData - def __init__(self, data: PostUsersSignInDataUnauthorizedData): + def __init__( + self, + data: PostUsersSignInDataUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, PostUsersSignInDataUnauthorizedData) - class PostUsersSignInDataErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class PostUsersSignInDataBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class PostUsersSignInDataBadRequest(Exception): +class PostUsersSignInDataBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: PostUsersSignInDataBadRequestData - def __init__(self, data: PostUsersSignInDataBadRequestData): + def __init__( + self, + data: PostUsersSignInDataBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, PostUsersSignInDataBadRequestData) diff --git a/src/plex_api_client/models/errors/responsevalidationerror.py b/src/plex_api_client/models/errors/responsevalidationerror.py new file mode 100644 index 0000000..d41c119 --- /dev/null +++ b/src/plex_api_client/models/errors/responsevalidationerror.py @@ -0,0 +1,25 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import httpx +from typing import Optional + +from plex_api_client.models.errors import PlexAPIError + + +class ResponseValidationError(PlexAPIError): + """Error raised when there is a type mismatch between the response data and the expected Pydantic model.""" + + def __init__( + self, + message: str, + raw_response: httpx.Response, + cause: Exception, + body: Optional[str] = None, + ): + message = f"{message}: {cause}" + super().__init__(message, raw_response, body) + + @property + def cause(self): + """Normally the Pydantic ValidationError""" + return self.__cause__ diff --git a/src/plex_api_client/models/errors/sdkerror.py b/src/plex_api_client/models/errors/sdkerror.py index 03216cb..f55be2a 100644 --- a/src/plex_api_client/models/errors/sdkerror.py +++ b/src/plex_api_client/models/errors/sdkerror.py @@ -1,22 +1,38 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" -from dataclasses import dataclass -from typing import Optional import httpx +from typing import Optional + +from plex_api_client.models.errors import PlexAPIError + +MAX_MESSAGE_LEN = 10_000 -@dataclass -class SDKError(Exception): - """Represents an error returned by the API.""" +class SDKError(PlexAPIError): + """The fallback error class if no more specific error class is matched.""" - message: str - status_code: int = -1 - body: str = "" - raw_response: Optional[httpx.Response] = None + def __init__( + self, message: str, raw_response: httpx.Response, body: Optional[str] = None + ): + body_display = body or raw_response.text or '""' - def __str__(self): - body = "" - if len(self.body) > 0: - body = f"\n{self.body}" + if message: + message += ": " + message += f"Status {raw_response.status_code}" - return f"{self.message}: Status {self.status_code}{body}" + headers = raw_response.headers + content_type = headers.get("content-type", '""') + if content_type != "application/json": + if " " in content_type: + content_type = f'"{content_type}"' + message += f" Content-Type {content_type}" + + if len(body_display) > MAX_MESSAGE_LEN: + truncated = body_display[:MAX_MESSAGE_LEN] + remaining = len(body_display) - MAX_MESSAGE_LEN + body_display = f"{truncated}...and {remaining} more chars" + + message += f". Body: {body_display}" + message = message.strip() + + super().__init__(message, raw_response, body) diff --git a/src/plex_api_client/models/errors/startalltasks.py b/src/plex_api_client/models/errors/startalltasks.py index e21bd8f..850bf03 100644 --- a/src/plex_api_client/models/errors/startalltasks.py +++ b/src/plex_api_client/models/errors/startalltasks.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class StartAllTasksUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StartAllTasksUnauthorized(Exception): +class StartAllTasksUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: StartAllTasksUnauthorizedData - def __init__(self, data: StartAllTasksUnauthorizedData): + def __init__( + self, + data: StartAllTasksUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, StartAllTasksUnauthorizedData) - class StartAllTasksErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class StartAllTasksBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StartAllTasksBadRequest(Exception): +class StartAllTasksBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: StartAllTasksBadRequestData - def __init__(self, data: StartAllTasksBadRequestData): + def __init__( + self, + data: StartAllTasksBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, StartAllTasksBadRequestData) diff --git a/src/plex_api_client/models/errors/starttask.py b/src/plex_api_client/models/errors/starttask.py index eb67114..af2b24a 100644 --- a/src/plex_api_client/models/errors/starttask.py +++ b/src/plex_api_client/models/errors/starttask.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class StartTaskUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StartTaskUnauthorized(Exception): +class StartTaskUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: StartTaskUnauthorizedData - def __init__(self, data: StartTaskUnauthorizedData): + def __init__( + self, + data: StartTaskUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, StartTaskUnauthorizedData) - class StartTaskErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class StartTaskBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StartTaskBadRequest(Exception): +class StartTaskBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: StartTaskBadRequestData - def __init__(self, data: StartTaskBadRequestData): + def __init__( + self, + data: StartTaskBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, StartTaskBadRequestData) diff --git a/src/plex_api_client/models/errors/startuniversaltranscode.py b/src/plex_api_client/models/errors/startuniversaltranscode.py index 73ce372..f9e6336 100644 --- a/src/plex_api_client/models/errors/startuniversaltranscode.py +++ b/src/plex_api_client/models/errors/startuniversaltranscode.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class StartUniversalTranscodeUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StartUniversalTranscodeUnauthorized(Exception): +class StartUniversalTranscodeUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: StartUniversalTranscodeUnauthorizedData - def __init__(self, data: StartUniversalTranscodeUnauthorizedData): + def __init__( + self, + data: StartUniversalTranscodeUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, StartUniversalTranscodeUnauthorizedData) - class StartUniversalTranscodeErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class StartUniversalTranscodeBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StartUniversalTranscodeBadRequest(Exception): +class StartUniversalTranscodeBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: StartUniversalTranscodeBadRequestData - def __init__(self, data: StartUniversalTranscodeBadRequestData): + def __init__( + self, + data: StartUniversalTranscodeBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, StartUniversalTranscodeBadRequestData) diff --git a/src/plex_api_client/models/errors/stopalltasks.py b/src/plex_api_client/models/errors/stopalltasks.py index 5623337..0732cd0 100644 --- a/src/plex_api_client/models/errors/stopalltasks.py +++ b/src/plex_api_client/models/errors/stopalltasks.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class StopAllTasksUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StopAllTasksUnauthorized(Exception): +class StopAllTasksUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: StopAllTasksUnauthorizedData - def __init__(self, data: StopAllTasksUnauthorizedData): + def __init__( + self, + data: StopAllTasksUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, StopAllTasksUnauthorizedData) - class StopAllTasksErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class StopAllTasksBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StopAllTasksBadRequest(Exception): +class StopAllTasksBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: StopAllTasksBadRequestData - def __init__(self, data: StopAllTasksBadRequestData): + def __init__( + self, + data: StopAllTasksBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, StopAllTasksBadRequestData) diff --git a/src/plex_api_client/models/errors/stoptask.py b/src/plex_api_client/models/errors/stoptask.py index 908e588..2aec0fe 100644 --- a/src/plex_api_client/models/errors/stoptask.py +++ b/src/plex_api_client/models/errors/stoptask.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class StopTaskUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StopTaskUnauthorized(Exception): +class StopTaskUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: StopTaskUnauthorizedData - def __init__(self, data: StopTaskUnauthorizedData): + def __init__( + self, + data: StopTaskUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, StopTaskUnauthorizedData) - class StopTaskErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class StopTaskBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StopTaskBadRequest(Exception): +class StopTaskBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: StopTaskBadRequestData - def __init__(self, data: StopTaskBadRequestData): + def __init__( + self, + data: StopTaskBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, StopTaskBadRequestData) diff --git a/src/plex_api_client/models/errors/stoptranscodesession.py b/src/plex_api_client/models/errors/stoptranscodesession.py index dee9720..05779c9 100644 --- a/src/plex_api_client/models/errors/stoptranscodesession.py +++ b/src/plex_api_client/models/errors/stoptranscodesession.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class StopTranscodeSessionUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StopTranscodeSessionUnauthorized(Exception): +class StopTranscodeSessionUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: StopTranscodeSessionUnauthorizedData - def __init__(self, data: StopTranscodeSessionUnauthorizedData): + def __init__( + self, + data: StopTranscodeSessionUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, StopTranscodeSessionUnauthorizedData) - class StopTranscodeSessionErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class StopTranscodeSessionBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class StopTranscodeSessionBadRequest(Exception): +class StopTranscodeSessionBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: StopTranscodeSessionBadRequestData - def __init__(self, data: StopTranscodeSessionBadRequestData): + def __init__( + self, + data: StopTranscodeSessionBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, StopTranscodeSessionBadRequestData) diff --git a/src/plex_api_client/models/errors/updateplaylist.py b/src/plex_api_client/models/errors/updateplaylist.py index c911d5a..8958f81 100644 --- a/src/plex_api_client/models/errors/updateplaylist.py +++ b/src/plex_api_client/models/errors/updateplaylist.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class UpdatePlaylistUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class UpdatePlaylistUnauthorized(Exception): +class UpdatePlaylistUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: UpdatePlaylistUnauthorizedData - def __init__(self, data: UpdatePlaylistUnauthorizedData): + def __init__( + self, + data: UpdatePlaylistUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, UpdatePlaylistUnauthorizedData) - class UpdatePlaylistErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class UpdatePlaylistBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class UpdatePlaylistBadRequest(Exception): +class UpdatePlaylistBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: UpdatePlaylistBadRequestData - def __init__(self, data: UpdatePlaylistBadRequestData): + def __init__( + self, + data: UpdatePlaylistBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, UpdatePlaylistBadRequestData) diff --git a/src/plex_api_client/models/errors/updateplayprogress.py b/src/plex_api_client/models/errors/updateplayprogress.py index 1f29d24..3ab21ac 100644 --- a/src/plex_api_client/models/errors/updateplayprogress.py +++ b/src/plex_api_client/models/errors/updateplayprogress.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class UpdatePlayProgressUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class UpdatePlayProgressUnauthorized(Exception): +class UpdatePlayProgressUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: UpdatePlayProgressUnauthorizedData - def __init__(self, data: UpdatePlayProgressUnauthorizedData): + def __init__( + self, + data: UpdatePlayProgressUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, UpdatePlayProgressUnauthorizedData) - class UpdatePlayProgressErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class UpdatePlayProgressBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class UpdatePlayProgressBadRequest(Exception): +class UpdatePlayProgressBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: UpdatePlayProgressBadRequestData - def __init__(self, data: UpdatePlayProgressBadRequestData): + def __init__( + self, + data: UpdatePlayProgressBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, UpdatePlayProgressBadRequestData) diff --git a/src/plex_api_client/models/errors/uploadplaylist.py b/src/plex_api_client/models/errors/uploadplaylist.py index 3207c2d..340114d 100644 --- a/src/plex_api_client/models/errors/uploadplaylist.py +++ b/src/plex_api_client/models/errors/uploadplaylist.py @@ -2,7 +2,7 @@ from __future__ import annotations import httpx -from plex_api_client import utils +from plex_api_client.models.errors import PlexAPIError from plex_api_client.types import BaseModel import pydantic from typing import List, Optional @@ -32,17 +32,21 @@ class UploadPlaylistUnauthorizedData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class UploadPlaylistUnauthorized(Exception): +class UploadPlaylistUnauthorized(PlexAPIError): r"""Unauthorized - Returned if the X-Plex-Token is missing from the header or query.""" data: UploadPlaylistUnauthorizedData - def __init__(self, data: UploadPlaylistUnauthorizedData): + def __init__( + self, + data: UploadPlaylistUnauthorizedData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - def __str__(self) -> str: - return utils.marshal_json(self.data, UploadPlaylistUnauthorizedData) - class UploadPlaylistErrorsTypedDict(TypedDict): code: NotRequired[int] @@ -67,13 +71,17 @@ class UploadPlaylistBadRequestData(BaseModel): r"""Raw HTTP response; suitable for custom response parsing""" -class UploadPlaylistBadRequest(Exception): +class UploadPlaylistBadRequest(PlexAPIError): r"""Bad Request - A parameter was not specified, or was specified incorrectly.""" data: UploadPlaylistBadRequestData - def __init__(self, data: UploadPlaylistBadRequestData): + def __init__( + self, + data: UploadPlaylistBadRequestData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + message = body or raw_response.text + super().__init__(message, raw_response, body) self.data = data - - def __str__(self) -> str: - return utils.marshal_json(self.data, UploadPlaylistBadRequestData) diff --git a/src/plex_api_client/models/operations/__init__.py b/src/plex_api_client/models/operations/__init__.py index 4366a39..87e0093 100644 --- a/src/plex_api_client/models/operations/__init__.py +++ b/src/plex_api_client/models/operations/__init__.py @@ -2,6 +2,7 @@ from typing import TYPE_CHECKING from importlib import import_module +import builtins if TYPE_CHECKING: from .addplaylistcontents import ( @@ -3451,5 +3452,5 @@ def __getattr__(attr_name: str) -> object: def __dir__(): - lazy_attrs = list(_dynamic_imports.keys()) - return sorted(lazy_attrs) + lazy_attrs = builtins.list(_dynamic_imports.keys()) + return builtins.sorted(lazy_attrs) diff --git a/src/plex_api_client/playlists.py b/src/plex_api_client/playlists.py index 99090ea..8926350 100644 --- a/src/plex_api_client/playlists.py +++ b/src/plex_api_client/playlists.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional, Union, cast @@ -94,44 +95,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.CreatePlaylistResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.CreatePlaylistResponseBody] + object=unmarshal_json_response( + Optional[operations.CreatePlaylistResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CreatePlaylistBadRequestData + response_data = unmarshal_json_response( + errors.CreatePlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.CreatePlaylistBadRequest(data=response_data) + raise errors.CreatePlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CreatePlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.CreatePlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.CreatePlaylistUnauthorized(data=response_data) + raise errors.CreatePlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def create_playlist_async( self, @@ -211,44 +201,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.CreatePlaylistResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.CreatePlaylistResponseBody] + object=unmarshal_json_response( + Optional[operations.CreatePlaylistResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CreatePlaylistBadRequestData + response_data = unmarshal_json_response( + errors.CreatePlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.CreatePlaylistBadRequest(data=response_data) + raise errors.CreatePlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CreatePlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.CreatePlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.CreatePlaylistUnauthorized(data=response_data) + raise errors.CreatePlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_playlists( self, @@ -326,44 +305,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetPlaylistsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetPlaylistsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetPlaylistsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistsBadRequestData + response_data = unmarshal_json_response( + errors.GetPlaylistsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistsBadRequest(data=response_data) + raise errors.GetPlaylistsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetPlaylistsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistsUnauthorized(data=response_data) + raise errors.GetPlaylistsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_playlists_async( self, @@ -441,44 +409,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetPlaylistsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetPlaylistsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetPlaylistsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistsBadRequestData + response_data = unmarshal_json_response( + errors.GetPlaylistsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistsBadRequest(data=response_data) + raise errors.GetPlaylistsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetPlaylistsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistsUnauthorized(data=response_data) + raise errors.GetPlaylistsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_playlist( self, @@ -555,44 +512,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetPlaylistResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetPlaylistResponseBody] + object=unmarshal_json_response( + Optional[operations.GetPlaylistResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistBadRequestData + response_data = unmarshal_json_response( + errors.GetPlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistBadRequest(data=response_data) + raise errors.GetPlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.GetPlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistUnauthorized(data=response_data) + raise errors.GetPlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_playlist_async( self, @@ -669,44 +615,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetPlaylistResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetPlaylistResponseBody] + object=unmarshal_json_response( + Optional[operations.GetPlaylistResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistBadRequestData + response_data = unmarshal_json_response( + errors.GetPlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistBadRequest(data=response_data) + raise errors.GetPlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.GetPlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistUnauthorized(data=response_data) + raise errors.GetPlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def delete_playlist( self, @@ -787,36 +722,25 @@ class Playlists(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.DeletePlaylistBadRequestData + response_data = unmarshal_json_response( + errors.DeletePlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.DeletePlaylistBadRequest(data=response_data) + raise errors.DeletePlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.DeletePlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.DeletePlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.DeletePlaylistUnauthorized(data=response_data) + raise errors.DeletePlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def delete_playlist_async( self, @@ -897,36 +821,25 @@ class Playlists(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.DeletePlaylistBadRequestData + response_data = unmarshal_json_response( + errors.DeletePlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.DeletePlaylistBadRequest(data=response_data) + raise errors.DeletePlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.DeletePlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.DeletePlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.DeletePlaylistUnauthorized(data=response_data) + raise errors.DeletePlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def update_playlist( self, @@ -1013,36 +926,25 @@ class Playlists(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UpdatePlaylistBadRequestData + response_data = unmarshal_json_response( + errors.UpdatePlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.UpdatePlaylistBadRequest(data=response_data) + raise errors.UpdatePlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UpdatePlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.UpdatePlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.UpdatePlaylistUnauthorized(data=response_data) + raise errors.UpdatePlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def update_playlist_async( self, @@ -1129,36 +1031,25 @@ class Playlists(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UpdatePlaylistBadRequestData + response_data = unmarshal_json_response( + errors.UpdatePlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.UpdatePlaylistBadRequest(data=response_data) + raise errors.UpdatePlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UpdatePlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.UpdatePlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.UpdatePlaylistUnauthorized(data=response_data) + raise errors.UpdatePlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_playlist_contents( self, @@ -1240,44 +1131,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetPlaylistContentsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetPlaylistContentsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetPlaylistContentsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistContentsBadRequestData + response_data = unmarshal_json_response( + errors.GetPlaylistContentsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistContentsBadRequest(data=response_data) + raise errors.GetPlaylistContentsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistContentsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetPlaylistContentsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistContentsUnauthorized(data=response_data) + raise errors.GetPlaylistContentsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_playlist_contents_async( self, @@ -1359,44 +1239,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetPlaylistContentsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetPlaylistContentsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetPlaylistContentsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistContentsBadRequestData + response_data = unmarshal_json_response( + errors.GetPlaylistContentsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistContentsBadRequest(data=response_data) + raise errors.GetPlaylistContentsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPlaylistContentsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetPlaylistContentsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetPlaylistContentsUnauthorized(data=response_data) + raise errors.GetPlaylistContentsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def clear_playlist_contents( self, @@ -1477,36 +1346,25 @@ class Playlists(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.ClearPlaylistContentsBadRequestData + response_data = unmarshal_json_response( + errors.ClearPlaylistContentsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.ClearPlaylistContentsBadRequest(data=response_data) + raise errors.ClearPlaylistContentsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.ClearPlaylistContentsUnauthorizedData + response_data = unmarshal_json_response( + errors.ClearPlaylistContentsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.ClearPlaylistContentsUnauthorized(data=response_data) + raise errors.ClearPlaylistContentsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def clear_playlist_contents_async( self, @@ -1587,36 +1445,25 @@ class Playlists(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.ClearPlaylistContentsBadRequestData + response_data = unmarshal_json_response( + errors.ClearPlaylistContentsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.ClearPlaylistContentsBadRequest(data=response_data) + raise errors.ClearPlaylistContentsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.ClearPlaylistContentsUnauthorizedData + response_data = unmarshal_json_response( + errors.ClearPlaylistContentsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.ClearPlaylistContentsUnauthorized(data=response_data) + raise errors.ClearPlaylistContentsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def add_playlist_contents( self, @@ -1699,44 +1546,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.AddPlaylistContentsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.AddPlaylistContentsResponseBody] + object=unmarshal_json_response( + Optional[operations.AddPlaylistContentsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.AddPlaylistContentsBadRequestData + response_data = unmarshal_json_response( + errors.AddPlaylistContentsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.AddPlaylistContentsBadRequest(data=response_data) + raise errors.AddPlaylistContentsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.AddPlaylistContentsUnauthorizedData + response_data = unmarshal_json_response( + errors.AddPlaylistContentsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.AddPlaylistContentsUnauthorized(data=response_data) + raise errors.AddPlaylistContentsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def add_playlist_contents_async( self, @@ -1819,44 +1655,33 @@ class Playlists(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.AddPlaylistContentsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.AddPlaylistContentsResponseBody] + object=unmarshal_json_response( + Optional[operations.AddPlaylistContentsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.AddPlaylistContentsBadRequestData + response_data = unmarshal_json_response( + errors.AddPlaylistContentsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.AddPlaylistContentsBadRequest(data=response_data) + raise errors.AddPlaylistContentsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.AddPlaylistContentsUnauthorizedData + response_data = unmarshal_json_response( + errors.AddPlaylistContentsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.AddPlaylistContentsUnauthorized(data=response_data) + raise errors.AddPlaylistContentsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def upload_playlist( self, @@ -1943,36 +1768,25 @@ class Playlists(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UploadPlaylistBadRequestData + response_data = unmarshal_json_response( + errors.UploadPlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.UploadPlaylistBadRequest(data=response_data) + raise errors.UploadPlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UploadPlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.UploadPlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.UploadPlaylistUnauthorized(data=response_data) + raise errors.UploadPlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def upload_playlist_async( self, @@ -2059,33 +1873,22 @@ class Playlists(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UploadPlaylistBadRequestData + response_data = unmarshal_json_response( + errors.UploadPlaylistBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.UploadPlaylistBadRequest(data=response_data) + raise errors.UploadPlaylistBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.UploadPlaylistUnauthorizedData + response_data = unmarshal_json_response( + errors.UploadPlaylistUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.UploadPlaylistUnauthorized(data=response_data) + raise errors.UploadPlaylistUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/plex.py b/src/plex_api_client/plex.py index 26e0e00..25339f4 100644 --- a/src/plex_api_client/plex.py +++ b/src/plex_api_client/plex.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, List, Mapping, Optional, Union, cast @@ -77,44 +78,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetCompanionsDataResponse( - response_bodies=utils.unmarshal_json( - http_res.text, Optional[List[operations.ResponseBody]] + response_bodies=unmarshal_json_response( + Optional[List[operations.ResponseBody]], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetCompanionsDataBadRequestData + response_data = unmarshal_json_response( + errors.GetCompanionsDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetCompanionsDataBadRequest(data=response_data) + raise errors.GetCompanionsDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetCompanionsDataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetCompanionsDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetCompanionsDataUnauthorized(data=response_data) + raise errors.GetCompanionsDataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_companions_data_async( self, @@ -182,44 +172,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetCompanionsDataResponse( - response_bodies=utils.unmarshal_json( - http_res.text, Optional[List[operations.ResponseBody]] + response_bodies=unmarshal_json_response( + Optional[List[operations.ResponseBody]], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetCompanionsDataBadRequestData + response_data = unmarshal_json_response( + errors.GetCompanionsDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetCompanionsDataBadRequest(data=response_data) + raise errors.GetCompanionsDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetCompanionsDataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetCompanionsDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetCompanionsDataUnauthorized(data=response_data) + raise errors.GetCompanionsDataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_user_friends( self, @@ -287,44 +266,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetUserFriendsResponse( - friends=utils.unmarshal_json( - http_res.text, Optional[List[operations.Friend]] + friends=unmarshal_json_response( + Optional[List[operations.Friend]], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUserFriendsBadRequestData + response_data = unmarshal_json_response( + errors.GetUserFriendsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetUserFriendsBadRequest(data=response_data) + raise errors.GetUserFriendsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUserFriendsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetUserFriendsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetUserFriendsUnauthorized(data=response_data) + raise errors.GetUserFriendsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_user_friends_async( self, @@ -392,44 +360,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetUserFriendsResponse( - friends=utils.unmarshal_json( - http_res.text, Optional[List[operations.Friend]] + friends=unmarshal_json_response( + Optional[List[operations.Friend]], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUserFriendsBadRequestData + response_data = unmarshal_json_response( + errors.GetUserFriendsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetUserFriendsBadRequest(data=response_data) + raise errors.GetUserFriendsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUserFriendsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetUserFriendsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetUserFriendsUnauthorized(data=response_data) + raise errors.GetUserFriendsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_geo_data( self, @@ -496,44 +453,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetGeoDataResponse( - geo_data=utils.unmarshal_json( - http_res.text, Optional[operations.GetGeoDataGeoData] + geo_data=unmarshal_json_response( + Optional[operations.GetGeoDataGeoData], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGeoDataBadRequestData + response_data = unmarshal_json_response( + errors.GetGeoDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetGeoDataBadRequest(data=response_data) + raise errors.GetGeoDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGeoDataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetGeoDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetGeoDataUnauthorized(data=response_data) + raise errors.GetGeoDataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_geo_data_async( self, @@ -600,44 +546,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetGeoDataResponse( - geo_data=utils.unmarshal_json( - http_res.text, Optional[operations.GetGeoDataGeoData] + geo_data=unmarshal_json_response( + Optional[operations.GetGeoDataGeoData], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGeoDataBadRequestData + response_data = unmarshal_json_response( + errors.GetGeoDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetGeoDataBadRequest(data=response_data) + raise errors.GetGeoDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetGeoDataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetGeoDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetGeoDataUnauthorized(data=response_data) + raise errors.GetGeoDataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_home_data( self, @@ -705,44 +640,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetHomeDataResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetHomeDataResponseBody] + object=unmarshal_json_response( + Optional[operations.GetHomeDataResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetHomeDataBadRequestData + response_data = unmarshal_json_response( + errors.GetHomeDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetHomeDataBadRequest(data=response_data) + raise errors.GetHomeDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetHomeDataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetHomeDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetHomeDataUnauthorized(data=response_data) + raise errors.GetHomeDataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_home_data_async( self, @@ -810,44 +734,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetHomeDataResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetHomeDataResponseBody] + object=unmarshal_json_response( + Optional[operations.GetHomeDataResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetHomeDataBadRequestData + response_data = unmarshal_json_response( + errors.GetHomeDataBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetHomeDataBadRequest(data=response_data) + raise errors.GetHomeDataBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetHomeDataUnauthorizedData + response_data = unmarshal_json_response( + errors.GetHomeDataUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetHomeDataUnauthorized(data=response_data) + raise errors.GetHomeDataUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_server_resources( self, @@ -937,44 +850,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerResourcesResponse( - plex_devices=utils.unmarshal_json( - http_res.text, Optional[List[operations.PlexDevice]] + plex_devices=unmarshal_json_response( + Optional[List[operations.PlexDevice]], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerResourcesBadRequestData + response_data = unmarshal_json_response( + errors.GetServerResourcesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerResourcesBadRequest(data=response_data) + raise errors.GetServerResourcesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerResourcesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerResourcesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerResourcesUnauthorized(data=response_data) + raise errors.GetServerResourcesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_server_resources_async( self, @@ -1064,44 +966,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerResourcesResponse( - plex_devices=utils.unmarshal_json( - http_res.text, Optional[List[operations.PlexDevice]] + plex_devices=unmarshal_json_response( + Optional[List[operations.PlexDevice]], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerResourcesBadRequestData + response_data = unmarshal_json_response( + errors.GetServerResourcesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerResourcesBadRequest(data=response_data) + raise errors.GetServerResourcesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerResourcesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerResourcesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerResourcesUnauthorized(data=response_data) + raise errors.GetServerResourcesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_pin( self, @@ -1175,38 +1066,27 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "201", "application/json"): return operations.GetPinResponse( - auth_pin_container=utils.unmarshal_json( - http_res.text, Optional[operations.GetPinAuthPinContainer] + auth_pin_container=unmarshal_json_response( + Optional[operations.GetPinAuthPinContainer], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPinBadRequestData + response_data = unmarshal_json_response( + errors.GetPinBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetPinBadRequest(data=response_data) + raise errors.GetPinBadRequest(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_pin_async( self, @@ -1280,38 +1160,27 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "201", "application/json"): return operations.GetPinResponse( - auth_pin_container=utils.unmarshal_json( - http_res.text, Optional[operations.GetPinAuthPinContainer] + auth_pin_container=unmarshal_json_response( + Optional[operations.GetPinAuthPinContainer], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetPinBadRequestData + response_data = unmarshal_json_response( + errors.GetPinBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetPinBadRequest(data=response_data) + raise errors.GetPinBadRequest(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_token_by_pin_id( self, @@ -1388,44 +1257,33 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetTokenByPinIDResponse( - auth_pin_container=utils.unmarshal_json( - http_res.text, Optional[operations.GetTokenByPinIDAuthPinContainer] + auth_pin_container=unmarshal_json_response( + Optional[operations.GetTokenByPinIDAuthPinContainer], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTokenByPinIDBadRequestData + response_data = unmarshal_json_response( + errors.GetTokenByPinIDBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTokenByPinIDBadRequest(data=response_data) + raise errors.GetTokenByPinIDBadRequest(response_data, http_res) if utils.match_response(http_res, "404", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTokenByPinIDResponseBodyData + response_data = unmarshal_json_response( + errors.GetTokenByPinIDResponseBodyData, http_res ) response_data.raw_response = http_res - raise errors.GetTokenByPinIDResponseBody(data=response_data) + raise errors.GetTokenByPinIDResponseBody(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_token_by_pin_id_async( self, @@ -1502,41 +1360,30 @@ class Plex(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetTokenByPinIDResponse( - auth_pin_container=utils.unmarshal_json( - http_res.text, Optional[operations.GetTokenByPinIDAuthPinContainer] + auth_pin_container=unmarshal_json_response( + Optional[operations.GetTokenByPinIDAuthPinContainer], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTokenByPinIDBadRequestData + response_data = unmarshal_json_response( + errors.GetTokenByPinIDBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTokenByPinIDBadRequest(data=response_data) + raise errors.GetTokenByPinIDBadRequest(response_data, http_res) if utils.match_response(http_res, "404", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTokenByPinIDResponseBodyData + response_data = unmarshal_json_response( + errors.GetTokenByPinIDResponseBodyData, http_res ) response_data.raw_response = http_res - raise errors.GetTokenByPinIDResponseBody(data=response_data) + raise errors.GetTokenByPinIDResponseBody(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/search.py b/src/plex_api_client/search.py index 503472e..7296670 100644 --- a/src/plex_api_client/search.py +++ b/src/plex_api_client/search.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional @@ -107,36 +108,25 @@ class Search(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PerformSearchBadRequestData + response_data = unmarshal_json_response( + errors.PerformSearchBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.PerformSearchBadRequest(data=response_data) + raise errors.PerformSearchBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PerformSearchUnauthorizedData + response_data = unmarshal_json_response( + errors.PerformSearchUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.PerformSearchUnauthorized(data=response_data) + raise errors.PerformSearchUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def perform_search_async( self, @@ -234,36 +224,25 @@ class Search(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PerformSearchBadRequestData + response_data = unmarshal_json_response( + errors.PerformSearchBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.PerformSearchBadRequest(data=response_data) + raise errors.PerformSearchBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PerformSearchUnauthorizedData + response_data = unmarshal_json_response( + errors.PerformSearchUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.PerformSearchUnauthorized(data=response_data) + raise errors.PerformSearchUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def perform_voice_search( self, @@ -353,36 +332,25 @@ class Search(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PerformVoiceSearchBadRequestData + response_data = unmarshal_json_response( + errors.PerformVoiceSearchBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.PerformVoiceSearchBadRequest(data=response_data) + raise errors.PerformVoiceSearchBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PerformVoiceSearchUnauthorizedData + response_data = unmarshal_json_response( + errors.PerformVoiceSearchUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.PerformVoiceSearchUnauthorized(data=response_data) + raise errors.PerformVoiceSearchUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def perform_voice_search_async( self, @@ -472,36 +440,25 @@ class Search(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PerformVoiceSearchBadRequestData + response_data = unmarshal_json_response( + errors.PerformVoiceSearchBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.PerformVoiceSearchBadRequest(data=response_data) + raise errors.PerformVoiceSearchBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.PerformVoiceSearchUnauthorizedData + response_data = unmarshal_json_response( + errors.PerformVoiceSearchUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.PerformVoiceSearchUnauthorized(data=response_data) + raise errors.PerformVoiceSearchUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_search_results( self, @@ -576,44 +533,33 @@ class Search(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSearchResultsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetSearchResultsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetSearchResultsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchResultsBadRequestData + response_data = unmarshal_json_response( + errors.GetSearchResultsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchResultsBadRequest(data=response_data) + raise errors.GetSearchResultsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchResultsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSearchResultsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchResultsUnauthorized(data=response_data) + raise errors.GetSearchResultsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_search_results_async( self, @@ -688,41 +634,30 @@ class Search(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSearchResultsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetSearchResultsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetSearchResultsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchResultsBadRequestData + response_data = unmarshal_json_response( + errors.GetSearchResultsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchResultsBadRequest(data=response_data) + raise errors.GetSearchResultsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSearchResultsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSearchResultsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSearchResultsUnauthorized(data=response_data) + raise errors.GetSearchResultsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/server.py b/src/plex_api_client/server.py index 3b31431..fb55b01 100644 --- a/src/plex_api_client/server.py +++ b/src/plex_api_client/server.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional, Union, cast @@ -77,45 +78,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerCapabilitiesResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetServerCapabilitiesResponseBody], + object=unmarshal_json_response( + Optional[operations.GetServerCapabilitiesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerCapabilitiesBadRequestData + response_data = unmarshal_json_response( + errors.GetServerCapabilitiesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerCapabilitiesBadRequest(data=response_data) + raise errors.GetServerCapabilitiesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerCapabilitiesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerCapabilitiesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerCapabilitiesUnauthorized(data=response_data) + raise errors.GetServerCapabilitiesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_server_capabilities_async( self, @@ -183,45 +172,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerCapabilitiesResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetServerCapabilitiesResponseBody], + object=unmarshal_json_response( + Optional[operations.GetServerCapabilitiesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerCapabilitiesBadRequestData + response_data = unmarshal_json_response( + errors.GetServerCapabilitiesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerCapabilitiesBadRequest(data=response_data) + raise errors.GetServerCapabilitiesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerCapabilitiesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerCapabilitiesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerCapabilitiesUnauthorized(data=response_data) + raise errors.GetServerCapabilitiesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_server_preferences( self, @@ -289,44 +266,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerPreferencesResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetServerPreferencesResponseBody] + object=unmarshal_json_response( + Optional[operations.GetServerPreferencesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerPreferencesBadRequestData + response_data = unmarshal_json_response( + errors.GetServerPreferencesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerPreferencesBadRequest(data=response_data) + raise errors.GetServerPreferencesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerPreferencesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerPreferencesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerPreferencesUnauthorized(data=response_data) + raise errors.GetServerPreferencesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_server_preferences_async( self, @@ -394,44 +360,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerPreferencesResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetServerPreferencesResponseBody] + object=unmarshal_json_response( + Optional[operations.GetServerPreferencesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerPreferencesBadRequestData + response_data = unmarshal_json_response( + errors.GetServerPreferencesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerPreferencesBadRequest(data=response_data) + raise errors.GetServerPreferencesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerPreferencesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerPreferencesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerPreferencesUnauthorized(data=response_data) + raise errors.GetServerPreferencesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_available_clients( self, @@ -499,44 +454,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetAvailableClientsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetAvailableClientsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetAvailableClientsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetAvailableClientsBadRequestData + response_data = unmarshal_json_response( + errors.GetAvailableClientsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetAvailableClientsBadRequest(data=response_data) + raise errors.GetAvailableClientsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetAvailableClientsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetAvailableClientsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetAvailableClientsUnauthorized(data=response_data) + raise errors.GetAvailableClientsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_available_clients_async( self, @@ -604,44 +548,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetAvailableClientsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetAvailableClientsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetAvailableClientsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetAvailableClientsBadRequestData + response_data = unmarshal_json_response( + errors.GetAvailableClientsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetAvailableClientsBadRequest(data=response_data) + raise errors.GetAvailableClientsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetAvailableClientsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetAvailableClientsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetAvailableClientsUnauthorized(data=response_data) + raise errors.GetAvailableClientsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_devices( self, @@ -709,44 +642,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetDevicesResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetDevicesResponseBody] + object=unmarshal_json_response( + Optional[operations.GetDevicesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetDevicesBadRequestData + response_data = unmarshal_json_response( + errors.GetDevicesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetDevicesBadRequest(data=response_data) + raise errors.GetDevicesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetDevicesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetDevicesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetDevicesUnauthorized(data=response_data) + raise errors.GetDevicesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_devices_async( self, @@ -814,44 +736,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetDevicesResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetDevicesResponseBody] + object=unmarshal_json_response( + Optional[operations.GetDevicesResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetDevicesBadRequestData + response_data = unmarshal_json_response( + errors.GetDevicesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetDevicesBadRequest(data=response_data) + raise errors.GetDevicesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetDevicesUnauthorizedData + response_data = unmarshal_json_response( + errors.GetDevicesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetDevicesUnauthorized(data=response_data) + raise errors.GetDevicesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_server_identity( self, @@ -918,38 +829,27 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerIdentityResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetServerIdentityResponseBody] + object=unmarshal_json_response( + Optional[operations.GetServerIdentityResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "408", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerIdentityRequestTimeoutData + response_data = unmarshal_json_response( + errors.GetServerIdentityRequestTimeoutData, http_res ) response_data.raw_response = http_res - raise errors.GetServerIdentityRequestTimeout(data=response_data) + raise errors.GetServerIdentityRequestTimeout(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_server_identity_async( self, @@ -1016,38 +916,27 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerIdentityResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetServerIdentityResponseBody] + object=unmarshal_json_response( + Optional[operations.GetServerIdentityResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "408", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerIdentityRequestTimeoutData + response_data = unmarshal_json_response( + errors.GetServerIdentityRequestTimeoutData, http_res ) response_data.raw_response = http_res - raise errors.GetServerIdentityRequestTimeout(data=response_data) + raise errors.GetServerIdentityRequestTimeout(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_my_plex_account( self, @@ -1115,44 +1004,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetMyPlexAccountResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMyPlexAccountResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMyPlexAccountResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMyPlexAccountBadRequestData + response_data = unmarshal_json_response( + errors.GetMyPlexAccountBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetMyPlexAccountBadRequest(data=response_data) + raise errors.GetMyPlexAccountBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMyPlexAccountUnauthorizedData + response_data = unmarshal_json_response( + errors.GetMyPlexAccountUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetMyPlexAccountUnauthorized(data=response_data) + raise errors.GetMyPlexAccountUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_my_plex_account_async( self, @@ -1220,44 +1098,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetMyPlexAccountResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMyPlexAccountResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMyPlexAccountResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMyPlexAccountBadRequestData + response_data = unmarshal_json_response( + errors.GetMyPlexAccountBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetMyPlexAccountBadRequest(data=response_data) + raise errors.GetMyPlexAccountBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMyPlexAccountUnauthorizedData + response_data = unmarshal_json_response( + errors.GetMyPlexAccountUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetMyPlexAccountUnauthorized(data=response_data) + raise errors.GetMyPlexAccountUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_resized_photo( self, @@ -1341,36 +1208,25 @@ class Server(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetResizedPhotoBadRequestData + response_data = unmarshal_json_response( + errors.GetResizedPhotoBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetResizedPhotoBadRequest(data=response_data) + raise errors.GetResizedPhotoBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetResizedPhotoUnauthorizedData + response_data = unmarshal_json_response( + errors.GetResizedPhotoUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetResizedPhotoUnauthorized(data=response_data) + raise errors.GetResizedPhotoUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_resized_photo_async( self, @@ -1454,36 +1310,25 @@ class Server(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetResizedPhotoBadRequestData + response_data = unmarshal_json_response( + errors.GetResizedPhotoBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetResizedPhotoBadRequest(data=response_data) + raise errors.GetResizedPhotoBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetResizedPhotoUnauthorizedData + response_data = unmarshal_json_response( + errors.GetResizedPhotoUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetResizedPhotoUnauthorized(data=response_data) + raise errors.GetResizedPhotoUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_media_providers( self, @@ -1558,44 +1403,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetMediaProvidersResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMediaProvidersResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMediaProvidersResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMediaProvidersBadRequestData + response_data = unmarshal_json_response( + errors.GetMediaProvidersBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetMediaProvidersBadRequest(data=response_data) + raise errors.GetMediaProvidersBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMediaProvidersUnauthorizedData + response_data = unmarshal_json_response( + errors.GetMediaProvidersUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetMediaProvidersUnauthorized(data=response_data) + raise errors.GetMediaProvidersUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_media_providers_async( self, @@ -1670,44 +1504,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetMediaProvidersResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetMediaProvidersResponseBody] + object=unmarshal_json_response( + Optional[operations.GetMediaProvidersResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMediaProvidersBadRequestData + response_data = unmarshal_json_response( + errors.GetMediaProvidersBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetMediaProvidersBadRequest(data=response_data) + raise errors.GetMediaProvidersBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetMediaProvidersUnauthorizedData + response_data = unmarshal_json_response( + errors.GetMediaProvidersUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetMediaProvidersUnauthorized(data=response_data) + raise errors.GetMediaProvidersUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_server_list( self, @@ -1775,44 +1598,33 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerListResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetServerListResponseBody] + object=unmarshal_json_response( + Optional[operations.GetServerListResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerListBadRequestData + response_data = unmarshal_json_response( + errors.GetServerListBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerListBadRequest(data=response_data) + raise errors.GetServerListBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerListUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerListUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerListUnauthorized(data=response_data) + raise errors.GetServerListUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_server_list_async( self, @@ -1880,41 +1692,30 @@ class Server(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetServerListResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetServerListResponseBody] + object=unmarshal_json_response( + Optional[operations.GetServerListResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerListBadRequestData + response_data = unmarshal_json_response( + errors.GetServerListBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetServerListBadRequest(data=response_data) + raise errors.GetServerListBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetServerListUnauthorizedData + response_data = unmarshal_json_response( + errors.GetServerListUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetServerListUnauthorized(data=response_data) + raise errors.GetServerListUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/sessions.py b/src/plex_api_client/sessions.py index f6bbddf..97c1b4b 100644 --- a/src/plex_api_client/sessions.py +++ b/src/plex_api_client/sessions.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional, Union @@ -77,44 +78,33 @@ class Sessions(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSessionsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetSessionsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetSessionsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSessionsBadRequestData + response_data = unmarshal_json_response( + errors.GetSessionsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSessionsBadRequest(data=response_data) + raise errors.GetSessionsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSessionsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSessionsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSessionsUnauthorized(data=response_data) + raise errors.GetSessionsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_sessions_async( self, @@ -182,44 +172,33 @@ class Sessions(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSessionsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetSessionsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetSessionsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSessionsBadRequestData + response_data = unmarshal_json_response( + errors.GetSessionsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSessionsBadRequest(data=response_data) + raise errors.GetSessionsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSessionsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSessionsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSessionsUnauthorized(data=response_data) + raise errors.GetSessionsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_session_history( self, @@ -307,44 +286,33 @@ class Sessions(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSessionHistoryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetSessionHistoryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetSessionHistoryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSessionHistoryBadRequestData + response_data = unmarshal_json_response( + errors.GetSessionHistoryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSessionHistoryBadRequest(data=response_data) + raise errors.GetSessionHistoryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSessionHistoryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSessionHistoryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSessionHistoryUnauthorized(data=response_data) + raise errors.GetSessionHistoryUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_session_history_async( self, @@ -432,44 +400,33 @@ class Sessions(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetSessionHistoryResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetSessionHistoryResponseBody] + object=unmarshal_json_response( + Optional[operations.GetSessionHistoryResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSessionHistoryBadRequestData + response_data = unmarshal_json_response( + errors.GetSessionHistoryBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetSessionHistoryBadRequest(data=response_data) + raise errors.GetSessionHistoryBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetSessionHistoryUnauthorizedData + response_data = unmarshal_json_response( + errors.GetSessionHistoryUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetSessionHistoryUnauthorized(data=response_data) + raise errors.GetSessionHistoryUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_transcode_sessions( self, @@ -537,44 +494,33 @@ class Sessions(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetTranscodeSessionsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetTranscodeSessionsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetTranscodeSessionsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTranscodeSessionsBadRequestData + response_data = unmarshal_json_response( + errors.GetTranscodeSessionsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTranscodeSessionsBadRequest(data=response_data) + raise errors.GetTranscodeSessionsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTranscodeSessionsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTranscodeSessionsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTranscodeSessionsUnauthorized(data=response_data) + raise errors.GetTranscodeSessionsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_transcode_sessions_async( self, @@ -642,44 +588,33 @@ class Sessions(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetTranscodeSessionsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetTranscodeSessionsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetTranscodeSessionsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTranscodeSessionsBadRequestData + response_data = unmarshal_json_response( + errors.GetTranscodeSessionsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTranscodeSessionsBadRequest(data=response_data) + raise errors.GetTranscodeSessionsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTranscodeSessionsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTranscodeSessionsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTranscodeSessionsUnauthorized(data=response_data) + raise errors.GetTranscodeSessionsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def stop_transcode_session( self, @@ -759,36 +694,25 @@ class Sessions(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopTranscodeSessionBadRequestData + response_data = unmarshal_json_response( + errors.StopTranscodeSessionBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StopTranscodeSessionBadRequest(data=response_data) + raise errors.StopTranscodeSessionBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopTranscodeSessionUnauthorizedData + response_data = unmarshal_json_response( + errors.StopTranscodeSessionUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StopTranscodeSessionUnauthorized(data=response_data) + raise errors.StopTranscodeSessionUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def stop_transcode_session_async( self, @@ -868,33 +792,22 @@ class Sessions(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopTranscodeSessionBadRequestData + response_data = unmarshal_json_response( + errors.StopTranscodeSessionBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StopTranscodeSessionBadRequest(data=response_data) + raise errors.StopTranscodeSessionBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StopTranscodeSessionUnauthorizedData + response_data = unmarshal_json_response( + errors.StopTranscodeSessionUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StopTranscodeSessionUnauthorized(data=response_data) + raise errors.StopTranscodeSessionUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/statistics.py b/src/plex_api_client/statistics.py index 1066d12..21ec5f2 100644 --- a/src/plex_api_client/statistics.py +++ b/src/plex_api_client/statistics.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional @@ -84,44 +85,33 @@ class Statistics(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetStatisticsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetStatisticsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetStatisticsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetStatisticsBadRequestData + response_data = unmarshal_json_response( + errors.GetStatisticsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetStatisticsBadRequest(data=response_data) + raise errors.GetStatisticsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetStatisticsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetStatisticsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetStatisticsUnauthorized(data=response_data) + raise errors.GetStatisticsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_statistics_async( self, @@ -196,44 +186,33 @@ class Statistics(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetStatisticsResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetStatisticsResponseBody] + object=unmarshal_json_response( + Optional[operations.GetStatisticsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetStatisticsBadRequestData + response_data = unmarshal_json_response( + errors.GetStatisticsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetStatisticsBadRequest(data=response_data) + raise errors.GetStatisticsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetStatisticsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetStatisticsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetStatisticsUnauthorized(data=response_data) + raise errors.GetStatisticsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_resources_statistics( self, @@ -308,45 +287,33 @@ class Statistics(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetResourcesStatisticsResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetResourcesStatisticsResponseBody], + object=unmarshal_json_response( + Optional[operations.GetResourcesStatisticsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetResourcesStatisticsBadRequestData + response_data = unmarshal_json_response( + errors.GetResourcesStatisticsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetResourcesStatisticsBadRequest(data=response_data) + raise errors.GetResourcesStatisticsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetResourcesStatisticsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetResourcesStatisticsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetResourcesStatisticsUnauthorized(data=response_data) + raise errors.GetResourcesStatisticsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_resources_statistics_async( self, @@ -421,45 +388,33 @@ class Statistics(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetResourcesStatisticsResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetResourcesStatisticsResponseBody], + object=unmarshal_json_response( + Optional[operations.GetResourcesStatisticsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetResourcesStatisticsBadRequestData + response_data = unmarshal_json_response( + errors.GetResourcesStatisticsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetResourcesStatisticsBadRequest(data=response_data) + raise errors.GetResourcesStatisticsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetResourcesStatisticsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetResourcesStatisticsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetResourcesStatisticsUnauthorized(data=response_data) + raise errors.GetResourcesStatisticsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def get_bandwidth_statistics( self, @@ -534,45 +489,33 @@ class Statistics(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetBandwidthStatisticsResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetBandwidthStatisticsResponseBody], + object=unmarshal_json_response( + Optional[operations.GetBandwidthStatisticsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetBandwidthStatisticsBadRequestData + response_data = unmarshal_json_response( + errors.GetBandwidthStatisticsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetBandwidthStatisticsBadRequest(data=response_data) + raise errors.GetBandwidthStatisticsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetBandwidthStatisticsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetBandwidthStatisticsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetBandwidthStatisticsUnauthorized(data=response_data) + raise errors.GetBandwidthStatisticsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_bandwidth_statistics_async( self, @@ -647,42 +590,30 @@ class Statistics(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetBandwidthStatisticsResponse( - object=utils.unmarshal_json( - http_res.text, - Optional[operations.GetBandwidthStatisticsResponseBody], + object=unmarshal_json_response( + Optional[operations.GetBandwidthStatisticsResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetBandwidthStatisticsBadRequestData + response_data = unmarshal_json_response( + errors.GetBandwidthStatisticsBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetBandwidthStatisticsBadRequest(data=response_data) + raise errors.GetBandwidthStatisticsBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetBandwidthStatisticsUnauthorizedData + response_data = unmarshal_json_response( + errors.GetBandwidthStatisticsUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetBandwidthStatisticsUnauthorized(data=response_data) + raise errors.GetBandwidthStatisticsUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/updater.py b/src/plex_api_client/updater.py index 55e4884..feddce4 100644 --- a/src/plex_api_client/updater.py +++ b/src/plex_api_client/updater.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional @@ -80,44 +81,33 @@ class Updater(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetUpdateStatusResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetUpdateStatusResponseBody] + object=unmarshal_json_response( + Optional[operations.GetUpdateStatusResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUpdateStatusBadRequestData + response_data = unmarshal_json_response( + errors.GetUpdateStatusBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetUpdateStatusBadRequest(data=response_data) + raise errors.GetUpdateStatusBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUpdateStatusUnauthorizedData + response_data = unmarshal_json_response( + errors.GetUpdateStatusUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetUpdateStatusUnauthorized(data=response_data) + raise errors.GetUpdateStatusUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_update_status_async( self, @@ -185,44 +175,33 @@ class Updater(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetUpdateStatusResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetUpdateStatusResponseBody] + object=unmarshal_json_response( + Optional[operations.GetUpdateStatusResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUpdateStatusBadRequestData + response_data = unmarshal_json_response( + errors.GetUpdateStatusBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetUpdateStatusBadRequest(data=response_data) + raise errors.GetUpdateStatusBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUpdateStatusUnauthorizedData + response_data = unmarshal_json_response( + errors.GetUpdateStatusUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetUpdateStatusUnauthorized(data=response_data) + raise errors.GetUpdateStatusUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def check_for_updates( self, @@ -302,36 +281,25 @@ class Updater(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CheckForUpdatesBadRequestData + response_data = unmarshal_json_response( + errors.CheckForUpdatesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.CheckForUpdatesBadRequest(data=response_data) + raise errors.CheckForUpdatesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CheckForUpdatesUnauthorizedData + response_data = unmarshal_json_response( + errors.CheckForUpdatesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.CheckForUpdatesUnauthorized(data=response_data) + raise errors.CheckForUpdatesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def check_for_updates_async( self, @@ -411,36 +379,25 @@ class Updater(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CheckForUpdatesBadRequestData + response_data = unmarshal_json_response( + errors.CheckForUpdatesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.CheckForUpdatesBadRequest(data=response_data) + raise errors.CheckForUpdatesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.CheckForUpdatesUnauthorizedData + response_data = unmarshal_json_response( + errors.CheckForUpdatesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.CheckForUpdatesUnauthorized(data=response_data) + raise errors.CheckForUpdatesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def apply_updates( self, @@ -524,36 +481,25 @@ class Updater(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.ApplyUpdatesBadRequestData + response_data = unmarshal_json_response( + errors.ApplyUpdatesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.ApplyUpdatesBadRequest(data=response_data) + raise errors.ApplyUpdatesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.ApplyUpdatesUnauthorizedData + response_data = unmarshal_json_response( + errors.ApplyUpdatesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.ApplyUpdatesUnauthorized(data=response_data) + raise errors.ApplyUpdatesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, ["500", "5XX"], "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def apply_updates_async( self, @@ -637,33 +583,22 @@ class Updater(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.ApplyUpdatesBadRequestData + response_data = unmarshal_json_response( + errors.ApplyUpdatesBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.ApplyUpdatesBadRequest(data=response_data) + raise errors.ApplyUpdatesBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.ApplyUpdatesUnauthorizedData + response_data = unmarshal_json_response( + errors.ApplyUpdatesUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.ApplyUpdatesUnauthorized(data=response_data) + raise errors.ApplyUpdatesUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, ["500", "5XX"], "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/users.py b/src/plex_api_client/users.py index edd8089..8383548 100644 --- a/src/plex_api_client/users.py +++ b/src/plex_api_client/users.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional, Union, cast @@ -88,36 +89,25 @@ class Users(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUsersBadRequestData + response_data = unmarshal_json_response( + errors.GetUsersBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetUsersBadRequest(data=response_data) + raise errors.GetUsersBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUsersUnauthorizedData + response_data = unmarshal_json_response( + errors.GetUsersUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetUsersUnauthorized(data=response_data) + raise errors.GetUsersUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_users_async( self, @@ -198,33 +188,22 @@ class Users(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUsersBadRequestData + response_data = unmarshal_json_response( + errors.GetUsersBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetUsersBadRequest(data=response_data) + raise errors.GetUsersBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetUsersUnauthorizedData + response_data = unmarshal_json_response( + errors.GetUsersUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetUsersUnauthorized(data=response_data) + raise errors.GetUsersUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/utils/__init__.py b/src/plex_api_client/utils/__init__.py index dd4aa4b..dc88403 100644 --- a/src/plex_api_client/utils/__init__.py +++ b/src/plex_api_client/utils/__init__.py @@ -2,6 +2,7 @@ from typing import TYPE_CHECKING from importlib import import_module +import builtins if TYPE_CHECKING: from .annotations import get_discriminator @@ -180,5 +181,5 @@ def __getattr__(attr_name: str) -> object: def __dir__(): - lazy_attrs = list(_dynamic_imports.keys()) - return sorted(lazy_attrs) + lazy_attrs = builtins.list(_dynamic_imports.keys()) + return builtins.sorted(lazy_attrs) diff --git a/src/plex_api_client/utils/forms.py b/src/plex_api_client/utils/forms.py index 0472aba..e873495 100644 --- a/src/plex_api_client/utils/forms.py +++ b/src/plex_api_client/utils/forms.py @@ -86,11 +86,39 @@ def _populate_form( return form +def _extract_file_properties(file_obj: Any) -> Tuple[str, Any, Any]: + """Extract file name, content, and content type from a file object.""" + file_fields: Dict[str, FieldInfo] = file_obj.__class__.model_fields + + file_name = "" + content = None + content_type = None + + for file_field_name in file_fields: + file_field = file_fields[file_field_name] + + file_metadata = find_field_metadata(file_field, MultipartFormMetadata) + if file_metadata is None: + continue + + if file_metadata.content: + content = getattr(file_obj, file_field_name, None) + elif file_field_name == "content_type": + content_type = getattr(file_obj, file_field_name, None) + else: + file_name = getattr(file_obj, file_field_name) + + if file_name == "" or content is None: + raise ValueError("invalid multipart/form-data file") + + return file_name, content, content_type + + def serialize_multipart_form( media_type: str, request: Any -) -> Tuple[str, Dict[str, Any], Dict[str, Any]]: +) -> Tuple[str, Dict[str, Any], List[Tuple[str, Any]]]: form: Dict[str, Any] = {} - files: Dict[str, Any] = {} + files: List[Tuple[str, Any]] = [] if not isinstance(request, BaseModel): raise TypeError("invalid request body type") @@ -112,39 +140,32 @@ def serialize_multipart_form( f_name = field.alias if field.alias else name if field_metadata.file: - file_fields: Dict[str, FieldInfo] = val.__class__.model_fields + if isinstance(val, List): + # Handle array of files + for file_obj in val: + if not _is_set(file_obj): + continue + + file_name, content, content_type = _extract_file_properties(file_obj) - file_name = "" - content = None - content_type = None - - for file_field_name in file_fields: - file_field = file_fields[file_field_name] - - file_metadata = find_field_metadata(file_field, MultipartFormMetadata) - if file_metadata is None: - continue - - if file_metadata.content: - content = getattr(val, file_field_name, None) - elif file_field_name == "content_type": - content_type = getattr(val, file_field_name, None) - else: - file_name = getattr(val, file_field_name) - - if file_name == "" or content is None: - raise ValueError("invalid multipart/form-data file") - - if content_type is not None: - files[f_name] = (file_name, content, content_type) + if content_type is not None: + files.append((f_name + "[]", (file_name, content, content_type))) + else: + files.append((f_name + "[]", (file_name, content))) else: - files[f_name] = (file_name, content) + # Handle single file + file_name, content, content_type = _extract_file_properties(val) + + if content_type is not None: + files.append((f_name, (file_name, content, content_type))) + else: + files.append((f_name, (file_name, content))) elif field_metadata.json: - files[f_name] = ( + files.append((f_name, ( None, marshal_json(val, request_field_types[name]), "application/json", - ) + ))) else: if isinstance(val, List): values = [] diff --git a/src/plex_api_client/utils/serializers.py b/src/plex_api_client/utils/serializers.py index 76e44d7..378a14c 100644 --- a/src/plex_api_client/utils/serializers.py +++ b/src/plex_api_client/utils/serializers.py @@ -192,7 +192,9 @@ def is_union(obj: object) -> bool: """ Returns True if the given object is a typing.Union or typing_extensions.Union. """ - return any(obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union")) + return any( + obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union") + ) def stream_to_text(stream: httpx.Response) -> str: @@ -245,4 +247,3 @@ def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]: f"Neither typing nor typing_extensions has an object called {name!r}" ) return result - diff --git a/src/plex_api_client/utils/unmarshal_json_response.py b/src/plex_api_client/utils/unmarshal_json_response.py new file mode 100644 index 0000000..6d90896 --- /dev/null +++ b/src/plex_api_client/utils/unmarshal_json_response.py @@ -0,0 +1,24 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import Any, Optional + +import httpx + +from .serializers import unmarshal_json +from plex_api_client.models import errors + + +def unmarshal_json_response( + typ: Any, http_res: httpx.Response, body: Optional[str] = None +) -> Any: + if body is None: + body = http_res.text + try: + return unmarshal_json(body, typ) + except Exception as e: + raise errors.ResponseValidationError( + "Response validation failed", + http_res, + e, + body, + ) from e diff --git a/src/plex_api_client/video.py b/src/plex_api_client/video.py index 3d4473e..4e8a6d7 100644 --- a/src/plex_api_client/video.py +++ b/src/plex_api_client/video.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional, Union, cast @@ -91,36 +92,25 @@ class Video(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTimelineBadRequestData + response_data = unmarshal_json_response( + errors.GetTimelineBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTimelineBadRequest(data=response_data) + raise errors.GetTimelineBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTimelineUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTimelineUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTimelineUnauthorized(data=response_data) + raise errors.GetTimelineUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_timeline_async( self, @@ -202,36 +192,25 @@ class Video(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTimelineBadRequestData + response_data = unmarshal_json_response( + errors.GetTimelineBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetTimelineBadRequest(data=response_data) + raise errors.GetTimelineBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetTimelineUnauthorizedData + response_data = unmarshal_json_response( + errors.GetTimelineUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetTimelineUnauthorized(data=response_data) + raise errors.GetTimelineUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) def start_universal_transcode( self, @@ -316,36 +295,25 @@ class Video(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartUniversalTranscodeBadRequestData + response_data = unmarshal_json_response( + errors.StartUniversalTranscodeBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StartUniversalTranscodeBadRequest(data=response_data) + raise errors.StartUniversalTranscodeBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartUniversalTranscodeUnauthorizedData + response_data = unmarshal_json_response( + errors.StartUniversalTranscodeUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StartUniversalTranscodeUnauthorized(data=response_data) + raise errors.StartUniversalTranscodeUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def start_universal_transcode_async( self, @@ -430,33 +398,22 @@ class Video(BaseSDK): raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartUniversalTranscodeBadRequestData + response_data = unmarshal_json_response( + errors.StartUniversalTranscodeBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.StartUniversalTranscodeBadRequest(data=response_data) + raise errors.StartUniversalTranscodeBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.StartUniversalTranscodeUnauthorizedData + response_data = unmarshal_json_response( + errors.StartUniversalTranscodeUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.StartUniversalTranscodeUnauthorized(data=response_data) + raise errors.StartUniversalTranscodeUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) diff --git a/src/plex_api_client/watchlist.py b/src/plex_api_client/watchlist.py index 1320709..4d7d1a1 100644 --- a/src/plex_api_client/watchlist.py +++ b/src/plex_api_client/watchlist.py @@ -5,6 +5,7 @@ from plex_api_client import utils from plex_api_client._hooks import HookContext from plex_api_client.models import errors, operations from plex_api_client.types import BaseModel, OptionalNullable, UNSET +from plex_api_client.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Mapping, Optional, Union, cast @@ -86,44 +87,33 @@ class Watchlist(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetWatchListResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetWatchListResponseBody] + object=unmarshal_json_response( + Optional[operations.GetWatchListResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetWatchListBadRequestData + response_data = unmarshal_json_response( + errors.GetWatchListBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetWatchListBadRequest(data=response_data) + raise errors.GetWatchListBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetWatchListUnauthorizedData + response_data = unmarshal_json_response( + errors.GetWatchListUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetWatchListUnauthorized(data=response_data) + raise errors.GetWatchListUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res) async def get_watch_list_async( self, @@ -200,41 +190,30 @@ class Watchlist(BaseSDK): response_data: Any = None if utils.match_response(http_res, "200", "application/json"): return operations.GetWatchListResponse( - object=utils.unmarshal_json( - http_res.text, Optional[operations.GetWatchListResponseBody] + object=unmarshal_json_response( + Optional[operations.GetWatchListResponseBody], http_res ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", raw_response=http_res, ) if utils.match_response(http_res, "400", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetWatchListBadRequestData + response_data = unmarshal_json_response( + errors.GetWatchListBadRequestData, http_res ) response_data.raw_response = http_res - raise errors.GetWatchListBadRequest(data=response_data) + raise errors.GetWatchListBadRequest(response_data, http_res) if utils.match_response(http_res, "401", "application/json"): - response_data = utils.unmarshal_json( - http_res.text, errors.GetWatchListUnauthorizedData + response_data = unmarshal_json_response( + errors.GetWatchListUnauthorizedData, http_res ) response_data.raw_response = http_res - raise errors.GetWatchListUnauthorized(data=response_data) + raise errors.GetWatchListUnauthorized(response_data, http_res) if utils.match_response(http_res, "4XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - "API error occurred", http_res.status_code, http_res_text, http_res - ) + raise errors.SDKError("API error occurred", http_res, http_res_text) - content_type = http_res.headers.get("Content-Type") - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError( - f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", - http_res.status_code, - http_res_text, - http_res, - ) + raise errors.SDKError("Unexpected response received", http_res)