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/butler.py ADDED
@@ -0,0 +1,333 @@
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 Butler:
11
+ r"""Butler is the task manager of the Plex Media Server Ecosystem."""
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_butler_tasks(self) -> operations.GetButlerTasksResponse:
20
+ r"""Get Butler tasks
21
+ Returns a list of butler tasks
22
+ """
23
+ hook_ctx = HookContext(operation_id='getButlerTasks', 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 + '/butler'
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.GetButlerTasksResponse(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.GetButlerTasksResponseBody])
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.GetButlerTasksResponseBody)
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 start_all_tasks(self) -> operations.StartAllTasksResponse:
84
+ r"""Start all Butler tasks
85
+ This endpoint will attempt to start all Butler tasks that are enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
86
+ 1. Any tasks not scheduled to run on the current day will be skipped.
87
+ 2. If a task is configured to run at a random time during the configured window and we are outside that window, the task will start immediately.
88
+ 3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
89
+ 4. If we are outside the configured window, the task will start immediately.
90
+ """
91
+ hook_ctx = HookContext(operation_id='startAllTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
92
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
93
+
94
+ url = base_url + '/butler'
95
+
96
+ if callable(self.sdk_configuration.security):
97
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
98
+ else:
99
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
100
+
101
+ headers['Accept'] = 'application/json'
102
+ headers['user-agent'] = self.sdk_configuration.user_agent
103
+ client = self.sdk_configuration.client
104
+
105
+ try:
106
+ req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
107
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
108
+ http_res = client.send(req)
109
+ except Exception as e:
110
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
111
+ if e is not None:
112
+ raise e
113
+
114
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
115
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
116
+ if e is not None:
117
+ raise e
118
+ if result is not None:
119
+ http_res = result
120
+ else:
121
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
122
+
123
+
124
+
125
+ res = operations.StartAllTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
126
+
127
+ if http_res.status_code == 200:
128
+ pass
129
+ 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:
130
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
131
+ elif http_res.status_code == 401:
132
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
133
+ out = utils.unmarshal_json(http_res.text, errors.StartAllTasksResponseBody)
134
+ out.raw_response = http_res
135
+ raise out
136
+ else:
137
+ content_type = http_res.headers.get('Content-Type')
138
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
139
+ else:
140
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
141
+
142
+ return res
143
+
144
+
145
+
146
+ def stop_all_tasks(self) -> operations.StopAllTasksResponse:
147
+ r"""Stop all Butler tasks
148
+ This endpoint will stop all currently running tasks and remove any scheduled tasks from the queue.
149
+ """
150
+ hook_ctx = HookContext(operation_id='stopAllTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
151
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
152
+
153
+ url = base_url + '/butler'
154
+
155
+ if callable(self.sdk_configuration.security):
156
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
157
+ else:
158
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
159
+
160
+ headers['Accept'] = 'application/json'
161
+ headers['user-agent'] = self.sdk_configuration.user_agent
162
+ client = self.sdk_configuration.client
163
+
164
+ try:
165
+ req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
166
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
167
+ http_res = client.send(req)
168
+ except Exception as e:
169
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
170
+ if e is not None:
171
+ raise e
172
+
173
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
174
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
175
+ if e is not None:
176
+ raise e
177
+ if result is not None:
178
+ http_res = result
179
+ else:
180
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
181
+
182
+
183
+
184
+ res = operations.StopAllTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
185
+
186
+ if http_res.status_code == 200:
187
+ pass
188
+ 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:
189
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
190
+ elif http_res.status_code == 401:
191
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
192
+ out = utils.unmarshal_json(http_res.text, errors.StopAllTasksResponseBody)
193
+ out.raw_response = http_res
194
+ raise out
195
+ else:
196
+ content_type = http_res.headers.get('Content-Type')
197
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
198
+ else:
199
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
200
+
201
+ return res
202
+
203
+
204
+
205
+ def start_task(self, task_name: operations.TaskName) -> operations.StartTaskResponse:
206
+ r"""Start a single Butler task
207
+ This endpoint will attempt to start a single Butler task that is enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
208
+ 1. Any tasks not scheduled to run on the current day will be skipped.
209
+ 2. If a task is configured to run at a random time during the configured window and we are outside that window, the task will start immediately.
210
+ 3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
211
+ 4. If we are outside the configured window, the task will start immediately.
212
+ """
213
+ hook_ctx = HookContext(operation_id='startTask', oauth2_scopes=[], security_source=self.sdk_configuration.security)
214
+ request = operations.StartTaskRequest(
215
+ task_name=task_name,
216
+ )
217
+
218
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
219
+
220
+ url = utils.generate_url(operations.StartTaskRequest, base_url, '/butler/{taskName}', request, self.sdk_configuration.globals)
221
+
222
+ if callable(self.sdk_configuration.security):
223
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
224
+ else:
225
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
226
+
227
+ headers['Accept'] = 'application/json'
228
+ headers['user-agent'] = self.sdk_configuration.user_agent
229
+ client = self.sdk_configuration.client
230
+
231
+ try:
232
+ req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
233
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
234
+ http_res = client.send(req)
235
+ except Exception as e:
236
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
237
+ if e is not None:
238
+ raise e
239
+
240
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
241
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
242
+ if e is not None:
243
+ raise e
244
+ if result is not None:
245
+ http_res = result
246
+ else:
247
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
248
+
249
+
250
+
251
+ res = operations.StartTaskResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
252
+
253
+ if http_res.status_code in [200, 202]:
254
+ pass
255
+ 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:
256
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
257
+ elif http_res.status_code == 401:
258
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
259
+ out = utils.unmarshal_json(http_res.text, errors.StartTaskResponseBody)
260
+ out.raw_response = http_res
261
+ raise out
262
+ else:
263
+ content_type = http_res.headers.get('Content-Type')
264
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
265
+ else:
266
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
267
+
268
+ return res
269
+
270
+
271
+
272
+ def stop_task(self, task_name: operations.PathParamTaskName) -> operations.StopTaskResponse:
273
+ r"""Stop a single Butler task
274
+ This endpoint will stop a currently running task by name, or remove it from the list of scheduled tasks if it exists. See the section above for a list of task names for this endpoint.
275
+ """
276
+ hook_ctx = HookContext(operation_id='stopTask', oauth2_scopes=[], security_source=self.sdk_configuration.security)
277
+ request = operations.StopTaskRequest(
278
+ task_name=task_name,
279
+ )
280
+
281
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
282
+
283
+ url = utils.generate_url(operations.StopTaskRequest, base_url, '/butler/{taskName}', request, self.sdk_configuration.globals)
284
+
285
+ if callable(self.sdk_configuration.security):
286
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
287
+ else:
288
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
289
+
290
+ headers['Accept'] = 'application/json'
291
+ headers['user-agent'] = self.sdk_configuration.user_agent
292
+ client = self.sdk_configuration.client
293
+
294
+ try:
295
+ req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
296
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
297
+ http_res = client.send(req)
298
+ except Exception as e:
299
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
300
+ if e is not None:
301
+ raise e
302
+
303
+ if utils.match_status_codes(['400','401','404','4XX','5XX'], http_res.status_code):
304
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
305
+ if e is not None:
306
+ raise e
307
+ if result is not None:
308
+ http_res = result
309
+ else:
310
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
311
+
312
+
313
+
314
+ res = operations.StopTaskResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
315
+
316
+ if http_res.status_code == 200:
317
+ pass
318
+ 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:
319
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
320
+ elif http_res.status_code == 401:
321
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
322
+ out = utils.unmarshal_json(http_res.text, errors.StopTaskResponseBody)
323
+ out.raw_response = http_res
324
+ raise out
325
+ else:
326
+ content_type = http_res.headers.get('Content-Type')
327
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
328
+ else:
329
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
330
+
331
+ return res
332
+
333
+
plex_api/hubs.py ADDED
@@ -0,0 +1,158 @@
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 Hubs:
11
+ r"""Hubs are a structured two-dimensional container for media, generally represented by multiple horizontal rows."""
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_global_hubs(self, count: Optional[float] = None, only_transient: Optional[operations.OnlyTransient] = None) -> operations.GetGlobalHubsResponse:
20
+ r"""Get Global Hubs
21
+ Get Global Hubs filtered by the parameters provided.
22
+ """
23
+ hook_ctx = HookContext(operation_id='getGlobalHubs', oauth2_scopes=[], security_source=self.sdk_configuration.security)
24
+ request = operations.GetGlobalHubsRequest(
25
+ count=count,
26
+ only_transient=only_transient,
27
+ )
28
+
29
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
30
+
31
+ url = base_url + '/hubs'
32
+
33
+ if callable(self.sdk_configuration.security):
34
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
35
+ else:
36
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
37
+
38
+ query_params = { **utils.get_query_params(operations.GetGlobalHubsRequest, request, self.sdk_configuration.globals), **query_params }
39
+ headers['Accept'] = 'application/json'
40
+ headers['user-agent'] = self.sdk_configuration.user_agent
41
+ client = self.sdk_configuration.client
42
+
43
+ try:
44
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
45
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
46
+ http_res = client.send(req)
47
+ except Exception as e:
48
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
49
+ if e is not None:
50
+ raise e
51
+
52
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
53
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
54
+ if e is not None:
55
+ raise e
56
+ if result is not None:
57
+ http_res = result
58
+ else:
59
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
60
+
61
+
62
+
63
+ res = operations.GetGlobalHubsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
64
+
65
+ if http_res.status_code == 200:
66
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
67
+ out = utils.unmarshal_json(http_res.text, Optional[operations.GetGlobalHubsResponseBody])
68
+ res.object = out
69
+ else:
70
+ content_type = http_res.headers.get('Content-Type')
71
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
72
+ 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:
73
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
74
+ elif http_res.status_code == 401:
75
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
76
+ out = utils.unmarshal_json(http_res.text, errors.GetGlobalHubsResponseBody)
77
+ out.raw_response = http_res
78
+ raise out
79
+ else:
80
+ content_type = http_res.headers.get('Content-Type')
81
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
82
+ else:
83
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
84
+
85
+ return res
86
+
87
+
88
+
89
+ def get_library_hubs(self, section_id: float, count: Optional[float] = None, only_transient: Optional[operations.QueryParamOnlyTransient] = None) -> operations.GetLibraryHubsResponse:
90
+ r"""Get library specific hubs
91
+ This endpoint will return a list of library specific hubs
92
+ """
93
+ hook_ctx = HookContext(operation_id='getLibraryHubs', oauth2_scopes=[], security_source=self.sdk_configuration.security)
94
+ request = operations.GetLibraryHubsRequest(
95
+ section_id=section_id,
96
+ count=count,
97
+ only_transient=only_transient,
98
+ )
99
+
100
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
101
+
102
+ url = utils.generate_url(operations.GetLibraryHubsRequest, base_url, '/hubs/sections/{sectionId}', request, self.sdk_configuration.globals)
103
+
104
+ if callable(self.sdk_configuration.security):
105
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
106
+ else:
107
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
108
+
109
+ query_params = { **utils.get_query_params(operations.GetLibraryHubsRequest, request, self.sdk_configuration.globals), **query_params }
110
+ headers['Accept'] = 'application/json'
111
+ headers['user-agent'] = self.sdk_configuration.user_agent
112
+ client = self.sdk_configuration.client
113
+
114
+ try:
115
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
116
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
117
+ http_res = client.send(req)
118
+ except Exception as e:
119
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
120
+ if e is not None:
121
+ raise e
122
+
123
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
124
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
125
+ if e is not None:
126
+ raise e
127
+ if result is not None:
128
+ http_res = result
129
+ else:
130
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
131
+
132
+
133
+
134
+ res = operations.GetLibraryHubsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
135
+
136
+ if http_res.status_code == 200:
137
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
138
+ out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryHubsResponseBody])
139
+ res.object = out
140
+ else:
141
+ content_type = http_res.headers.get('Content-Type')
142
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
143
+ 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:
144
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
145
+ elif http_res.status_code == 401:
146
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
147
+ out = utils.unmarshal_json(http_res.text, errors.GetLibraryHubsResponseBody)
148
+ out.raw_response = http_res
149
+ raise out
150
+ else:
151
+ content_type = http_res.headers.get('Content-Type')
152
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
153
+ else:
154
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
155
+
156
+ return res
157
+
158
+