ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.235.0

This commit is contained in:
speakeasybot
2024-04-03 01:13:02 +00:00
parent 03e43e4b00
commit 3f1271d2df
41 changed files with 940 additions and 980 deletions

View File

@@ -3,10 +3,10 @@ id: 3eeea668-4ef4-464e-a888-bdfa023bedf5
management: management:
docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae
docVersion: 0.0.3 docVersion: 0.0.3
speakeasyVersion: 1.228.1 speakeasyVersion: 1.235.0
generationVersion: 2.292.0 generationVersion: 2.298.0
releaseVersion: 0.5.0 releaseVersion: 0.6.0
configChecksum: 88642fda66f8275352708bb77b9deb87 configChecksum: 0711e7b95d1b4f1859b36dda6d47e994
repoURL: https://github.com/LukeHagar/plexpy.git repoURL: https://github.com/LukeHagar/plexpy.git
repoSubDirectory: . repoSubDirectory: .
installationURL: https://github.com/LukeHagar/plexpy.git installationURL: https://github.com/LukeHagar/plexpy.git
@@ -14,13 +14,13 @@ management:
features: features:
python: python:
constsAndDefaults: 0.1.3 constsAndDefaults: 0.1.3
core: 4.5.2 core: 4.6.0
flattening: 2.81.1 flattening: 2.81.1
globalSecurity: 2.83.5 globalSecurity: 2.83.5
globalServerURLs: 2.82.2 globalServerURLs: 2.82.2
globals: 2.82.1 globals: 2.82.1
methodServerURLs: 2.82.1 methodServerURLs: 2.82.1
nameOverrides: 2.81.1 nameOverrides: 2.81.2
responseFormat: 0.1.0 responseFormat: 0.1.0
generatedFiles: generatedFiles:
- src/plex_api/sdkconfiguration.py - src/plex_api/sdkconfiguration.py

View File

@@ -12,7 +12,7 @@ generation:
auth: auth:
oAuth2ClientCredentialsEnabled: false oAuth2ClientCredentialsEnabled: false
python: python:
version: 0.5.0 version: 0.6.0
additionalDependencies: additionalDependencies:
dependencies: {} dependencies: {}
extraDependencies: extraDependencies:
@@ -33,4 +33,5 @@ python:
maxMethodParams: 4 maxMethodParams: 4
outputModelSuffix: output outputModelSuffix: output
packageName: plex-api-client packageName: plex-api-client
projectUrls: {}
responseFormat: envelope responseFormat: envelope

View File

@@ -155,7 +155,7 @@ Handling errors in this SDK should largely match your expectations. All operati
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
| errors.GetServerCapabilitiesResponseBody | 401 | application/json | | errors.GetServerCapabilitiesResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
### Example ### Example
@@ -277,7 +277,7 @@ import requests
http_client = requests.Session() http_client = requests.Session()
http_client.headers.update({'x-custom-header': 'someValue'}) http_client.headers.update({'x-custom-header': 'someValue'})
s = plex_api.PlexAPI(client: http_client) s = plex_api.PlexAPI(client=http_client)
``` ```
<!-- End Custom HTTP Client [http-client] --> <!-- End Custom HTTP Client [http-client] -->

View File

@@ -118,4 +118,14 @@ Based on:
### Generated ### Generated
- [python v0.5.0] . - [python v0.5.0] .
### Releases ### Releases
- [PyPI v0.5.0] https://pypi.org/project/plex-api-client/0.5.0 - . - [PyPI v0.5.0] https://pypi.org/project/plex-api-client/0.5.0 - .
## 2024-04-03 01:12:00
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.235.0 (2.298.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v0.6.0] .
### Releases
- [PyPI v0.6.0] https://pypi.org/project/plex-api-client/0.6.0 - .

View File

@@ -49,7 +49,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- | | -------------------------------------- | -------------------------------------- | -------------------------------------- |
| errors.GetServerActivitiesResponseBody | 401 | application/json | | errors.GetServerActivitiesResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## cancel_server_activities ## cancel_server_activities
@@ -89,4 +89,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- |
| errors.CancelServerActivitiesResponseBody | 401 | application/json | | errors.CancelServerActivitiesResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -52,7 +52,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------------ | ------------------------------------ | ------------------------------------ | | ------------------------------------ | ------------------------------------ | ------------------------------------ |
| errors.GetTransientTokenResponseBody | 401 | application/json | | errors.GetTransientTokenResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_source_connection_information ## get_source_connection_information
@@ -94,4 +94,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- | | ------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- |
| errors.GetSourceConnectionInformationResponseBody | 401 | application/json | | errors.GetSourceConnectionInformationResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -46,7 +46,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------- | --------------------------------- | --------------------------------- | | --------------------------------- | --------------------------------- | --------------------------------- |
| errors.GetButlerTasksResponseBody | 401 | application/json | | errors.GetButlerTasksResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## start_all_tasks ## start_all_tasks
@@ -85,7 +85,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------- | -------------------------------- | -------------------------------- | | -------------------------------- | -------------------------------- | -------------------------------- |
| errors.StartAllTasksResponseBody | 401 | application/json | | errors.StartAllTasksResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## stop_all_tasks ## stop_all_tasks
@@ -120,7 +120,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------- | ------------------------------- | ------------------------------- | | ------------------------------- | ------------------------------- | ------------------------------- |
| errors.StopAllTasksResponseBody | 401 | application/json | | errors.StopAllTasksResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## start_task ## start_task
@@ -166,7 +166,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ---------------------------- | ---------------------------- | ---------------------------- | | ---------------------------- | ---------------------------- | ---------------------------- |
| errors.StartTaskResponseBody | 401 | application/json | | errors.StartTaskResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## stop_task ## stop_task
@@ -208,4 +208,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------- | --------------------------- | --------------------------- | | --------------------------- | --------------------------- | --------------------------- |
| errors.StopTaskResponseBody | 401 | application/json | | errors.StopTaskResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -51,7 +51,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------- | -------------------------------- | -------------------------------- | | -------------------------------- | -------------------------------- | -------------------------------- |
| errors.GetGlobalHubsResponseBody | 401 | application/json | | errors.GetGlobalHubsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_library_hubs ## get_library_hubs
@@ -95,4 +95,4 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------- | --------------------------------- | --------------------------------- | | --------------------------------- | --------------------------------- | --------------------------------- |
| errors.GetLibraryHubsResponseBody | 401 | application/json | | errors.GetLibraryHubsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -59,7 +59,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------ | ------------------------------ | ------------------------------ | | ------------------------------ | ------------------------------ | ------------------------------ |
| errors.GetFileHashResponseBody | 401 | application/json | | errors.GetFileHashResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_recently_added ## get_recently_added
@@ -94,7 +94,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ----------------------------------- | ----------------------------------- | ----------------------------------- | | ----------------------------------- | ----------------------------------- | ----------------------------------- |
| errors.GetRecentlyAddedResponseBody | 401 | application/json | | errors.GetRecentlyAddedResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_libraries ## get_libraries
@@ -134,7 +134,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------- | ------------------------------- | ------------------------------- | | ------------------------------- | ------------------------------- | ------------------------------- |
| errors.GetLibrariesResponseBody | 401 | application/json | | errors.GetLibrariesResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_library ## get_library
@@ -215,7 +215,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ----------------------------- | ----------------------------- | ----------------------------- | | ----------------------------- | ----------------------------- | ----------------------------- |
| errors.GetLibraryResponseBody | 401 | application/json | | errors.GetLibraryResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## delete_library ## delete_library
@@ -255,7 +255,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------- | -------------------------------- | -------------------------------- | | -------------------------------- | -------------------------------- | -------------------------------- |
| errors.DeleteLibraryResponseBody | 401 | application/json | | errors.DeleteLibraryResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_library_items ## get_library_items
@@ -316,7 +316,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------- | --------------- | --------------- | | --------------- | --------------- | --------------- |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## refresh_library ## refresh_library
@@ -357,7 +357,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------- | --------------------------------- | --------------------------------- | | --------------------------------- | --------------------------------- | --------------------------------- |
| errors.RefreshLibraryResponseBody | 401 | application/json | | errors.RefreshLibraryResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## search_library ## search_library
@@ -416,7 +416,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------- | --------------- | --------------- | | --------------- | --------------- | --------------- |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_metadata ## get_metadata
@@ -457,7 +457,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------ | ------------------------------ | ------------------------------ | | ------------------------------ | ------------------------------ | ------------------------------ |
| errors.GetMetadataResponseBody | 401 | application/json | | errors.GetMetadataResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_metadata_children ## get_metadata_children
@@ -498,7 +498,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- | | -------------------------------------- | -------------------------------------- | -------------------------------------- |
| errors.GetMetadataChildrenResponseBody | 401 | application/json | | errors.GetMetadataChildrenResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_on_deck ## get_on_deck
@@ -533,4 +533,4 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ---------------------------- | ---------------------------- | ---------------------------- | | ---------------------------- | ---------------------------- | ---------------------------- |
| errors.GetOnDeckResponseBody | 401 | application/json | | errors.GetOnDeckResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -54,7 +54,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------- | -------------------------- | -------------------------- | | -------------------------- | -------------------------- | -------------------------- |
| errors.LogLineResponseBody | 401 | application/json | | errors.LogLineResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## log_multi_line ## log_multi_line
@@ -118,7 +118,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------- | ------------------------------- | ------------------------------- | | ------------------------------- | ------------------------------- | ------------------------------- |
| errors.LogMultiLineResponseBody | 401 | application/json | | errors.LogMultiLineResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## enable_paper_trail ## enable_paper_trail
@@ -153,4 +153,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ----------------------------------- | ----------------------------------- | ----------------------------------- | | ----------------------------------- | ----------------------------------- | ----------------------------------- |
| errors.EnablePaperTrailResponseBody | 401 | application/json | | errors.EnablePaperTrailResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -50,7 +50,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ----------------------------- | ----------------------------- | ----------------------------- | | ----------------------------- | ----------------------------- | ----------------------------- |
| errors.MarkPlayedResponseBody | 401 | application/json | | errors.MarkPlayedResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## mark_unplayed ## mark_unplayed
@@ -90,7 +90,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------- | ------------------------------- | ------------------------------- | | ------------------------------- | ------------------------------- | ------------------------------- |
| errors.MarkUnplayedResponseBody | 401 | application/json | | errors.MarkUnplayedResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## update_play_progress ## update_play_progress
@@ -133,4 +133,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------------- | ------------------------------------- | ------------------------------------- | | ------------------------------------- | ------------------------------------- | ------------------------------------- |
| errors.UpdatePlayProgressResponseBody | 401 | application/json | | errors.UpdatePlayProgressResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -69,7 +69,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------- | --------------------------------- | --------------------------------- | | --------------------------------- | --------------------------------- | --------------------------------- |
| errors.CreatePlaylistResponseBody | 401 | application/json | | errors.CreatePlaylistResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_playlists ## get_playlists
@@ -111,7 +111,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------- | ------------------------------- | ------------------------------- | | ------------------------------- | ------------------------------- | ------------------------------- |
| errors.GetPlaylistsResponseBody | 401 | application/json | | errors.GetPlaylistsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_playlist ## get_playlist
@@ -153,7 +153,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------ | ------------------------------ | ------------------------------ | | ------------------------------ | ------------------------------ | ------------------------------ |
| errors.GetPlaylistResponseBody | 401 | application/json | | errors.GetPlaylistResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## delete_playlist ## delete_playlist
@@ -194,7 +194,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------- | --------------------------------- | --------------------------------- | | --------------------------------- | --------------------------------- | --------------------------------- |
| errors.DeletePlaylistResponseBody | 401 | application/json | | errors.DeletePlaylistResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## update_playlist ## update_playlist
@@ -237,7 +237,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------- | --------------------------------- | --------------------------------- | | --------------------------------- | --------------------------------- | --------------------------------- |
| errors.UpdatePlaylistResponseBody | 401 | application/json | | errors.UpdatePlaylistResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_playlist_contents ## get_playlist_contents
@@ -282,7 +282,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- | | -------------------------------------- | -------------------------------------- | -------------------------------------- |
| errors.GetPlaylistContentsResponseBody | 401 | application/json | | errors.GetPlaylistContentsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## clear_playlist_contents ## clear_playlist_contents
@@ -323,7 +323,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
| errors.ClearPlaylistContentsResponseBody | 401 | application/json | | errors.ClearPlaylistContentsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## add_playlist_contents ## add_playlist_contents
@@ -367,7 +367,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- | | -------------------------------------- | -------------------------------------- | -------------------------------------- |
| errors.AddPlaylistContentsResponseBody | 401 | application/json | | errors.AddPlaylistContentsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## upload_playlist ## upload_playlist
@@ -410,4 +410,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------- | --------------------------------- | --------------------------------- | | --------------------------------- | --------------------------------- | --------------------------------- |
| errors.UploadPlaylistResponseBody | 401 | application/json | | errors.UploadPlaylistResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -50,7 +50,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------- | ------------------------- | ------------------------- | | ------------------------- | ------------------------- | ------------------------- |
| errors.GetPinResponseBody | 400 | application/json | | errors.GetPinResponseBody | 400 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_token ## get_token
@@ -91,4 +91,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------- | --------------------------- | --------------------------- | | --------------------------- | --------------------------- | --------------------------- |
| errors.GetTokenResponseBody | 400 | application/json | | errors.GetTokenResponseBody | 400 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -64,7 +64,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------- | -------------------------------- | -------------------------------- | | -------------------------------- | -------------------------------- | -------------------------------- |
| errors.PerformSearchResponseBody | 401 | application/json | | errors.PerformSearchResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## perform_voice_search ## perform_voice_search
@@ -110,7 +110,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------------- | ------------------------------------- | ------------------------------------- | | ------------------------------------- | ------------------------------------- | ------------------------------------- |
| errors.PerformVoiceSearchResponseBody | 401 | application/json | | errors.PerformVoiceSearchResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_search_results ## get_search_results
@@ -150,4 +150,4 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ----------------------------------- | ----------------------------------- | ----------------------------------- | | ----------------------------------- | ----------------------------------- | ----------------------------------- |
| errors.GetSearchResultsResponseBody | 401 | application/json | | errors.GetSearchResultsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -49,7 +49,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
| errors.GetServerCapabilitiesResponseBody | 401 | application/json | | errors.GetServerCapabilitiesResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_server_preferences ## get_server_preferences
@@ -83,7 +83,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------------- | --------------------------------------- | --------------------------------------- | | --------------------------------------- | --------------------------------------- | --------------------------------------- |
| errors.GetServerPreferencesResponseBody | 401 | application/json | | errors.GetServerPreferencesResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_available_clients ## get_available_clients
@@ -117,7 +117,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- | | -------------------------------------- | -------------------------------------- | -------------------------------------- |
| errors.GetAvailableClientsResponseBody | 401 | application/json | | errors.GetAvailableClientsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_devices ## get_devices
@@ -151,7 +151,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ----------------------------- | ----------------------------- | ----------------------------- | | ----------------------------- | ----------------------------- | ----------------------------- |
| errors.GetDevicesResponseBody | 401 | application/json | | errors.GetDevicesResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_server_identity ## get_server_identity
@@ -185,7 +185,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------------ | ------------------------------------ | ------------------------------------ | | ------------------------------------ | ------------------------------------ | ------------------------------------ |
| errors.GetServerIdentityResponseBody | 401 | application/json | | errors.GetServerIdentityResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_my_plex_account ## get_my_plex_account
@@ -219,7 +219,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ----------------------------------- | ----------------------------------- | ----------------------------------- | | ----------------------------------- | ----------------------------------- | ----------------------------------- |
| errors.GetMyPlexAccountResponseBody | 401 | application/json | | errors.GetMyPlexAccountResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_resized_photo ## get_resized_photo
@@ -270,7 +270,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ---------------------------------- | ---------------------------------- | ---------------------------------- | | ---------------------------------- | ---------------------------------- | ---------------------------------- |
| errors.GetResizedPhotoResponseBody | 401 | application/json | | errors.GetResizedPhotoResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_server_list ## get_server_list
@@ -304,4 +304,4 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------- | -------------------------------- | -------------------------------- | | -------------------------------- | -------------------------------- | -------------------------------- |
| errors.GetServerListResponseBody | 401 | application/json | | errors.GetServerListResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -45,7 +45,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------ | ------------------------------ | ------------------------------ | | ------------------------------ | ------------------------------ | ------------------------------ |
| errors.GetSessionsResponseBody | 401 | application/json | | errors.GetSessionsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_session_history ## get_session_history
@@ -79,7 +79,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------------ | ------------------------------------ | ------------------------------------ | | ------------------------------------ | ------------------------------------ | ------------------------------------ |
| errors.GetSessionHistoryResponseBody | 401 | application/json | | errors.GetSessionHistoryResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## get_transcode_sessions ## get_transcode_sessions
@@ -113,7 +113,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------------- | --------------------------------------- | --------------------------------------- | | --------------------------------------- | --------------------------------------- | --------------------------------------- |
| errors.GetTranscodeSessionsResponseBody | 401 | application/json | | errors.GetTranscodeSessionsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## stop_transcode_session ## stop_transcode_session
@@ -153,4 +153,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| --------------------------------------- | --------------------------------------- | --------------------------------------- | | --------------------------------------- | --------------------------------------- | --------------------------------------- |
| errors.StopTranscodeSessionResponseBody | 401 | application/json | | errors.StopTranscodeSessionResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -48,4 +48,4 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| -------------------------------- | -------------------------------- | -------------------------------- | | -------------------------------- | -------------------------------- | -------------------------------- |
| errors.GetStatisticsResponseBody | 401 | application/json | | errors.GetStatisticsResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -45,7 +45,7 @@ if res.object is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ---------------------------------- | ---------------------------------- | ---------------------------------- | | ---------------------------------- | ---------------------------------- | ---------------------------------- |
| errors.GetUpdateStatusResponseBody | 401 | application/json | | errors.GetUpdateStatusResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## check_for_updates ## check_for_updates
@@ -86,7 +86,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ---------------------------------- | ---------------------------------- | ---------------------------------- | | ---------------------------------- | ---------------------------------- | ---------------------------------- |
| errors.CheckForUpdatesResponseBody | 401 | application/json | | errors.CheckForUpdatesResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## apply_updates ## apply_updates
@@ -129,4 +129,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------- | ------------------------------- | ------------------------------- | | ------------------------------- | ------------------------------- | ------------------------------- |
| errors.ApplyUpdatesResponseBody | 401 | application/json | | errors.ApplyUpdatesResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -62,7 +62,7 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------ | ------------------------------ | ------------------------------ | | ------------------------------ | ------------------------------ | ------------------------------ |
| errors.GetTimelineResponseBody | 401 | application/json | | errors.GetTimelineResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |
## start_universal_transcode ## start_universal_transcode
@@ -110,4 +110,4 @@ if res is not None:
| Error Object | Status Code | Content Type | | Error Object | Status Code | Content Type |
| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ |
| errors.StartUniversalTranscodeResponseBody | 401 | application/json | | errors.StartUniversalTranscodeResponseBody | 401 | application/json |
| errors.SDKError | 4x-5xx | */* | | errors.SDKError | 4xx-5xx | */* |

View File

@@ -445,7 +445,8 @@ disable=raw-checker-failed,
too-many-nested-blocks, too-many-nested-blocks,
too-many-boolean-expressions, too-many-boolean-expressions,
no-else-raise, no-else-raise,
bare-except bare-except,
broad-exception-caught
# Enable the message, report, category or checker with the given id(s). You can # Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option # either give multiple identifier separated by comma (,) or put this option

View File

@@ -10,9 +10,10 @@ except FileNotFoundError:
setuptools.setup( setuptools.setup(
name="plex-api-client", name="plex-api-client",
version="0.5.0", version="0.6.0",
author="LukeHagar", author="LukeHagar",
description="Python Client SDK Generated by Speakeasy", description="Python Client SDK Generated by Speakeasy",
url="https://github.com/LukeHagar/plexpy.git",
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
packages=setuptools.find_packages(where="src"), packages=setuptools.find_packages(where="src"),

View File

@@ -3,7 +3,7 @@
import requests import requests
from .types import SDKInitHook, BeforeRequestContext, BeforeRequestHook, AfterSuccessContext, AfterSuccessHook, AfterErrorContext, AfterErrorHook, Hooks from .types import SDKInitHook, BeforeRequestContext, BeforeRequestHook, AfterSuccessContext, AfterSuccessHook, AfterErrorContext, AfterErrorHook, Hooks
from .registration import init_hooks from .registration import init_hooks
from typing import List, Optional, Tuple, Union from typing import List, Optional, Tuple
class SDKHooks(Hooks): class SDKHooks(Hooks):
@@ -31,19 +31,21 @@ class SDKHooks(Hooks):
base_url, client = hook.sdk_init(base_url, client) base_url, client = hook.sdk_init(base_url, client)
return base_url, client return base_url, client
def before_request(self, hook_ctx: BeforeRequestContext, request: requests.PreparedRequest) -> Union[requests.PreparedRequest, Exception]: def before_request(self, hook_ctx: BeforeRequestContext, request: requests.PreparedRequest) -> requests.PreparedRequest:
for hook in self.before_request_hooks: for hook in self.before_request_hooks:
request = hook.before_request(hook_ctx, request) out = hook.before_request(hook_ctx, request)
if isinstance(request, Exception): if isinstance(out, Exception):
raise request raise out
request = out
return request return request
def after_success(self, hook_ctx: AfterSuccessContext, response: requests.Response) -> requests.Response: def after_success(self, hook_ctx: AfterSuccessContext, response: requests.Response) -> requests.Response:
for hook in self.after_success_hooks: for hook in self.after_success_hooks:
response = hook.after_success(hook_ctx, response) out = hook.after_success(hook_ctx, response)
if isinstance(response, Exception): if isinstance(out, Exception):
raise response raise out
response = out
return response return response
def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests.Response], error: Optional[Exception]) -> Tuple[Optional[requests.Response], Optional[Exception]]: def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests.Response], error: Optional[Exception]) -> Tuple[Optional[requests.Response], Optional[Exception]]:

View File

@@ -17,15 +17,19 @@ class HookContext:
class BeforeRequestContext(HookContext): class BeforeRequestContext(HookContext):
pass def __init__(self, hook_ctx: HookContext):
super().__init__(hook_ctx.operation_id, hook_ctx.oauth2_scopes, hook_ctx.security_source)
class AfterSuccessContext(HookContext): class AfterSuccessContext(HookContext):
pass def __init__(self, hook_ctx: HookContext):
super().__init__(hook_ctx.operation_id, hook_ctx.oauth2_scopes, hook_ctx.security_source)
class AfterErrorContext(HookContext): class AfterErrorContext(HookContext):
pass def __init__(self, hook_ctx: HookContext):
super().__init__(hook_ctx.operation_id, hook_ctx.oauth2_scopes, hook_ctx.security_source)
class SDKInitHook(ABC): class SDKInitHook(ABC):

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -42,30 +42,29 @@ class Activities:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetServerActivitiesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetServerActivitiesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerActivitiesResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerActivitiesResponseBody])
res.object = out res.object = out
else: else:
@@ -74,7 +73,7 @@ class Activities:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetServerActivitiesResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetServerActivitiesResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -111,34 +110,33 @@ class Activities:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('DELETE', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.CancelServerActivitiesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.CancelServerActivitiesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.CancelServerActivitiesResponseBody) out = utils.unmarshal_json(http_res.text, errors.CancelServerActivitiesResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
class Authentication: class Authentication:
@@ -40,34 +40,33 @@ class Authentication:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetTransientTokenResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetTransientTokenResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetTransientTokenResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetTransientTokenResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -106,34 +105,33 @@ class Authentication:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetSourceConnectionInformationResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetSourceConnectionInformationResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetSourceConnectionInformationResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetSourceConnectionInformationResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -35,30 +35,29 @@ class Butler:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetButlerTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetButlerTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetButlerTasksResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetButlerTasksResponseBody])
res.object = out res.object = out
else: else:
@@ -67,7 +66,7 @@ class Butler:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetButlerTasksResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetButlerTasksResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -104,34 +103,33 @@ class Butler:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.StartAllTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.StartAllTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.StartAllTasksResponseBody) out = utils.unmarshal_json(http_res.text, errors.StartAllTasksResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -164,34 +162,33 @@ class Butler:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('DELETE', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.StopAllTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.StopAllTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.StopAllTasksResponseBody) out = utils.unmarshal_json(http_res.text, errors.StopAllTasksResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -232,34 +229,33 @@ class Butler:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.StartTaskResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.StartTaskResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code in [200, 202]: if http_res.status_code in [200, 202]:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.StartTaskResponseBody) out = utils.unmarshal_json(http_res.text, errors.StartTaskResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -296,34 +292,33 @@ class Butler:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('DELETE', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','404','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','404','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.StopTaskResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.StopTaskResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code == 404 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code == 404 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.StopTaskResponseBody) out = utils.unmarshal_json(http_res.text, errors.StopTaskResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -41,30 +41,29 @@ class Hubs:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetGlobalHubsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetGlobalHubsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetGlobalHubsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetGlobalHubsResponseBody])
res.object = out res.object = out
else: else:
@@ -73,7 +72,7 @@ class Hubs:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetGlobalHubsResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetGlobalHubsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -113,30 +112,29 @@ class Hubs:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetLibraryHubsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetLibraryHubsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryHubsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryHubsResponseBody])
res.object = out res.object = out
else: else:
@@ -145,7 +143,7 @@ class Hubs:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetLibraryHubsResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetLibraryHubsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -41,34 +41,33 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetFileHashResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetFileHashResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetFileHashResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetFileHashResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -101,30 +100,29 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetRecentlyAddedResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetRecentlyAddedResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetRecentlyAddedResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetRecentlyAddedResponseBody])
res.object = out res.object = out
else: else:
@@ -133,7 +131,7 @@ class Library:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetRecentlyAddedResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetRecentlyAddedResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -171,30 +169,29 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetLibrariesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetLibrariesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibrariesResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibrariesResponseBody])
res.object = out res.object = out
else: else:
@@ -203,7 +200,7 @@ class Library:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetLibrariesResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetLibrariesResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -280,30 +277,29 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryResponseBody])
res.object = out res.object = out
else: else:
@@ -312,7 +308,7 @@ class Library:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetLibraryResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetLibraryResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -349,34 +345,33 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('DELETE', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.DeleteLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.DeleteLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.DeleteLibraryResponseBody) out = utils.unmarshal_json(http_res.text, errors.DeleteLibraryResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -433,30 +428,29 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['4XX','5XX'], http_res.status_code): if utils.match_status_codes(['4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetLibraryItemsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetLibraryItemsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryItemsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryItemsResponseBody])
res.object = out res.object = out
else: else:
@@ -494,34 +488,33 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.RefreshLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.RefreshLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.RefreshLibraryResponseBody) out = utils.unmarshal_json(http_res.text, errors.RefreshLibraryResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -577,30 +570,29 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['4XX','5XX'], http_res.status_code): if utils.match_status_codes(['4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.SearchLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.SearchLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.SearchLibraryResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.SearchLibraryResponseBody])
res.object = out res.object = out
else: else:
@@ -638,30 +630,29 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetMetadataResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetMetadataResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetMetadataResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetMetadataResponseBody])
res.object = out res.object = out
else: else:
@@ -670,7 +661,7 @@ class Library:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetMetadataResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetMetadataResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -707,30 +698,29 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetMetadataChildrenResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetMetadataChildrenResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetMetadataChildrenResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetMetadataChildrenResponseBody])
res.object = out res.object = out
else: else:
@@ -739,7 +729,7 @@ class Library:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetMetadataChildrenResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetMetadataChildrenResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -772,30 +762,29 @@ class Library:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetOnDeckResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetOnDeckResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetOnDeckResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetOnDeckResponseBody])
res.object = out res.object = out
else: else:
@@ -804,7 +793,7 @@ class Library:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetOnDeckResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetOnDeckResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
class Log: class Log:
@@ -41,34 +41,33 @@ class Log:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.LogLineResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.LogLineResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.LogLineResponseBody) out = utils.unmarshal_json(http_res.text, errors.LogLineResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -126,34 +125,33 @@ class Log:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('POST', url, params=query_params, data=data, files=form, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('POST', url, params=query_params, data=data, files=form, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.LogMultiLineResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.LogMultiLineResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.LogMultiLineResponseBody) out = utils.unmarshal_json(http_res.text, errors.LogMultiLineResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -186,34 +184,33 @@ class Log:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','403','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','403','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.EnablePaperTrailResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.EnablePaperTrailResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code == 403 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code == 403 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.EnablePaperTrailResponseBody) out = utils.unmarshal_json(http_res.text, errors.EnablePaperTrailResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
class Media: class Media:
@@ -39,34 +39,33 @@ class Media:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.MarkPlayedResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.MarkPlayedResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.MarkPlayedResponseBody) out = utils.unmarshal_json(http_res.text, errors.MarkPlayedResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -104,34 +103,33 @@ class Media:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.MarkUnplayedResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.MarkUnplayedResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.MarkUnplayedResponseBody) out = utils.unmarshal_json(http_res.text, errors.MarkUnplayedResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -171,34 +169,33 @@ class Media:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.UpdatePlayProgressResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.UpdatePlayProgressResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.UpdatePlayProgressResponseBody) out = utils.unmarshal_json(http_res.text, errors.UpdatePlayProgressResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -42,30 +42,29 @@ class Playlists:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.CreatePlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.CreatePlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.CreatePlaylistResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.CreatePlaylistResponseBody])
res.object = out res.object = out
else: else:
@@ -74,7 +73,7 @@ class Playlists:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.CreatePlaylistResponseBody) out = utils.unmarshal_json(http_res.text, errors.CreatePlaylistResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -113,30 +112,29 @@ class Playlists:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetPlaylistsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetPlaylistsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetPlaylistsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetPlaylistsResponseBody])
res.object = out res.object = out
else: else:
@@ -145,7 +143,7 @@ class Playlists:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetPlaylistsResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetPlaylistsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -183,30 +181,29 @@ class Playlists:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetPlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetPlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetPlaylistResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetPlaylistResponseBody])
res.object = out res.object = out
else: else:
@@ -215,7 +212,7 @@ class Playlists:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetPlaylistResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetPlaylistResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -252,34 +249,33 @@ class Playlists:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('DELETE', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.DeletePlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.DeletePlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.DeletePlaylistResponseBody) out = utils.unmarshal_json(http_res.text, errors.DeletePlaylistResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -319,34 +315,33 @@ class Playlists:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('PUT', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('PUT', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.UpdatePlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.UpdatePlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.UpdatePlaylistResponseBody) out = utils.unmarshal_json(http_res.text, errors.UpdatePlaylistResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -388,30 +383,29 @@ class Playlists:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetPlaylistContentsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetPlaylistContentsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetPlaylistContentsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetPlaylistContentsResponseBody])
res.object = out res.object = out
else: else:
@@ -420,7 +414,7 @@ class Playlists:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetPlaylistContentsResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetPlaylistContentsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -457,34 +451,33 @@ class Playlists:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('DELETE', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.ClearPlaylistContentsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.ClearPlaylistContentsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.ClearPlaylistContentsResponseBody) out = utils.unmarshal_json(http_res.text, errors.ClearPlaylistContentsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -525,30 +518,29 @@ class Playlists:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('PUT', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('PUT', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.AddPlaylistContentsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.AddPlaylistContentsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.AddPlaylistContentsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.AddPlaylistContentsResponseBody])
res.object = out res.object = out
else: else:
@@ -557,7 +549,7 @@ class Playlists:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.AddPlaylistContentsResponseBody) out = utils.unmarshal_json(http_res.text, errors.AddPlaylistContentsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -596,34 +588,33 @@ class Playlists:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.UploadPlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.UploadPlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.UploadPlaylistResponseBody) out = utils.unmarshal_json(http_res.text, errors.UploadPlaylistResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -43,37 +43,36 @@ class Plex:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetPinResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetPinResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetPinResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetPinResponseBody])
res.object = out res.object = out
else: else:
content_type = http_res.headers.get('Content-Type') content_type = http_res.headers.get('Content-Type')
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 400: elif http_res.status_code == 400:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetPinResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetPinResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -114,32 +113,31 @@ class Plex:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetTokenResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetTokenResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400: elif http_res.status_code == 400:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetTokenResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetTokenResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -16,6 +16,7 @@ from .server import Server
from .sessions import Sessions from .sessions import Sessions
from .statistics import Statistics from .statistics import Statistics
from .updater import Updater from .updater import Updater
from .utils.retries import RetryConfig
from .video import Video from .video import Video
from plex_api import utils from plex_api import utils
from plex_api._hooks import SDKHooks from plex_api._hooks import SDKHooks
@@ -82,7 +83,7 @@ class PlexAPI:
server_url: Optional[str] = None, server_url: Optional[str] = None,
url_params: Optional[Dict[str, str]] = None, url_params: Optional[Dict[str, str]] = None,
client: Optional[requests_http.Session] = None, client: Optional[requests_http.Session] = None,
retry_config: Optional[utils.RetryConfig] = None retry_config: Optional[RetryConfig] = None
) -> None: ) -> None:
"""Instantiates the SDK configuring it with the provided parameters. """Instantiates the SDK configuring it with the provided parameters.
@@ -105,7 +106,7 @@ class PlexAPI:
:param client: The requests.Session HTTP client to use for all operations :param client: The requests.Session HTTP client to use for all operations
:type client: requests_http.Session :type client: requests_http.Session
:param retry_config: The utils.RetryConfig to use globally :param retry_config: The utils.RetryConfig to use globally
:type retry_config: utils.RetryConfig :type retry_config: RetryConfig
""" """
if client is None: if client is None:
client = requests_http.Session() client = requests_http.Session()

View File

@@ -8,7 +8,7 @@ from .utils.retries import RetryConfig
from dataclasses import dataclass, field from dataclasses import dataclass, field
from enum import Enum from enum import Enum
from plex_api.models import components from plex_api.models import components
from typing import Any, Callable, Dict, List, Tuple, Union from typing import Any, Callable, Dict, List, Optional, Tuple, Union
SERVERS = [ SERVERS = [
@@ -27,20 +27,20 @@ class ServerProtocol(str, Enum):
class SDKConfiguration: class SDKConfiguration:
client: requests_http.Session client: requests_http.Session
security: Union[components.Security,Callable[[], components.Security]] = None security: Union[components.Security,Callable[[], components.Security]] = None
server_url: str = '' server_url: Optional[str] = ''
server_idx: int = 0 server_idx: Optional[int] = 0
server_defaults: List[Dict[str, str]] = field(default_factory=List) server_defaults: List[Dict[str, str]] = field(default_factory=List)
globals: Dict[str, Dict[str, Dict[str, Any]]] = field(default_factory=Dict) globals: Dict[str, Dict[str, Dict[str, Any]]] = field(default_factory=Dict)
language: str = 'python' language: str = 'python'
openapi_doc_version: str = '0.0.3' openapi_doc_version: str = '0.0.3'
sdk_version: str = '0.5.0' sdk_version: str = '0.6.0'
gen_version: str = '2.292.0' gen_version: str = '2.298.0'
user_agent: str = 'speakeasy-sdk/python 0.5.0 2.292.0 0.0.3 plex-api-client' user_agent: str = 'speakeasy-sdk/python 0.6.0 2.298.0 0.0.3 plex-api-client'
retry_config: RetryConfig = None retry_config: Optional[RetryConfig] = None
_hooks: SDKHooks = None _hooks: Optional[SDKHooks] = None
def get_server_details(self) -> Tuple[str, Dict[str, str]]: def get_server_details(self) -> Tuple[str, Dict[str, str]]:
if self.server_url: if self.server_url is not None and self.server_url != '':
return utils.remove_suffix(self.server_url, '/'), {} return utils.remove_suffix(self.server_url, '/'), {}
if self.server_idx is None: if self.server_idx is None:
self.server_idx = 0 self.server_idx = 0

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -53,34 +53,33 @@ class Search:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.PerformSearchResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.PerformSearchResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.PerformSearchResponseBody) out = utils.unmarshal_json(http_res.text, errors.PerformSearchResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -123,34 +122,33 @@ class Search:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.PerformVoiceSearchResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.PerformVoiceSearchResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.PerformVoiceSearchResponseBody) out = utils.unmarshal_json(http_res.text, errors.PerformVoiceSearchResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -188,30 +186,29 @@ class Search:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetSearchResultsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetSearchResultsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetSearchResultsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetSearchResultsResponseBody])
res.object = out res.object = out
else: else:
@@ -220,7 +217,7 @@ class Search:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetSearchResultsResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetSearchResultsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -35,30 +35,29 @@ class Server:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetServerCapabilitiesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetServerCapabilitiesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerCapabilitiesResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerCapabilitiesResponseBody])
res.object = out res.object = out
else: else:
@@ -67,7 +66,7 @@ class Server:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetServerCapabilitiesResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetServerCapabilitiesResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -100,30 +99,29 @@ class Server:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetServerPreferencesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetServerPreferencesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerPreferencesResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerPreferencesResponseBody])
res.object = out res.object = out
else: else:
@@ -132,7 +130,7 @@ class Server:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetServerPreferencesResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetServerPreferencesResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -165,30 +163,29 @@ class Server:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetAvailableClientsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetAvailableClientsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetAvailableClientsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetAvailableClientsResponseBody])
res.object = out res.object = out
else: else:
@@ -197,7 +194,7 @@ class Server:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetAvailableClientsResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetAvailableClientsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -230,30 +227,29 @@ class Server:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetDevicesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetDevicesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetDevicesResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetDevicesResponseBody])
res.object = out res.object = out
else: else:
@@ -262,7 +258,7 @@ class Server:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetDevicesResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetDevicesResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -295,30 +291,29 @@ class Server:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetServerIdentityResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetServerIdentityResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerIdentityResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerIdentityResponseBody])
res.object = out res.object = out
else: else:
@@ -327,7 +322,7 @@ class Server:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetServerIdentityResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetServerIdentityResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -360,30 +355,29 @@ class Server:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetMyPlexAccountResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetMyPlexAccountResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetMyPlexAccountResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetMyPlexAccountResponseBody])
res.object = out res.object = out
else: else:
@@ -392,7 +386,7 @@ class Server:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetMyPlexAccountResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetMyPlexAccountResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -426,34 +420,33 @@ class Server:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetResizedPhotoResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetResizedPhotoResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetResizedPhotoResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetResizedPhotoResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -486,30 +479,29 @@ class Server:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetServerListResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetServerListResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerListResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerListResponseBody])
res.object = out res.object = out
else: else:
@@ -518,7 +510,7 @@ class Server:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetServerListResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetServerListResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -35,30 +35,29 @@ class Sessions:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetSessionsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetSessionsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetSessionsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetSessionsResponseBody])
res.object = out res.object = out
else: else:
@@ -67,7 +66,7 @@ class Sessions:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetSessionsResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetSessionsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -100,30 +99,29 @@ class Sessions:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetSessionHistoryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetSessionHistoryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetSessionHistoryResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetSessionHistoryResponseBody])
res.object = out res.object = out
else: else:
@@ -132,7 +130,7 @@ class Sessions:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetSessionHistoryResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetSessionHistoryResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -165,30 +163,29 @@ class Sessions:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetTranscodeSessionsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetTranscodeSessionsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetTranscodeSessionsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetTranscodeSessionsResponseBody])
res.object = out res.object = out
else: else:
@@ -197,7 +194,7 @@ class Sessions:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetTranscodeSessionsResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetTranscodeSessionsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -234,34 +231,33 @@ class Sessions:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('DELETE', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.StopTranscodeSessionResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.StopTranscodeSessionResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 204: if http_res.status_code == 204:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.StopTranscodeSessionResponseBody) out = utils.unmarshal_json(http_res.text, errors.StopTranscodeSessionResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -40,30 +40,29 @@ class Statistics:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetStatisticsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetStatisticsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetStatisticsResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetStatisticsResponseBody])
res.object = out res.object = out
else: else:
@@ -72,7 +71,7 @@ class Statistics:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetStatisticsResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetStatisticsResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
from typing import Optional from typing import Optional
@@ -37,30 +37,29 @@ class Updater:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetUpdateStatusResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetUpdateStatusResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, Optional[operations.GetUpdateStatusResponseBody]) out = utils.unmarshal_json(http_res.text, Optional[operations.GetUpdateStatusResponseBody])
res.object = out res.object = out
else: else:
@@ -69,7 +68,7 @@ class Updater:
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetUpdateStatusResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetUpdateStatusResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -107,34 +106,33 @@ class Updater:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('PUT', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('PUT', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.CheckForUpdatesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.CheckForUpdatesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.CheckForUpdatesResponseBody) out = utils.unmarshal_json(http_res.text, errors.CheckForUpdatesResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -173,34 +171,33 @@ class Updater:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('PUT', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('PUT', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','500','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','500','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.ApplyUpdatesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.ApplyUpdatesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code == 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code == 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.ApplyUpdatesResponseBody) out = utils.unmarshal_json(http_res.text, errors.ApplyUpdatesResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out

View File

@@ -75,12 +75,12 @@ def retry(func, retries: Retries):
if res.status_code == parsed_code: if res.status_code == parsed_code:
raise TemporaryError(res) raise TemporaryError(res)
except requests.exceptions.ConnectionError as exception: except requests.exceptions.ConnectionError as exception:
if retries.config.config.retry_connection_errors: if retries.config.retry_connection_errors:
raise raise
raise PermanentError(exception) from exception raise PermanentError(exception) from exception
except requests.exceptions.Timeout as exception: except requests.exceptions.Timeout as exception:
if retries.config.config.retry_connection_errors: if retries.config.retry_connection_errors:
raise raise
raise PermanentError(exception) from exception raise PermanentError(exception) from exception

View File

@@ -3,7 +3,7 @@
import requests as requests_http import requests as requests_http
from .sdkconfiguration import SDKConfiguration from .sdkconfiguration import SDKConfiguration
from plex_api import utils from plex_api import utils
from plex_api._hooks import HookContext from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
from plex_api.models import errors, operations from plex_api.models import errors, operations
class Video: class Video:
@@ -35,34 +35,33 @@ class Video:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.GetTimelineResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.GetTimelineResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.GetTimelineResponseBody) out = utils.unmarshal_json(http_res.text, errors.GetTimelineResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out
@@ -96,34 +95,33 @@ class Video:
client = self.sdk_configuration.client client = self.sdk_configuration.client
try: try:
req = self.sdk_configuration.get_hooks().before_request( req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
hook_ctx, req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req) http_res = client.send(req)
except Exception as e: except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e) _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
raise e if e is not None:
raise e
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code): if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None) result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
if e: if e is not None:
raise e raise e
if result is not None:
http_res = result
else: else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res) http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
if isinstance(result, Exception):
raise result
http_res = result
res = operations.StartUniversalTranscodeResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type'), raw_response=http_res) res = operations.StartUniversalTranscodeResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
if http_res.status_code == 200: if http_res.status_code == 200:
pass pass
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
elif http_res.status_code == 401: elif http_res.status_code == 401:
if utils.match_content_type(http_res.headers.get('Content-Type'), 'application/json'): if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
out = utils.unmarshal_json(http_res.text, errors.StartUniversalTranscodeResponseBody) out = utils.unmarshal_json(http_res.text, errors.StartUniversalTranscodeResponseBody)
out.raw_response = http_res out.raw_response = http_res
raise out raise out