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/library.py ADDED
@@ -0,0 +1,808 @@
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 Library:
11
+ r"""API Calls interacting with Plex Media Server Libraries"""
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_file_hash(self, url: str, type_: Optional[float] = None) -> operations.GetFileHashResponse:
20
+ r"""Get Hash Value
21
+ This resource returns hash values for local files
22
+ """
23
+ hook_ctx = HookContext(operation_id='getFileHash', oauth2_scopes=[], security_source=self.sdk_configuration.security)
24
+ request = operations.GetFileHashRequest(
25
+ url=url,
26
+ type=type_,
27
+ )
28
+
29
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
30
+
31
+ url = base_url + '/library/hashes'
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.GetFileHashRequest, 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.GetFileHashResponse(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
+ pass
67
+ 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:
68
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
69
+ elif http_res.status_code == 401:
70
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
71
+ out = utils.unmarshal_json(http_res.text, errors.GetFileHashResponseBody)
72
+ out.raw_response = http_res
73
+ raise out
74
+ else:
75
+ content_type = http_res.headers.get('Content-Type')
76
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
77
+ else:
78
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
79
+
80
+ return res
81
+
82
+
83
+
84
+ def get_recently_added(self) -> operations.GetRecentlyAddedResponse:
85
+ r"""Get Recently Added
86
+ This endpoint will return the recently added content.
87
+ """
88
+ hook_ctx = HookContext(operation_id='getRecentlyAdded', oauth2_scopes=[], security_source=self.sdk_configuration.security)
89
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
90
+
91
+ url = base_url + '/library/recentlyAdded'
92
+
93
+ if callable(self.sdk_configuration.security):
94
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
95
+ else:
96
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
97
+
98
+ headers['Accept'] = 'application/json'
99
+ headers['user-agent'] = self.sdk_configuration.user_agent
100
+ client = self.sdk_configuration.client
101
+
102
+ try:
103
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
104
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
105
+ http_res = client.send(req)
106
+ except Exception as e:
107
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
108
+ if e is not None:
109
+ raise e
110
+
111
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
112
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
113
+ if e is not None:
114
+ raise e
115
+ if result is not None:
116
+ http_res = result
117
+ else:
118
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
119
+
120
+
121
+
122
+ res = operations.GetRecentlyAddedResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
123
+
124
+ if http_res.status_code == 200:
125
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
126
+ out = utils.unmarshal_json(http_res.text, Optional[operations.GetRecentlyAddedResponseBody])
127
+ res.object = out
128
+ else:
129
+ content_type = http_res.headers.get('Content-Type')
130
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
131
+ 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:
132
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
133
+ elif http_res.status_code == 401:
134
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
135
+ out = utils.unmarshal_json(http_res.text, errors.GetRecentlyAddedResponseBody)
136
+ out.raw_response = http_res
137
+ raise out
138
+ else:
139
+ content_type = http_res.headers.get('Content-Type')
140
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
141
+ else:
142
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
143
+
144
+ return res
145
+
146
+
147
+
148
+ def get_libraries(self) -> operations.GetLibrariesResponse:
149
+ r"""Get All Libraries
150
+ A library section (commonly referred to as just a library) is a collection of media.
151
+ Libraries are typed, and depending on their type provide either a flat or a hierarchical view of the media.
152
+ For example, a music library has an artist > albums > tracks structure, whereas a movie library is flat.
153
+
154
+ Libraries have features beyond just being a collection of media; for starters, they include information about supported types, filters and sorts.
155
+ This allows a client to provide a rich interface around the media (e.g. allow sorting movies by release year).
156
+ """
157
+ hook_ctx = HookContext(operation_id='getLibraries', oauth2_scopes=[], security_source=self.sdk_configuration.security)
158
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
159
+
160
+ url = base_url + '/library/sections'
161
+
162
+ if callable(self.sdk_configuration.security):
163
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
164
+ else:
165
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
166
+
167
+ headers['Accept'] = 'application/json'
168
+ headers['user-agent'] = self.sdk_configuration.user_agent
169
+ client = self.sdk_configuration.client
170
+
171
+ try:
172
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
173
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
174
+ http_res = client.send(req)
175
+ except Exception as e:
176
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
177
+ if e is not None:
178
+ raise e
179
+
180
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
181
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
182
+ if e is not None:
183
+ raise e
184
+ if result is not None:
185
+ http_res = result
186
+ else:
187
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
188
+
189
+
190
+
191
+ res = operations.GetLibrariesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
192
+
193
+ if http_res.status_code == 200:
194
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
195
+ out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibrariesResponseBody])
196
+ res.object = out
197
+ else:
198
+ content_type = http_res.headers.get('Content-Type')
199
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
200
+ 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:
201
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
202
+ elif http_res.status_code == 401:
203
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
204
+ out = utils.unmarshal_json(http_res.text, errors.GetLibrariesResponseBody)
205
+ out.raw_response = http_res
206
+ raise out
207
+ else:
208
+ content_type = http_res.headers.get('Content-Type')
209
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
210
+ else:
211
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
212
+
213
+ return res
214
+
215
+
216
+
217
+ def get_library(self, section_id: float, include_details: Optional[operations.IncludeDetails] = None) -> operations.GetLibraryResponse:
218
+ r"""Get Library Details
219
+ ## Library Details Endpoint
220
+
221
+ This endpoint provides comprehensive details about the library, focusing on organizational aspects rather than the content itself.
222
+
223
+ The details include:
224
+
225
+ ### Directories
226
+ Organized into three categories:
227
+
228
+ - **Primary Directories**:
229
+ - Used in some clients for quick access to media subsets (e.g., \"All\", \"On Deck\").
230
+ - Most can be replicated via media queries.
231
+ - Customizable by users.
232
+
233
+ - **Secondary Directories**:
234
+ - Marked with `secondary=\"1\"`.
235
+ - Used in older clients for structured navigation.
236
+
237
+ - **Special Directories**:
238
+ - Includes a \"By Folder\" entry for filesystem-based browsing.
239
+ - Contains an obsolete `search=\"1\"` entry for on-the-fly search dialog creation.
240
+
241
+ ### Types
242
+ Each type in the library comes with a set of filters and sorts, aiding in building dynamic media controls:
243
+
244
+ - **Type Object Attributes**:
245
+ - `key`: Endpoint for the media list of this type.
246
+ - `type`: Metadata type (if standard Plex type).
247
+ - `title`: Title for this content type (e.g., \"Movies\").
248
+
249
+ - **Filter Objects**:
250
+ - Subset of the media query language.
251
+ - Attributes include `filter` (name), `filterType` (data type), `key` (endpoint for value range), and `title`.
252
+
253
+ - **Sort Objects**:
254
+ - Description of sort fields.
255
+ - Attributes include `defaultDirection` (asc/desc), `descKey` and `key` (sort parameters), and `title`.
256
+
257
+ > **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.
258
+ """
259
+ hook_ctx = HookContext(operation_id='getLibrary', oauth2_scopes=[], security_source=self.sdk_configuration.security)
260
+ request = operations.GetLibraryRequest(
261
+ section_id=section_id,
262
+ include_details=include_details,
263
+ )
264
+
265
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
266
+
267
+ url = utils.generate_url(operations.GetLibraryRequest, base_url, '/library/sections/{sectionId}', request, self.sdk_configuration.globals)
268
+
269
+ if callable(self.sdk_configuration.security):
270
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
271
+ else:
272
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
273
+
274
+ query_params = { **utils.get_query_params(operations.GetLibraryRequest, request, self.sdk_configuration.globals), **query_params }
275
+ headers['Accept'] = 'application/json'
276
+ headers['user-agent'] = self.sdk_configuration.user_agent
277
+ client = self.sdk_configuration.client
278
+
279
+ try:
280
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
281
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
282
+ http_res = client.send(req)
283
+ except Exception as e:
284
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
285
+ if e is not None:
286
+ raise e
287
+
288
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
289
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
290
+ if e is not None:
291
+ raise e
292
+ if result is not None:
293
+ http_res = result
294
+ else:
295
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
296
+
297
+
298
+
299
+ res = operations.GetLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
300
+
301
+ if http_res.status_code == 200:
302
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
303
+ out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryResponseBody])
304
+ res.object = out
305
+ else:
306
+ content_type = http_res.headers.get('Content-Type')
307
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
308
+ 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:
309
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
310
+ elif http_res.status_code == 401:
311
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
312
+ out = utils.unmarshal_json(http_res.text, errors.GetLibraryResponseBody)
313
+ out.raw_response = http_res
314
+ raise out
315
+ else:
316
+ content_type = http_res.headers.get('Content-Type')
317
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
318
+ else:
319
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
320
+
321
+ return res
322
+
323
+
324
+
325
+ def delete_library(self, section_id: float) -> operations.DeleteLibraryResponse:
326
+ r"""Delete Library Section
327
+ Delate a library using a specific section
328
+ """
329
+ hook_ctx = HookContext(operation_id='deleteLibrary', oauth2_scopes=[], security_source=self.sdk_configuration.security)
330
+ request = operations.DeleteLibraryRequest(
331
+ section_id=section_id,
332
+ )
333
+
334
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
335
+
336
+ url = utils.generate_url(operations.DeleteLibraryRequest, base_url, '/library/sections/{sectionId}', request, self.sdk_configuration.globals)
337
+
338
+ if callable(self.sdk_configuration.security):
339
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
340
+ else:
341
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
342
+
343
+ headers['Accept'] = 'application/json'
344
+ headers['user-agent'] = self.sdk_configuration.user_agent
345
+ client = self.sdk_configuration.client
346
+
347
+ try:
348
+ req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
349
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
350
+ http_res = client.send(req)
351
+ except Exception as e:
352
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
353
+ if e is not None:
354
+ raise e
355
+
356
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
357
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
358
+ if e is not None:
359
+ raise e
360
+ if result is not None:
361
+ http_res = result
362
+ else:
363
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
364
+
365
+
366
+
367
+ res = operations.DeleteLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
368
+
369
+ if http_res.status_code == 200:
370
+ pass
371
+ 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:
372
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
373
+ elif http_res.status_code == 401:
374
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
375
+ out = utils.unmarshal_json(http_res.text, errors.DeleteLibraryResponseBody)
376
+ out.raw_response = http_res
377
+ raise out
378
+ else:
379
+ content_type = http_res.headers.get('Content-Type')
380
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
381
+ else:
382
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
383
+
384
+ return res
385
+
386
+
387
+
388
+ def get_library_items(self, section_id: int, tag: operations.Tag) -> operations.GetLibraryItemsResponse:
389
+ r"""Get Library Items
390
+ Fetches details from a specific section of the library identified by a section key and a tag. The tag parameter accepts the following values:
391
+ - `all`: All items in the section.
392
+ - `unwatched`: Items that have not been played.
393
+ - `newest`: Items that are recently released.
394
+ - `recentlyAdded`: Items that are recently added to the library.
395
+ - `recentlyViewed`: Items that were recently viewed.
396
+ - `onDeck`: Items to continue watching.
397
+ - `collection`: Items categorized by collection.
398
+ - `edition`: Items categorized by edition.
399
+ - `genre`: Items categorized by genre.
400
+ - `year`: Items categorized by year of release.
401
+ - `decade`: Items categorized by decade.
402
+ - `director`: Items categorized by director.
403
+ - `actor`: Items categorized by starring actor.
404
+ - `country`: Items categorized by country of origin.
405
+ - `contentRating`: Items categorized by content rating.
406
+ - `rating`: Items categorized by rating.
407
+ - `resolution`: Items categorized by resolution.
408
+ - `firstCharacter`: Items categorized by the first letter.
409
+ - `folder`: Items categorized by folder.
410
+ """
411
+ hook_ctx = HookContext(operation_id='getLibraryItems', oauth2_scopes=[], security_source=self.sdk_configuration.security)
412
+ request = operations.GetLibraryItemsRequest(
413
+ section_id=section_id,
414
+ tag=tag,
415
+ )
416
+
417
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
418
+
419
+ url = utils.generate_url(operations.GetLibraryItemsRequest, base_url, '/library/sections/{sectionId}/{tag}', request, self.sdk_configuration.globals)
420
+
421
+ if callable(self.sdk_configuration.security):
422
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
423
+ else:
424
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
425
+
426
+ headers['Accept'] = 'application/json'
427
+ headers['user-agent'] = self.sdk_configuration.user_agent
428
+ client = self.sdk_configuration.client
429
+
430
+ try:
431
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
432
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
433
+ http_res = client.send(req)
434
+ except Exception as e:
435
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
436
+ if e is not None:
437
+ raise e
438
+
439
+ if utils.match_status_codes(['4XX','5XX'], http_res.status_code):
440
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
441
+ if e is not None:
442
+ raise e
443
+ if result is not None:
444
+ http_res = result
445
+ else:
446
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
447
+
448
+
449
+
450
+ res = operations.GetLibraryItemsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
451
+
452
+ if http_res.status_code == 200:
453
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
454
+ out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryItemsResponseBody])
455
+ res.object = out
456
+ else:
457
+ content_type = http_res.headers.get('Content-Type')
458
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
459
+ elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
460
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
461
+ else:
462
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
463
+
464
+ return res
465
+
466
+
467
+
468
+ def refresh_library(self, section_id: float) -> operations.RefreshLibraryResponse:
469
+ r"""Refresh Library
470
+ This endpoint Refreshes the library.
471
+ """
472
+ hook_ctx = HookContext(operation_id='refreshLibrary', oauth2_scopes=[], security_source=self.sdk_configuration.security)
473
+ request = operations.RefreshLibraryRequest(
474
+ section_id=section_id,
475
+ )
476
+
477
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
478
+
479
+ url = utils.generate_url(operations.RefreshLibraryRequest, base_url, '/library/sections/{sectionId}/refresh', request, self.sdk_configuration.globals)
480
+
481
+ if callable(self.sdk_configuration.security):
482
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
483
+ else:
484
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
485
+
486
+ headers['Accept'] = 'application/json'
487
+ headers['user-agent'] = self.sdk_configuration.user_agent
488
+ client = self.sdk_configuration.client
489
+
490
+ try:
491
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
492
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
493
+ http_res = client.send(req)
494
+ except Exception as e:
495
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
496
+ if e is not None:
497
+ raise e
498
+
499
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
500
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
501
+ if e is not None:
502
+ raise e
503
+ if result is not None:
504
+ http_res = result
505
+ else:
506
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
507
+
508
+
509
+
510
+ res = operations.RefreshLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
511
+
512
+ if http_res.status_code == 200:
513
+ pass
514
+ 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:
515
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
516
+ elif http_res.status_code == 401:
517
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
518
+ out = utils.unmarshal_json(http_res.text, errors.RefreshLibraryResponseBody)
519
+ out.raw_response = http_res
520
+ raise out
521
+ else:
522
+ content_type = http_res.headers.get('Content-Type')
523
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
524
+ else:
525
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
526
+
527
+ return res
528
+
529
+
530
+
531
+ def search_library(self, section_id: int, type_: operations.Type) -> operations.SearchLibraryResponse:
532
+ r"""Search Library
533
+ Search for content within a specific section of the library.
534
+
535
+ ### Types
536
+ Each type in the library comes with a set of filters and sorts, aiding in building dynamic media controls:
537
+
538
+ - **Type Object Attributes**:
539
+ - `type`: Metadata type (if standard Plex type).
540
+ - `title`: Title for this content type (e.g., \"Movies\").
541
+
542
+ - **Filter Objects**:
543
+ - Subset of the media query language.
544
+ - Attributes include `filter` (name), `filterType` (data type), `key` (endpoint for value range), and `title`.
545
+
546
+ - **Sort Objects**:
547
+ - Description of sort fields.
548
+ - Attributes include `defaultDirection` (asc/desc), `descKey` and `key` (sort parameters), and `title`.
549
+
550
+ > **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.
551
+ """
552
+ hook_ctx = HookContext(operation_id='searchLibrary', oauth2_scopes=[], security_source=self.sdk_configuration.security)
553
+ request = operations.SearchLibraryRequest(
554
+ section_id=section_id,
555
+ type=type_,
556
+ )
557
+
558
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
559
+
560
+ url = utils.generate_url(operations.SearchLibraryRequest, base_url, '/library/sections/{sectionId}/search', request, self.sdk_configuration.globals)
561
+
562
+ if callable(self.sdk_configuration.security):
563
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
564
+ else:
565
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
566
+
567
+ query_params = { **utils.get_query_params(operations.SearchLibraryRequest, request, self.sdk_configuration.globals), **query_params }
568
+ headers['Accept'] = 'application/json'
569
+ headers['user-agent'] = self.sdk_configuration.user_agent
570
+ client = self.sdk_configuration.client
571
+
572
+ try:
573
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
574
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
575
+ http_res = client.send(req)
576
+ except Exception as e:
577
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
578
+ if e is not None:
579
+ raise e
580
+
581
+ if utils.match_status_codes(['4XX','5XX'], http_res.status_code):
582
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
583
+ if e is not None:
584
+ raise e
585
+ if result is not None:
586
+ http_res = result
587
+ else:
588
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
589
+
590
+
591
+
592
+ res = operations.SearchLibraryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
593
+
594
+ if http_res.status_code == 200:
595
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
596
+ out = utils.unmarshal_json(http_res.text, Optional[operations.SearchLibraryResponseBody])
597
+ res.object = out
598
+ else:
599
+ content_type = http_res.headers.get('Content-Type')
600
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
601
+ elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
602
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
603
+ else:
604
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
605
+
606
+ return res
607
+
608
+
609
+
610
+ def get_metadata(self, rating_key: float) -> operations.GetMetadataResponse:
611
+ r"""Get Items Metadata
612
+ This endpoint will return the metadata of a library item specified with the ratingKey.
613
+ """
614
+ hook_ctx = HookContext(operation_id='getMetadata', oauth2_scopes=[], security_source=self.sdk_configuration.security)
615
+ request = operations.GetMetadataRequest(
616
+ rating_key=rating_key,
617
+ )
618
+
619
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
620
+
621
+ url = utils.generate_url(operations.GetMetadataRequest, base_url, '/library/metadata/{ratingKey}', request, self.sdk_configuration.globals)
622
+
623
+ if callable(self.sdk_configuration.security):
624
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
625
+ else:
626
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
627
+
628
+ headers['Accept'] = 'application/json'
629
+ headers['user-agent'] = self.sdk_configuration.user_agent
630
+ client = self.sdk_configuration.client
631
+
632
+ try:
633
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
634
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
635
+ http_res = client.send(req)
636
+ except Exception as e:
637
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
638
+ if e is not None:
639
+ raise e
640
+
641
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
642
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
643
+ if e is not None:
644
+ raise e
645
+ if result is not None:
646
+ http_res = result
647
+ else:
648
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
649
+
650
+
651
+
652
+ res = operations.GetMetadataResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
653
+
654
+ if http_res.status_code == 200:
655
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
656
+ out = utils.unmarshal_json(http_res.text, Optional[operations.GetMetadataResponseBody])
657
+ res.object = out
658
+ else:
659
+ content_type = http_res.headers.get('Content-Type')
660
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
661
+ 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:
662
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
663
+ elif http_res.status_code == 401:
664
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
665
+ out = utils.unmarshal_json(http_res.text, errors.GetMetadataResponseBody)
666
+ out.raw_response = http_res
667
+ raise out
668
+ else:
669
+ content_type = http_res.headers.get('Content-Type')
670
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
671
+ else:
672
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
673
+
674
+ return res
675
+
676
+
677
+
678
+ def get_metadata_children(self, rating_key: float) -> operations.GetMetadataChildrenResponse:
679
+ r"""Get Items Children
680
+ This endpoint will return the children of of a library item specified with the ratingKey.
681
+ """
682
+ hook_ctx = HookContext(operation_id='getMetadataChildren', oauth2_scopes=[], security_source=self.sdk_configuration.security)
683
+ request = operations.GetMetadataChildrenRequest(
684
+ rating_key=rating_key,
685
+ )
686
+
687
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
688
+
689
+ url = utils.generate_url(operations.GetMetadataChildrenRequest, base_url, '/library/metadata/{ratingKey}/children', request, self.sdk_configuration.globals)
690
+
691
+ if callable(self.sdk_configuration.security):
692
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
693
+ else:
694
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
695
+
696
+ headers['Accept'] = 'application/json'
697
+ headers['user-agent'] = self.sdk_configuration.user_agent
698
+ client = self.sdk_configuration.client
699
+
700
+ try:
701
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
702
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
703
+ http_res = client.send(req)
704
+ except Exception as e:
705
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
706
+ if e is not None:
707
+ raise e
708
+
709
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
710
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
711
+ if e is not None:
712
+ raise e
713
+ if result is not None:
714
+ http_res = result
715
+ else:
716
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
717
+
718
+
719
+
720
+ res = operations.GetMetadataChildrenResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
721
+
722
+ if http_res.status_code == 200:
723
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
724
+ out = utils.unmarshal_json(http_res.text, Optional[operations.GetMetadataChildrenResponseBody])
725
+ res.object = out
726
+ else:
727
+ content_type = http_res.headers.get('Content-Type')
728
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
729
+ 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:
730
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
731
+ elif http_res.status_code == 401:
732
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
733
+ out = utils.unmarshal_json(http_res.text, errors.GetMetadataChildrenResponseBody)
734
+ out.raw_response = http_res
735
+ raise out
736
+ else:
737
+ content_type = http_res.headers.get('Content-Type')
738
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
739
+ else:
740
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
741
+
742
+ return res
743
+
744
+
745
+
746
+ def get_on_deck(self) -> operations.GetOnDeckResponse:
747
+ r"""Get On Deck
748
+ This endpoint will return the on deck content.
749
+ """
750
+ hook_ctx = HookContext(operation_id='getOnDeck', oauth2_scopes=[], security_source=self.sdk_configuration.security)
751
+ base_url = utils.template_url(*self.sdk_configuration.get_server_details())
752
+
753
+ url = base_url + '/library/onDeck'
754
+
755
+ if callable(self.sdk_configuration.security):
756
+ headers, query_params = utils.get_security(self.sdk_configuration.security())
757
+ else:
758
+ headers, query_params = utils.get_security(self.sdk_configuration.security)
759
+
760
+ headers['Accept'] = 'application/json'
761
+ headers['user-agent'] = self.sdk_configuration.user_agent
762
+ client = self.sdk_configuration.client
763
+
764
+ try:
765
+ req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
766
+ req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
767
+ http_res = client.send(req)
768
+ except Exception as e:
769
+ _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
770
+ if e is not None:
771
+ raise e
772
+
773
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
774
+ result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
775
+ if e is not None:
776
+ raise e
777
+ if result is not None:
778
+ http_res = result
779
+ else:
780
+ http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
781
+
782
+
783
+
784
+ res = operations.GetOnDeckResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
785
+
786
+ if http_res.status_code == 200:
787
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
788
+ out = utils.unmarshal_json(http_res.text, Optional[operations.GetOnDeckResponseBody])
789
+ res.object = out
790
+ else:
791
+ content_type = http_res.headers.get('Content-Type')
792
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
793
+ 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:
794
+ raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
795
+ elif http_res.status_code == 401:
796
+ if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
797
+ out = utils.unmarshal_json(http_res.text, errors.GetOnDeckResponseBody)
798
+ out.raw_response = http_res
799
+ raise out
800
+ else:
801
+ content_type = http_res.headers.get('Content-Type')
802
+ raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
803
+ else:
804
+ raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
805
+
806
+ return res
807
+
808
+