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.
Files changed (154) hide show
  1. plex_api/__init__.py +4 -0
  2. plex_api/_hooks/__init__.py +5 -0
  3. plex_api/_hooks/registration.py +13 -0
  4. plex_api/_hooks/sdkhooks.py +57 -0
  5. plex_api/_hooks/types.py +74 -0
  6. plex_api/activities.py +151 -0
  7. plex_api/authentication.py +146 -0
  8. plex_api/butler.py +333 -0
  9. plex_api/hubs.py +158 -0
  10. plex_api/library.py +808 -0
  11. plex_api/log.py +225 -0
  12. plex_api/media.py +210 -0
  13. plex_api/models/__init__.py +4 -0
  14. plex_api/models/components/__init__.py +5 -0
  15. plex_api/models/components/security.py +11 -0
  16. plex_api/models/errors/__init__.py +63 -0
  17. plex_api/models/errors/addplaylistcontents.py +32 -0
  18. plex_api/models/errors/applyupdates.py +32 -0
  19. plex_api/models/errors/cancelserveractivities.py +32 -0
  20. plex_api/models/errors/checkforupdates.py +32 -0
  21. plex_api/models/errors/clearplaylistcontents.py +32 -0
  22. plex_api/models/errors/createplaylist.py +32 -0
  23. plex_api/models/errors/deletelibrary.py +32 -0
  24. plex_api/models/errors/deleteplaylist.py +32 -0
  25. plex_api/models/errors/enablepapertrail.py +32 -0
  26. plex_api/models/errors/getavailableclients.py +32 -0
  27. plex_api/models/errors/getbutlertasks.py +32 -0
  28. plex_api/models/errors/getdevices.py +32 -0
  29. plex_api/models/errors/getfilehash.py +32 -0
  30. plex_api/models/errors/getglobalhubs.py +32 -0
  31. plex_api/models/errors/getlibraries.py +32 -0
  32. plex_api/models/errors/getlibrary.py +32 -0
  33. plex_api/models/errors/getlibraryhubs.py +32 -0
  34. plex_api/models/errors/getmetadata.py +32 -0
  35. plex_api/models/errors/getmetadatachildren.py +32 -0
  36. plex_api/models/errors/getmyplexaccount.py +32 -0
  37. plex_api/models/errors/getondeck.py +32 -0
  38. plex_api/models/errors/getpin.py +32 -0
  39. plex_api/models/errors/getplaylist.py +32 -0
  40. plex_api/models/errors/getplaylistcontents.py +32 -0
  41. plex_api/models/errors/getplaylists.py +32 -0
  42. plex_api/models/errors/getrecentlyadded.py +32 -0
  43. plex_api/models/errors/getresizedphoto.py +32 -0
  44. plex_api/models/errors/getsearchresults.py +32 -0
  45. plex_api/models/errors/getserveractivities.py +32 -0
  46. plex_api/models/errors/getservercapabilities.py +32 -0
  47. plex_api/models/errors/getserveridentity.py +32 -0
  48. plex_api/models/errors/getserverlist.py +32 -0
  49. plex_api/models/errors/getserverpreferences.py +32 -0
  50. plex_api/models/errors/getsessionhistory.py +32 -0
  51. plex_api/models/errors/getsessions.py +32 -0
  52. plex_api/models/errors/getsourceconnectioninformation.py +32 -0
  53. plex_api/models/errors/getstatistics.py +32 -0
  54. plex_api/models/errors/gettimeline.py +32 -0
  55. plex_api/models/errors/gettoken.py +32 -0
  56. plex_api/models/errors/gettranscodesessions.py +32 -0
  57. plex_api/models/errors/gettransienttoken.py +32 -0
  58. plex_api/models/errors/getupdatestatus.py +32 -0
  59. plex_api/models/errors/logline.py +32 -0
  60. plex_api/models/errors/logmultiline.py +32 -0
  61. plex_api/models/errors/markplayed.py +32 -0
  62. plex_api/models/errors/markunplayed.py +32 -0
  63. plex_api/models/errors/performsearch.py +32 -0
  64. plex_api/models/errors/performvoicesearch.py +32 -0
  65. plex_api/models/errors/refreshlibrary.py +32 -0
  66. plex_api/models/errors/sdkerror.py +24 -0
  67. plex_api/models/errors/startalltasks.py +32 -0
  68. plex_api/models/errors/starttask.py +32 -0
  69. plex_api/models/errors/startuniversaltranscode.py +32 -0
  70. plex_api/models/errors/stopalltasks.py +32 -0
  71. plex_api/models/errors/stoptask.py +32 -0
  72. plex_api/models/errors/stoptranscodesession.py +32 -0
  73. plex_api/models/errors/updateplaylist.py +32 -0
  74. plex_api/models/errors/updateplayprogress.py +32 -0
  75. plex_api/models/errors/uploadplaylist.py +32 -0
  76. plex_api/models/operations/__init__.py +64 -0
  77. plex_api/models/operations/addplaylistcontents.py +74 -0
  78. plex_api/models/operations/applyupdates.py +39 -0
  79. plex_api/models/operations/cancelserveractivities.py +25 -0
  80. plex_api/models/operations/checkforupdates.py +32 -0
  81. plex_api/models/operations/clearplaylistcontents.py +25 -0
  82. plex_api/models/operations/createplaylist.py +91 -0
  83. plex_api/models/operations/deletelibrary.py +25 -0
  84. plex_api/models/operations/deleteplaylist.py +25 -0
  85. plex_api/models/operations/enablepapertrail.py +17 -0
  86. plex_api/models/operations/getavailableclients.py +58 -0
  87. plex_api/models/operations/getbutlertasks.py +52 -0
  88. plex_api/models/operations/getdevices.py +53 -0
  89. plex_api/models/operations/getfilehash.py +28 -0
  90. plex_api/models/operations/getglobalhubs.py +100 -0
  91. plex_api/models/operations/getlibraries.py +79 -0
  92. plex_api/models/operations/getlibrary.py +153 -0
  93. plex_api/models/operations/getlibraryhubs.py +205 -0
  94. plex_api/models/operations/getlibraryitems.py +227 -0
  95. plex_api/models/operations/getmetadata.py +264 -0
  96. plex_api/models/operations/getmetadatachildren.py +115 -0
  97. plex_api/models/operations/getmyplexaccount.py +50 -0
  98. plex_api/models/operations/getondeck.py +166 -0
  99. plex_api/models/operations/getpin.py +86 -0
  100. plex_api/models/operations/getplaylist.py +70 -0
  101. plex_api/models/operations/getplaylistcontents.py +178 -0
  102. plex_api/models/operations/getplaylists.py +85 -0
  103. plex_api/models/operations/getrecentlyadded.py +166 -0
  104. plex_api/models/operations/getresizedphoto.py +48 -0
  105. plex_api/models/operations/getsearchresults.py +182 -0
  106. plex_api/models/operations/getserveractivities.py +63 -0
  107. plex_api/models/operations/getservercapabilities.py +99 -0
  108. plex_api/models/operations/getserveridentity.py +42 -0
  109. plex_api/models/operations/getserverlist.py +53 -0
  110. plex_api/models/operations/getserverpreferences.py +57 -0
  111. plex_api/models/operations/getsessionhistory.py +67 -0
  112. plex_api/models/operations/getsessions.py +185 -0
  113. plex_api/models/operations/getsourceconnectioninformation.py +25 -0
  114. plex_api/models/operations/getstatistics.py +93 -0
  115. plex_api/models/operations/gettimeline.py +50 -0
  116. plex_api/models/operations/gettoken.py +35 -0
  117. plex_api/models/operations/gettranscodesessions.py +71 -0
  118. plex_api/models/operations/gettransienttoken.py +36 -0
  119. plex_api/models/operations/getupdatestatus.py +57 -0
  120. plex_api/models/operations/logline.py +50 -0
  121. plex_api/models/operations/logmultiline.py +17 -0
  122. plex_api/models/operations/markplayed.py +25 -0
  123. plex_api/models/operations/markunplayed.py +25 -0
  124. plex_api/models/operations/performsearch.py +30 -0
  125. plex_api/models/operations/performvoicesearch.py +30 -0
  126. plex_api/models/operations/refreshlibrary.py +25 -0
  127. plex_api/models/operations/searchlibrary.py +96 -0
  128. plex_api/models/operations/startalltasks.py +17 -0
  129. plex_api/models/operations/starttask.py +43 -0
  130. plex_api/models/operations/startuniversaltranscode.py +56 -0
  131. plex_api/models/operations/stopalltasks.py +17 -0
  132. plex_api/models/operations/stoptask.py +43 -0
  133. plex_api/models/operations/stoptranscodesession.py +25 -0
  134. plex_api/models/operations/updateplaylist.py +30 -0
  135. plex_api/models/operations/updateplayprogress.py +29 -0
  136. plex_api/models/operations/uploadplaylist.py +47 -0
  137. plex_api/playlists.py +629 -0
  138. plex_api/plex.py +154 -0
  139. plex_api/sdk.py +180 -0
  140. plex_api/sdkconfiguration.py +52 -0
  141. plex_api/search.py +232 -0
  142. plex_api/server.py +525 -0
  143. plex_api/sessions.py +272 -0
  144. plex_api/statistics.py +86 -0
  145. plex_api/updater.py +212 -0
  146. plex_api/utils/__init__.py +4 -0
  147. plex_api/utils/retries.py +120 -0
  148. plex_api/utils/utils.py +898 -0
  149. plex_api/video.py +136 -0
  150. plex_api_client-0.6.1.dist-info/LICENSE.md +21 -0
  151. plex_api_client-0.6.1.dist-info/METADATA +397 -0
  152. plex_api_client-0.6.1.dist-info/RECORD +154 -0
  153. plex_api_client-0.6.1.dist-info/WHEEL +5 -0
  154. 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
+