plex-api-client 0.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plex_api/__init__.py +4 -0
- plex_api/_hooks/__init__.py +5 -0
- plex_api/_hooks/registration.py +13 -0
- plex_api/_hooks/sdkhooks.py +57 -0
- plex_api/_hooks/types.py +74 -0
- plex_api/activities.py +151 -0
- plex_api/authentication.py +146 -0
- plex_api/butler.py +333 -0
- plex_api/hubs.py +158 -0
- plex_api/library.py +808 -0
- plex_api/log.py +225 -0
- plex_api/media.py +210 -0
- plex_api/models/__init__.py +4 -0
- plex_api/models/components/__init__.py +5 -0
- plex_api/models/components/security.py +11 -0
- plex_api/models/errors/__init__.py +63 -0
- plex_api/models/errors/addplaylistcontents.py +32 -0
- plex_api/models/errors/applyupdates.py +32 -0
- plex_api/models/errors/cancelserveractivities.py +32 -0
- plex_api/models/errors/checkforupdates.py +32 -0
- plex_api/models/errors/clearplaylistcontents.py +32 -0
- plex_api/models/errors/createplaylist.py +32 -0
- plex_api/models/errors/deletelibrary.py +32 -0
- plex_api/models/errors/deleteplaylist.py +32 -0
- plex_api/models/errors/enablepapertrail.py +32 -0
- plex_api/models/errors/getavailableclients.py +32 -0
- plex_api/models/errors/getbutlertasks.py +32 -0
- plex_api/models/errors/getdevices.py +32 -0
- plex_api/models/errors/getfilehash.py +32 -0
- plex_api/models/errors/getglobalhubs.py +32 -0
- plex_api/models/errors/getlibraries.py +32 -0
- plex_api/models/errors/getlibrary.py +32 -0
- plex_api/models/errors/getlibraryhubs.py +32 -0
- plex_api/models/errors/getmetadata.py +32 -0
- plex_api/models/errors/getmetadatachildren.py +32 -0
- plex_api/models/errors/getmyplexaccount.py +32 -0
- plex_api/models/errors/getondeck.py +32 -0
- plex_api/models/errors/getpin.py +32 -0
- plex_api/models/errors/getplaylist.py +32 -0
- plex_api/models/errors/getplaylistcontents.py +32 -0
- plex_api/models/errors/getplaylists.py +32 -0
- plex_api/models/errors/getrecentlyadded.py +32 -0
- plex_api/models/errors/getresizedphoto.py +32 -0
- plex_api/models/errors/getsearchresults.py +32 -0
- plex_api/models/errors/getserveractivities.py +32 -0
- plex_api/models/errors/getservercapabilities.py +32 -0
- plex_api/models/errors/getserveridentity.py +32 -0
- plex_api/models/errors/getserverlist.py +32 -0
- plex_api/models/errors/getserverpreferences.py +32 -0
- plex_api/models/errors/getsessionhistory.py +32 -0
- plex_api/models/errors/getsessions.py +32 -0
- plex_api/models/errors/getsourceconnectioninformation.py +32 -0
- plex_api/models/errors/getstatistics.py +32 -0
- plex_api/models/errors/gettimeline.py +32 -0
- plex_api/models/errors/gettoken.py +32 -0
- plex_api/models/errors/gettranscodesessions.py +32 -0
- plex_api/models/errors/gettransienttoken.py +32 -0
- plex_api/models/errors/getupdatestatus.py +32 -0
- plex_api/models/errors/logline.py +32 -0
- plex_api/models/errors/logmultiline.py +32 -0
- plex_api/models/errors/markplayed.py +32 -0
- plex_api/models/errors/markunplayed.py +32 -0
- plex_api/models/errors/performsearch.py +32 -0
- plex_api/models/errors/performvoicesearch.py +32 -0
- plex_api/models/errors/refreshlibrary.py +32 -0
- plex_api/models/errors/sdkerror.py +24 -0
- plex_api/models/errors/startalltasks.py +32 -0
- plex_api/models/errors/starttask.py +32 -0
- plex_api/models/errors/startuniversaltranscode.py +32 -0
- plex_api/models/errors/stopalltasks.py +32 -0
- plex_api/models/errors/stoptask.py +32 -0
- plex_api/models/errors/stoptranscodesession.py +32 -0
- plex_api/models/errors/updateplaylist.py +32 -0
- plex_api/models/errors/updateplayprogress.py +32 -0
- plex_api/models/errors/uploadplaylist.py +32 -0
- plex_api/models/operations/__init__.py +64 -0
- plex_api/models/operations/addplaylistcontents.py +74 -0
- plex_api/models/operations/applyupdates.py +39 -0
- plex_api/models/operations/cancelserveractivities.py +25 -0
- plex_api/models/operations/checkforupdates.py +32 -0
- plex_api/models/operations/clearplaylistcontents.py +25 -0
- plex_api/models/operations/createplaylist.py +91 -0
- plex_api/models/operations/deletelibrary.py +25 -0
- plex_api/models/operations/deleteplaylist.py +25 -0
- plex_api/models/operations/enablepapertrail.py +17 -0
- plex_api/models/operations/getavailableclients.py +58 -0
- plex_api/models/operations/getbutlertasks.py +52 -0
- plex_api/models/operations/getdevices.py +53 -0
- plex_api/models/operations/getfilehash.py +28 -0
- plex_api/models/operations/getglobalhubs.py +100 -0
- plex_api/models/operations/getlibraries.py +79 -0
- plex_api/models/operations/getlibrary.py +153 -0
- plex_api/models/operations/getlibraryhubs.py +205 -0
- plex_api/models/operations/getlibraryitems.py +227 -0
- plex_api/models/operations/getmetadata.py +264 -0
- plex_api/models/operations/getmetadatachildren.py +115 -0
- plex_api/models/operations/getmyplexaccount.py +50 -0
- plex_api/models/operations/getondeck.py +166 -0
- plex_api/models/operations/getpin.py +86 -0
- plex_api/models/operations/getplaylist.py +70 -0
- plex_api/models/operations/getplaylistcontents.py +178 -0
- plex_api/models/operations/getplaylists.py +85 -0
- plex_api/models/operations/getrecentlyadded.py +166 -0
- plex_api/models/operations/getresizedphoto.py +48 -0
- plex_api/models/operations/getsearchresults.py +182 -0
- plex_api/models/operations/getserveractivities.py +63 -0
- plex_api/models/operations/getservercapabilities.py +99 -0
- plex_api/models/operations/getserveridentity.py +42 -0
- plex_api/models/operations/getserverlist.py +53 -0
- plex_api/models/operations/getserverpreferences.py +57 -0
- plex_api/models/operations/getsessionhistory.py +67 -0
- plex_api/models/operations/getsessions.py +185 -0
- plex_api/models/operations/getsourceconnectioninformation.py +25 -0
- plex_api/models/operations/getstatistics.py +93 -0
- plex_api/models/operations/gettimeline.py +50 -0
- plex_api/models/operations/gettoken.py +35 -0
- plex_api/models/operations/gettranscodesessions.py +71 -0
- plex_api/models/operations/gettransienttoken.py +36 -0
- plex_api/models/operations/getupdatestatus.py +57 -0
- plex_api/models/operations/logline.py +50 -0
- plex_api/models/operations/logmultiline.py +17 -0
- plex_api/models/operations/markplayed.py +25 -0
- plex_api/models/operations/markunplayed.py +25 -0
- plex_api/models/operations/performsearch.py +30 -0
- plex_api/models/operations/performvoicesearch.py +30 -0
- plex_api/models/operations/refreshlibrary.py +25 -0
- plex_api/models/operations/searchlibrary.py +96 -0
- plex_api/models/operations/startalltasks.py +17 -0
- plex_api/models/operations/starttask.py +43 -0
- plex_api/models/operations/startuniversaltranscode.py +56 -0
- plex_api/models/operations/stopalltasks.py +17 -0
- plex_api/models/operations/stoptask.py +43 -0
- plex_api/models/operations/stoptranscodesession.py +25 -0
- plex_api/models/operations/updateplaylist.py +30 -0
- plex_api/models/operations/updateplayprogress.py +29 -0
- plex_api/models/operations/uploadplaylist.py +47 -0
- plex_api/playlists.py +629 -0
- plex_api/plex.py +154 -0
- plex_api/sdk.py +180 -0
- plex_api/sdkconfiguration.py +52 -0
- plex_api/search.py +232 -0
- plex_api/server.py +525 -0
- plex_api/sessions.py +272 -0
- plex_api/statistics.py +86 -0
- plex_api/updater.py +212 -0
- plex_api/utils/__init__.py +4 -0
- plex_api/utils/retries.py +120 -0
- plex_api/utils/utils.py +898 -0
- plex_api/video.py +136 -0
- plex_api_client-0.6.1.dist-info/LICENSE.md +21 -0
- plex_api_client-0.6.1.dist-info/METADATA +397 -0
- plex_api_client-0.6.1.dist-info/RECORD +154 -0
- plex_api_client-0.6.1.dist-info/WHEEL +5 -0
- plex_api_client-0.6.1.dist-info/top_level.txt +1 -0
plex_api/server.py
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
import requests as requests_http
|
|
4
|
+
from .sdkconfiguration import SDKConfiguration
|
|
5
|
+
from plex_api import utils
|
|
6
|
+
from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
|
|
7
|
+
from plex_api.models import errors, operations
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
class Server:
|
|
11
|
+
r"""Operations against the Plex Media Server System."""
|
|
12
|
+
sdk_configuration: SDKConfiguration
|
|
13
|
+
|
|
14
|
+
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
|
15
|
+
self.sdk_configuration = sdk_config
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_server_capabilities(self) -> operations.GetServerCapabilitiesResponse:
|
|
20
|
+
r"""Server Capabilities
|
|
21
|
+
Server Capabilities
|
|
22
|
+
"""
|
|
23
|
+
hook_ctx = HookContext(operation_id='getServerCapabilities', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
24
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
25
|
+
|
|
26
|
+
url = base_url + '/'
|
|
27
|
+
|
|
28
|
+
if callable(self.sdk_configuration.security):
|
|
29
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
30
|
+
else:
|
|
31
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
32
|
+
|
|
33
|
+
headers['Accept'] = 'application/json'
|
|
34
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
35
|
+
client = self.sdk_configuration.client
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
39
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
40
|
+
http_res = client.send(req)
|
|
41
|
+
except Exception as e:
|
|
42
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
43
|
+
if e is not None:
|
|
44
|
+
raise e
|
|
45
|
+
|
|
46
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
47
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
48
|
+
if e is not None:
|
|
49
|
+
raise e
|
|
50
|
+
if result is not None:
|
|
51
|
+
http_res = result
|
|
52
|
+
else:
|
|
53
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
res = operations.GetServerCapabilitiesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
58
|
+
|
|
59
|
+
if http_res.status_code == 200:
|
|
60
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
61
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerCapabilitiesResponseBody])
|
|
62
|
+
res.object = out
|
|
63
|
+
else:
|
|
64
|
+
content_type = http_res.headers.get('Content-Type')
|
|
65
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
66
|
+
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:
|
|
67
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
68
|
+
elif http_res.status_code == 401:
|
|
69
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
70
|
+
out = utils.unmarshal_json(http_res.text, errors.GetServerCapabilitiesResponseBody)
|
|
71
|
+
out.raw_response = http_res
|
|
72
|
+
raise out
|
|
73
|
+
else:
|
|
74
|
+
content_type = http_res.headers.get('Content-Type')
|
|
75
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
76
|
+
else:
|
|
77
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
78
|
+
|
|
79
|
+
return res
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def get_server_preferences(self) -> operations.GetServerPreferencesResponse:
|
|
84
|
+
r"""Get Server Preferences
|
|
85
|
+
Get Server Preferences
|
|
86
|
+
"""
|
|
87
|
+
hook_ctx = HookContext(operation_id='getServerPreferences', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
88
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
89
|
+
|
|
90
|
+
url = base_url + '/:/prefs'
|
|
91
|
+
|
|
92
|
+
if callable(self.sdk_configuration.security):
|
|
93
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
94
|
+
else:
|
|
95
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
96
|
+
|
|
97
|
+
headers['Accept'] = 'application/json'
|
|
98
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
99
|
+
client = self.sdk_configuration.client
|
|
100
|
+
|
|
101
|
+
try:
|
|
102
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
103
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
104
|
+
http_res = client.send(req)
|
|
105
|
+
except Exception as e:
|
|
106
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
107
|
+
if e is not None:
|
|
108
|
+
raise e
|
|
109
|
+
|
|
110
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
111
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
112
|
+
if e is not None:
|
|
113
|
+
raise e
|
|
114
|
+
if result is not None:
|
|
115
|
+
http_res = result
|
|
116
|
+
else:
|
|
117
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
res = operations.GetServerPreferencesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
122
|
+
|
|
123
|
+
if http_res.status_code == 200:
|
|
124
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
125
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerPreferencesResponseBody])
|
|
126
|
+
res.object = out
|
|
127
|
+
else:
|
|
128
|
+
content_type = http_res.headers.get('Content-Type')
|
|
129
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
130
|
+
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:
|
|
131
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
132
|
+
elif http_res.status_code == 401:
|
|
133
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
134
|
+
out = utils.unmarshal_json(http_res.text, errors.GetServerPreferencesResponseBody)
|
|
135
|
+
out.raw_response = http_res
|
|
136
|
+
raise out
|
|
137
|
+
else:
|
|
138
|
+
content_type = http_res.headers.get('Content-Type')
|
|
139
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
140
|
+
else:
|
|
141
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
142
|
+
|
|
143
|
+
return res
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def get_available_clients(self) -> operations.GetAvailableClientsResponse:
|
|
148
|
+
r"""Get Available Clients
|
|
149
|
+
Get Available Clients
|
|
150
|
+
"""
|
|
151
|
+
hook_ctx = HookContext(operation_id='getAvailableClients', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
152
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
153
|
+
|
|
154
|
+
url = base_url + '/clients'
|
|
155
|
+
|
|
156
|
+
if callable(self.sdk_configuration.security):
|
|
157
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
158
|
+
else:
|
|
159
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
160
|
+
|
|
161
|
+
headers['Accept'] = 'application/json'
|
|
162
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
163
|
+
client = self.sdk_configuration.client
|
|
164
|
+
|
|
165
|
+
try:
|
|
166
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
167
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
168
|
+
http_res = client.send(req)
|
|
169
|
+
except Exception as e:
|
|
170
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
171
|
+
if e is not None:
|
|
172
|
+
raise e
|
|
173
|
+
|
|
174
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
175
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
176
|
+
if e is not None:
|
|
177
|
+
raise e
|
|
178
|
+
if result is not None:
|
|
179
|
+
http_res = result
|
|
180
|
+
else:
|
|
181
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
res = operations.GetAvailableClientsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
186
|
+
|
|
187
|
+
if http_res.status_code == 200:
|
|
188
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
189
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetAvailableClientsResponseBody])
|
|
190
|
+
res.object = out
|
|
191
|
+
else:
|
|
192
|
+
content_type = http_res.headers.get('Content-Type')
|
|
193
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
194
|
+
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:
|
|
195
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
196
|
+
elif http_res.status_code == 401:
|
|
197
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
198
|
+
out = utils.unmarshal_json(http_res.text, errors.GetAvailableClientsResponseBody)
|
|
199
|
+
out.raw_response = http_res
|
|
200
|
+
raise out
|
|
201
|
+
else:
|
|
202
|
+
content_type = http_res.headers.get('Content-Type')
|
|
203
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
204
|
+
else:
|
|
205
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
206
|
+
|
|
207
|
+
return res
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def get_devices(self) -> operations.GetDevicesResponse:
|
|
212
|
+
r"""Get Devices
|
|
213
|
+
Get Devices
|
|
214
|
+
"""
|
|
215
|
+
hook_ctx = HookContext(operation_id='getDevices', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
216
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
217
|
+
|
|
218
|
+
url = base_url + '/devices'
|
|
219
|
+
|
|
220
|
+
if callable(self.sdk_configuration.security):
|
|
221
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
222
|
+
else:
|
|
223
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
224
|
+
|
|
225
|
+
headers['Accept'] = 'application/json'
|
|
226
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
227
|
+
client = self.sdk_configuration.client
|
|
228
|
+
|
|
229
|
+
try:
|
|
230
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
231
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
232
|
+
http_res = client.send(req)
|
|
233
|
+
except Exception as e:
|
|
234
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
235
|
+
if e is not None:
|
|
236
|
+
raise e
|
|
237
|
+
|
|
238
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
239
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
240
|
+
if e is not None:
|
|
241
|
+
raise e
|
|
242
|
+
if result is not None:
|
|
243
|
+
http_res = result
|
|
244
|
+
else:
|
|
245
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
res = operations.GetDevicesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
250
|
+
|
|
251
|
+
if http_res.status_code == 200:
|
|
252
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
253
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetDevicesResponseBody])
|
|
254
|
+
res.object = out
|
|
255
|
+
else:
|
|
256
|
+
content_type = http_res.headers.get('Content-Type')
|
|
257
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
258
|
+
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:
|
|
259
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
260
|
+
elif http_res.status_code == 401:
|
|
261
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
262
|
+
out = utils.unmarshal_json(http_res.text, errors.GetDevicesResponseBody)
|
|
263
|
+
out.raw_response = http_res
|
|
264
|
+
raise out
|
|
265
|
+
else:
|
|
266
|
+
content_type = http_res.headers.get('Content-Type')
|
|
267
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
268
|
+
else:
|
|
269
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
270
|
+
|
|
271
|
+
return res
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def get_server_identity(self) -> operations.GetServerIdentityResponse:
|
|
276
|
+
r"""Get Server Identity
|
|
277
|
+
Get Server Identity
|
|
278
|
+
"""
|
|
279
|
+
hook_ctx = HookContext(operation_id='getServerIdentity', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
280
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
281
|
+
|
|
282
|
+
url = base_url + '/identity'
|
|
283
|
+
|
|
284
|
+
if callable(self.sdk_configuration.security):
|
|
285
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
286
|
+
else:
|
|
287
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
288
|
+
|
|
289
|
+
headers['Accept'] = 'application/json'
|
|
290
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
291
|
+
client = self.sdk_configuration.client
|
|
292
|
+
|
|
293
|
+
try:
|
|
294
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
295
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
296
|
+
http_res = client.send(req)
|
|
297
|
+
except Exception as e:
|
|
298
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
299
|
+
if e is not None:
|
|
300
|
+
raise e
|
|
301
|
+
|
|
302
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
303
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
304
|
+
if e is not None:
|
|
305
|
+
raise e
|
|
306
|
+
if result is not None:
|
|
307
|
+
http_res = result
|
|
308
|
+
else:
|
|
309
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
res = operations.GetServerIdentityResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
314
|
+
|
|
315
|
+
if http_res.status_code == 200:
|
|
316
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
317
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerIdentityResponseBody])
|
|
318
|
+
res.object = out
|
|
319
|
+
else:
|
|
320
|
+
content_type = http_res.headers.get('Content-Type')
|
|
321
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
322
|
+
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:
|
|
323
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
324
|
+
elif http_res.status_code == 401:
|
|
325
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
326
|
+
out = utils.unmarshal_json(http_res.text, errors.GetServerIdentityResponseBody)
|
|
327
|
+
out.raw_response = http_res
|
|
328
|
+
raise out
|
|
329
|
+
else:
|
|
330
|
+
content_type = http_res.headers.get('Content-Type')
|
|
331
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
332
|
+
else:
|
|
333
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
334
|
+
|
|
335
|
+
return res
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def get_my_plex_account(self) -> operations.GetMyPlexAccountResponse:
|
|
340
|
+
r"""Get MyPlex Account
|
|
341
|
+
Returns MyPlex Account Information
|
|
342
|
+
"""
|
|
343
|
+
hook_ctx = HookContext(operation_id='getMyPlexAccount', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
344
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
345
|
+
|
|
346
|
+
url = base_url + '/myplex/account'
|
|
347
|
+
|
|
348
|
+
if callable(self.sdk_configuration.security):
|
|
349
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
350
|
+
else:
|
|
351
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
352
|
+
|
|
353
|
+
headers['Accept'] = 'application/json'
|
|
354
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
355
|
+
client = self.sdk_configuration.client
|
|
356
|
+
|
|
357
|
+
try:
|
|
358
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
359
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
360
|
+
http_res = client.send(req)
|
|
361
|
+
except Exception as e:
|
|
362
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
363
|
+
if e is not None:
|
|
364
|
+
raise e
|
|
365
|
+
|
|
366
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
367
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
368
|
+
if e is not None:
|
|
369
|
+
raise e
|
|
370
|
+
if result is not None:
|
|
371
|
+
http_res = result
|
|
372
|
+
else:
|
|
373
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
res = operations.GetMyPlexAccountResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
378
|
+
|
|
379
|
+
if http_res.status_code == 200:
|
|
380
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
381
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetMyPlexAccountResponseBody])
|
|
382
|
+
res.object = out
|
|
383
|
+
else:
|
|
384
|
+
content_type = http_res.headers.get('Content-Type')
|
|
385
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
386
|
+
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:
|
|
387
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
388
|
+
elif http_res.status_code == 401:
|
|
389
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
390
|
+
out = utils.unmarshal_json(http_res.text, errors.GetMyPlexAccountResponseBody)
|
|
391
|
+
out.raw_response = http_res
|
|
392
|
+
raise out
|
|
393
|
+
else:
|
|
394
|
+
content_type = http_res.headers.get('Content-Type')
|
|
395
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
396
|
+
else:
|
|
397
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
398
|
+
|
|
399
|
+
return res
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def get_resized_photo(self, request: operations.GetResizedPhotoRequest) -> operations.GetResizedPhotoResponse:
|
|
404
|
+
r"""Get a Resized Photo
|
|
405
|
+
Plex's Photo transcoder is used throughout the service to serve images at specified sizes.
|
|
406
|
+
"""
|
|
407
|
+
hook_ctx = HookContext(operation_id='getResizedPhoto', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
408
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
409
|
+
|
|
410
|
+
url = base_url + '/photo/:/transcode'
|
|
411
|
+
|
|
412
|
+
if callable(self.sdk_configuration.security):
|
|
413
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
414
|
+
else:
|
|
415
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
416
|
+
|
|
417
|
+
query_params = { **utils.get_query_params(operations.GetResizedPhotoRequest, request, self.sdk_configuration.globals), **query_params }
|
|
418
|
+
headers['Accept'] = 'application/json'
|
|
419
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
420
|
+
client = self.sdk_configuration.client
|
|
421
|
+
|
|
422
|
+
try:
|
|
423
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
424
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
425
|
+
http_res = client.send(req)
|
|
426
|
+
except Exception as e:
|
|
427
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
428
|
+
if e is not None:
|
|
429
|
+
raise e
|
|
430
|
+
|
|
431
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
432
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
433
|
+
if e is not None:
|
|
434
|
+
raise e
|
|
435
|
+
if result is not None:
|
|
436
|
+
http_res = result
|
|
437
|
+
else:
|
|
438
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
res = operations.GetResizedPhotoResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
443
|
+
|
|
444
|
+
if http_res.status_code == 200:
|
|
445
|
+
pass
|
|
446
|
+
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:
|
|
447
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
448
|
+
elif http_res.status_code == 401:
|
|
449
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
450
|
+
out = utils.unmarshal_json(http_res.text, errors.GetResizedPhotoResponseBody)
|
|
451
|
+
out.raw_response = http_res
|
|
452
|
+
raise out
|
|
453
|
+
else:
|
|
454
|
+
content_type = http_res.headers.get('Content-Type')
|
|
455
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
456
|
+
else:
|
|
457
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
458
|
+
|
|
459
|
+
return res
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def get_server_list(self) -> operations.GetServerListResponse:
|
|
464
|
+
r"""Get Server List
|
|
465
|
+
Get Server List
|
|
466
|
+
"""
|
|
467
|
+
hook_ctx = HookContext(operation_id='getServerList', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
468
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
469
|
+
|
|
470
|
+
url = base_url + '/servers'
|
|
471
|
+
|
|
472
|
+
if callable(self.sdk_configuration.security):
|
|
473
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
474
|
+
else:
|
|
475
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
476
|
+
|
|
477
|
+
headers['Accept'] = 'application/json'
|
|
478
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
479
|
+
client = self.sdk_configuration.client
|
|
480
|
+
|
|
481
|
+
try:
|
|
482
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
483
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
484
|
+
http_res = client.send(req)
|
|
485
|
+
except Exception as e:
|
|
486
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
487
|
+
if e is not None:
|
|
488
|
+
raise e
|
|
489
|
+
|
|
490
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
491
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
492
|
+
if e is not None:
|
|
493
|
+
raise e
|
|
494
|
+
if result is not None:
|
|
495
|
+
http_res = result
|
|
496
|
+
else:
|
|
497
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
res = operations.GetServerListResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
502
|
+
|
|
503
|
+
if http_res.status_code == 200:
|
|
504
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
505
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetServerListResponseBody])
|
|
506
|
+
res.object = out
|
|
507
|
+
else:
|
|
508
|
+
content_type = http_res.headers.get('Content-Type')
|
|
509
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
510
|
+
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:
|
|
511
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
512
|
+
elif http_res.status_code == 401:
|
|
513
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
514
|
+
out = utils.unmarshal_json(http_res.text, errors.GetServerListResponseBody)
|
|
515
|
+
out.raw_response = http_res
|
|
516
|
+
raise out
|
|
517
|
+
else:
|
|
518
|
+
content_type = http_res.headers.get('Content-Type')
|
|
519
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
520
|
+
else:
|
|
521
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
522
|
+
|
|
523
|
+
return res
|
|
524
|
+
|
|
525
|
+
|