mirror of
https://github.com/LukeHagar/plexpy.git
synced 2025-12-06 04:20:52 +00:00
ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.198.1
This commit is contained in:
@@ -4,9 +4,9 @@ management:
|
||||
docChecksum: e34dac84738ebf2d447ea2b9055a6eeb
|
||||
docVersion: 0.0.3
|
||||
speakeasyVersion: internal
|
||||
generationVersion: 2.272.4
|
||||
releaseVersion: 0.2.1
|
||||
configChecksum: 7495c103921e1dcc54066a6ddc49966d
|
||||
generationVersion: 2.275.4
|
||||
releaseVersion: 0.3.0
|
||||
configChecksum: 1df7c31fecec61686c8b5f29f2f6df8e
|
||||
repoURL: https://github.com/LukeHagar/plexpy.git
|
||||
repoSubDirectory: .
|
||||
installationURL: https://github.com/LukeHagar/plexpy.git
|
||||
@@ -14,9 +14,9 @@ management:
|
||||
features:
|
||||
python:
|
||||
constsAndDefaults: 0.1.2
|
||||
core: 4.4.7
|
||||
core: 4.5.0
|
||||
flattening: 2.81.1
|
||||
globalSecurity: 2.83.3
|
||||
globalSecurity: 2.83.4
|
||||
globalServerURLs: 2.82.1
|
||||
methodServerURLs: 2.82.1
|
||||
nameOverrides: 2.81.1
|
||||
@@ -585,3 +585,6 @@ generatedFiles:
|
||||
- docs/sdks/updater/README.md
|
||||
- USAGE.md
|
||||
- .gitattributes
|
||||
- src/plex_api/_hooks/sdkhooks.py
|
||||
- src/plex_api/_hooks/types.py
|
||||
- src/plex_api/_hooks/__init__.py
|
||||
|
||||
12
RELEASES.md
12
RELEASES.md
@@ -58,4 +58,14 @@ Based on:
|
||||
### Generated
|
||||
- [python v0.2.1] .
|
||||
### Releases
|
||||
- [PyPI v0.2.1] https://pypi.org/project/plex-api-client/0.2.1 - .
|
||||
- [PyPI v0.2.1] https://pypi.org/project/plex-api-client/0.2.1 - .
|
||||
|
||||
## 2024-03-01 01:16:44
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc 0.0.3
|
||||
- Speakeasy CLI 1.198.1 (2.275.4) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [python v0.3.0] .
|
||||
### Releases
|
||||
- [PyPI v0.3.0] https://pypi.org/project/plex-api-client/0.3.0 - .
|
||||
@@ -231,7 +231,7 @@ req = operations.GetResizedPhotoRequest(
|
||||
min_size=operations.MinSize.ONE,
|
||||
upscale=operations.Upscale.ZERO,
|
||||
url='/library/metadata/49564/thumb/1654258204',
|
||||
opacity=209783,
|
||||
opacity=100,
|
||||
)
|
||||
|
||||
res = s.server.get_resized_photo(req)
|
||||
|
||||
6
gen.yaml
6
gen.yaml
@@ -12,7 +12,11 @@ generation:
|
||||
auth:
|
||||
oAuth2ClientCredentialsEnabled: false
|
||||
python:
|
||||
version: 0.2.1
|
||||
version: 0.3.0
|
||||
additionalDependencies:
|
||||
dependencies: {}
|
||||
extraDependencies:
|
||||
dev: {}
|
||||
author: LukeHagar
|
||||
clientServerStatusCodesAsErrors: true
|
||||
description: Python Client SDK Generated by Speakeasy
|
||||
|
||||
10
setup.py
10
setup.py
@@ -10,7 +10,7 @@ except FileNotFoundError:
|
||||
|
||||
setuptools.setup(
|
||||
name="plex-api-client",
|
||||
version="0.2.1",
|
||||
version="0.3.0",
|
||||
author="LukeHagar",
|
||||
description="Python Client SDK Generated by Speakeasy",
|
||||
long_description=long_description,
|
||||
@@ -19,9 +19,9 @@ setuptools.setup(
|
||||
install_requires=[
|
||||
"certifi>=2023.7.22",
|
||||
"charset-normalizer>=3.2.0",
|
||||
"dataclasses-json-speakeasy>=0.5.11",
|
||||
"dataclasses-json>=0.6.4",
|
||||
"idna>=3.4",
|
||||
"jsonpath-python>=1.0.6 ",
|
||||
"jsonpath-python>=1.0.6",
|
||||
"marshmallow>=3.19.0",
|
||||
"mypy-extensions>=1.0.0",
|
||||
"packaging>=23.1",
|
||||
@@ -33,7 +33,9 @@ setuptools.setup(
|
||||
"urllib3>=1.26.18",
|
||||
],
|
||||
extras_require={
|
||||
"dev":["pylint==2.16.2"]
|
||||
"dev": [
|
||||
"pylint==2.16.2",
|
||||
],
|
||||
},
|
||||
package_dir={'': 'src'},
|
||||
python_requires='>=3.8',
|
||||
|
||||
4
src/plex_api/_hooks/__init__.py
Normal file
4
src/plex_api/_hooks/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
from .sdkhooks import *
|
||||
from .types import *
|
||||
55
src/plex_api/_hooks/sdkhooks.py
Normal file
55
src/plex_api/_hooks/sdkhooks.py
Normal file
@@ -0,0 +1,55 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests
|
||||
from .types import SDKInitHook, BeforeRequestContext, BeforeRequestHook, AfterSuccessContext, AfterSuccessHook, AfterErrorContext, AfterErrorHook, Hooks
|
||||
from typing import List, Optional, Tuple, Union
|
||||
|
||||
|
||||
class SDKHooks(Hooks):
|
||||
sdk_init_hooks: List[SDKInitHook] = []
|
||||
before_request_hooks: List[BeforeRequestHook] = []
|
||||
after_success_hooks: List[AfterSuccessHook] = []
|
||||
after_error_hooks: List[AfterErrorHook] = []
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def register_sdk_init_hook(self, hook: SDKInitHook) -> None:
|
||||
self.sdk_init_hooks.append(hook)
|
||||
|
||||
def register_before_request_hook(self, hook: BeforeRequestHook) -> None:
|
||||
self.before_request_hooks.append(hook)
|
||||
|
||||
def register_after_success_hook(self, hook: AfterSuccessHook) -> None:
|
||||
self.after_success_hooks.append(hook)
|
||||
|
||||
def register_after_error_hook(self, hook: AfterErrorHook) -> None:
|
||||
self.after_error_hooks.append(hook)
|
||||
|
||||
def sdk_init(self, base_url: str, client: requests.Session) -> Tuple[str, requests.Session]:
|
||||
for hook in self.sdk_init_hooks:
|
||||
base_url, client = hook.sdk_init(base_url, client)
|
||||
return base_url, client
|
||||
|
||||
def before_request(self, hook_ctx: BeforeRequestContext, request: requests.PreparedRequest) -> Union[requests.PreparedRequest, Exception]:
|
||||
for hook in self.before_request_hooks:
|
||||
request = hook.before_request(hook_ctx, request)
|
||||
if isinstance(request, Exception):
|
||||
raise request
|
||||
|
||||
return request
|
||||
|
||||
def after_success(self, hook_ctx: AfterSuccessContext, response: requests.Response) -> requests.Response:
|
||||
for hook in self.after_success_hooks:
|
||||
response = hook.after_success(hook_ctx, response)
|
||||
if isinstance(response, Exception):
|
||||
raise response
|
||||
return response
|
||||
|
||||
def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests.Response], error: Optional[Exception]) -> Tuple[Optional[requests.Response], Optional[Exception]]:
|
||||
for hook in self.after_error_hooks:
|
||||
result = hook.after_error(hook_ctx, response, error)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
response, error = result
|
||||
return response, error
|
||||
70
src/plex_api/_hooks/types.py
Normal file
70
src/plex_api/_hooks/types.py
Normal file
@@ -0,0 +1,70 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Callable, List, Optional, Tuple, Union
|
||||
|
||||
|
||||
class HookContext:
|
||||
operation_id: str
|
||||
oauth2_scopes: Optional[List[str]] = None
|
||||
security_source: Optional[Union[Any, Callable[[], Any]]] = None
|
||||
|
||||
def __init__(self, operation_id: str, oauth2_scopes: Optional[List[str]], security_source: Optional[Union[Any, Callable[[], Any]]]):
|
||||
self.operation_id = operation_id
|
||||
self.oauth2_scopes = oauth2_scopes
|
||||
self.security_source = security_source
|
||||
|
||||
|
||||
class BeforeRequestContext(HookContext):
|
||||
pass
|
||||
|
||||
|
||||
class AfterSuccessContext(HookContext):
|
||||
pass
|
||||
|
||||
|
||||
class AfterErrorContext(HookContext):
|
||||
pass
|
||||
|
||||
|
||||
class SDKInitHook(ABC):
|
||||
@abstractmethod
|
||||
def sdk_init(self, base_url: str, client: requests_http.Session) -> Tuple[str, requests_http.Session]:
|
||||
pass
|
||||
|
||||
|
||||
class BeforeRequestHook(ABC):
|
||||
@abstractmethod
|
||||
def before_request(self, hook_ctx: BeforeRequestContext, request: requests_http.PreparedRequest) -> Union[requests_http.PreparedRequest, Exception]:
|
||||
pass
|
||||
|
||||
|
||||
class AfterSuccessHook(ABC):
|
||||
@abstractmethod
|
||||
def after_success(self, hook_ctx: AfterSuccessContext, response: requests_http.Response) -> Union[requests_http.PreparedRequest, Exception]:
|
||||
pass
|
||||
|
||||
|
||||
class AfterErrorHook(ABC):
|
||||
@abstractmethod
|
||||
def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests_http.Response], error: Optional[Exception]) -> Union[Tuple[Optional[requests_http.PreparedRequest], Optional[Exception]], Exception]:
|
||||
pass
|
||||
|
||||
|
||||
class Hooks(ABC):
|
||||
@abstractmethod
|
||||
def register_sdk_init_hook(self, hook: SDKInitHook):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def register_before_request_hook(self, hook: BeforeRequestHook):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def register_after_success_hook(self, hook: AfterSuccessHook):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def register_after_error_hook(self, hook: AfterErrorHook):
|
||||
pass
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -25,6 +27,7 @@ class Activities:
|
||||
r"""Get Server Activities
|
||||
Get Server Activities
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getServerActivities', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/activities'
|
||||
@@ -37,7 +40,27 @@ class Activities:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetServerActivitiesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -66,6 +89,7 @@ class Activities:
|
||||
r"""Cancel Server Activities
|
||||
Cancel Server Activities
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='cancelServerActivities', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.CancelServerActivitiesRequest(
|
||||
activity_uuid=activity_uuid,
|
||||
)
|
||||
@@ -82,7 +106,27 @@ class Activities:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('DELETE', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('DELETE', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.CancelServerActivitiesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
|
||||
class Authentication:
|
||||
@@ -17,6 +19,7 @@ class Authentication:
|
||||
r"""Get a Transient Token.
|
||||
This endpoint provides the caller with a temporary token with the same access level as the caller's token. These tokens are valid for up to 48 hours and are destroyed if the server instance is restarted.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getTransientToken', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetTransientTokenRequest(
|
||||
type=type_,
|
||||
scope=scope,
|
||||
@@ -35,7 +38,27 @@ class Authentication:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetTransientTokenResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -61,6 +84,7 @@ class Authentication:
|
||||
If a caller requires connection details and a transient token for a source that is known to the server, for example a cloud media provider or shared PMS, then this endpoint can be called. This endpoint is only accessible with either an admin token or a valid transient token generated from an admin token.
|
||||
Note: requires Plex Media Server >= 1.15.4.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getSourceConnectionInformation', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetSourceConnectionInformationRequest(
|
||||
source=source,
|
||||
)
|
||||
@@ -78,7 +102,27 @@ class Authentication:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetSourceConnectionInformationResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -18,6 +20,7 @@ class Butler:
|
||||
r"""Get Butler tasks
|
||||
Returns a list of butler tasks
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getButlerTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/butler'
|
||||
@@ -30,7 +33,27 @@ class Butler:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetButlerTasksResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -63,6 +86,7 @@ class Butler:
|
||||
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.
|
||||
4. If we are outside the configured window, the task will start immediately.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='startAllTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/butler'
|
||||
@@ -75,7 +99,27 @@ class Butler:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('POST', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('POST', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.StartAllTasksResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -100,6 +144,7 @@ class Butler:
|
||||
r"""Stop all Butler tasks
|
||||
This endpoint will stop all currently running tasks and remove any scheduled tasks from the queue.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='stopAllTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/butler'
|
||||
@@ -112,7 +157,27 @@ class Butler:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('DELETE', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('DELETE', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.StopAllTasksResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -141,6 +206,7 @@ class Butler:
|
||||
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.
|
||||
4. If we are outside the configured window, the task will start immediately.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='startTask', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.StartTaskRequest(
|
||||
task_name=task_name,
|
||||
)
|
||||
@@ -157,7 +223,27 @@ class Butler:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('POST', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('POST', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.StartTaskResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -182,6 +268,7 @@ class Butler:
|
||||
r"""Stop a single Butler task
|
||||
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.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='stopTask', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.StopTaskRequest(
|
||||
task_name=task_name,
|
||||
)
|
||||
@@ -198,7 +285,27 @@ class Butler:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('DELETE', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('DELETE', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','404','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.StopTaskResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -18,6 +20,7 @@ class Hubs:
|
||||
r"""Get Global Hubs
|
||||
Get Global Hubs filtered by the parameters provided.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getGlobalHubs', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetGlobalHubsRequest(
|
||||
count=count,
|
||||
only_transient=only_transient,
|
||||
@@ -36,7 +39,27 @@ class Hubs:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetGlobalHubsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -65,6 +88,7 @@ class Hubs:
|
||||
r"""Get library specific hubs
|
||||
This endpoint will return a list of library specific hubs
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getLibraryHubs', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetLibraryHubsRequest(
|
||||
section_id=section_id,
|
||||
count=count,
|
||||
@@ -84,7 +108,27 @@ class Hubs:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetLibraryHubsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -18,6 +20,7 @@ class Library:
|
||||
r"""Get Hash Value
|
||||
This resource returns hash values for local files
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getFileHash', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetFileHashRequest(
|
||||
url=url,
|
||||
type=type_,
|
||||
@@ -36,7 +39,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetFileHashResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -61,6 +84,7 @@ class Library:
|
||||
r"""Get Recently Added
|
||||
This endpoint will return the recently added content.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getRecentlyAdded', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/library/recentlyAdded'
|
||||
@@ -73,7 +97,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetRecentlyAddedResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -107,6 +151,7 @@ class Library:
|
||||
Libraries have features beyond just being a collection of media; for starters, they include information about supported types, filters and sorts.
|
||||
This allows a client to provide a rich interface around the media (e.g. allow sorting movies by release year).
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getLibraries', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/library/sections'
|
||||
@@ -119,7 +164,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetLibrariesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -186,6 +251,7 @@ class Library:
|
||||
|
||||
> **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getLibrary', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetLibraryRequest(
|
||||
section_id=section_id,
|
||||
include_details=include_details,
|
||||
@@ -204,7 +270,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetLibraryResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -233,6 +319,7 @@ class Library:
|
||||
r"""Delete Library Section
|
||||
Delate a library using a specific section
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='deleteLibrary', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.DeleteLibraryRequest(
|
||||
section_id=section_id,
|
||||
)
|
||||
@@ -249,7 +336,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('DELETE', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('DELETE', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.DeleteLibraryResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -293,6 +400,7 @@ class Library:
|
||||
- `firstCharacter`: Items categorized by the first letter.
|
||||
- `folder`: Items categorized by folder.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getLibraryItems', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetLibraryItemsRequest(
|
||||
section_id=section_id,
|
||||
tag=tag,
|
||||
@@ -310,7 +418,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetLibraryItemsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -332,6 +460,7 @@ class Library:
|
||||
r"""Refresh Library
|
||||
This endpoint Refreshes the library.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='refreshLibrary', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.RefreshLibraryRequest(
|
||||
section_id=section_id,
|
||||
)
|
||||
@@ -348,7 +477,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.RefreshLibraryResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -390,6 +539,7 @@ class Library:
|
||||
|
||||
> **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='searchLibrary', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.SearchLibraryRequest(
|
||||
section_id=section_id,
|
||||
type=type_,
|
||||
@@ -408,7 +558,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.SearchLibraryResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -430,6 +600,7 @@ class Library:
|
||||
r"""Get Items Metadata
|
||||
This endpoint will return the metadata of a library item specified with the ratingKey.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getMetadata', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetMetadataRequest(
|
||||
rating_key=rating_key,
|
||||
)
|
||||
@@ -446,7 +617,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetMetadataResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -475,6 +666,7 @@ class Library:
|
||||
r"""Get Items Children
|
||||
This endpoint will return the children of of a library item specified with the ratingKey.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getMetadataChildren', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetMetadataChildrenRequest(
|
||||
rating_key=rating_key,
|
||||
)
|
||||
@@ -491,7 +683,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetMetadataChildrenResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -520,6 +732,7 @@ class Library:
|
||||
r"""Get On Deck
|
||||
This endpoint will return the on deck content.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getOnDeck', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/library/onDeck'
|
||||
@@ -532,7 +745,27 @@ class Library:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetOnDeckResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
|
||||
class Log:
|
||||
@@ -17,6 +19,7 @@ class Log:
|
||||
r"""Logging a single line message.
|
||||
This endpoint will write a single-line log message, including a level and source to the main Plex Media Server log.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='logLine', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.LogLineRequest(
|
||||
level=level,
|
||||
message=message,
|
||||
@@ -36,7 +39,27 @@ class Log:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.LogLineResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -81,12 +104,13 @@ class Log:
|
||||
|
||||
Ensure each parameter is properly URL-encoded to avoid interpretation issues.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='logMultiLine', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/log'
|
||||
headers = {}
|
||||
req_content_type, data, form = utils.serialize_request_body(request, str, "request", False, False, 'string')
|
||||
if req_content_type not in ('multipart/form-data', 'multipart/mixed'):
|
||||
if req_content_type is not None and req_content_type not in ('multipart/form-data', 'multipart/mixed'):
|
||||
headers['content-type'] = req_content_type
|
||||
if data is None and form is None:
|
||||
raise Exception('request body is required')
|
||||
@@ -98,7 +122,27 @@ class Log:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('POST', url, data=data, files=form, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('POST', url, data=data, files=form, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.LogMultiLineResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -123,6 +167,7 @@ class Log:
|
||||
r"""Enabling Papertrail
|
||||
This endpoint will enable all Plex Media Serverlogs to be sent to the Papertrail networked logging site for a period of time.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='enablePaperTrail', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/log/networked'
|
||||
@@ -135,7 +180,27 @@ class Log:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','403','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.EnablePaperTrailResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
|
||||
class Media:
|
||||
@@ -17,6 +19,7 @@ class Media:
|
||||
r"""Mark Media Played
|
||||
This will mark the provided media key as Played.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='markPlayed', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.MarkPlayedRequest(
|
||||
key=key,
|
||||
)
|
||||
@@ -34,7 +37,27 @@ class Media:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.MarkPlayedResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -59,6 +82,7 @@ class Media:
|
||||
r"""Mark Media Unplayed
|
||||
This will mark the provided media key as Unplayed.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='markUnplayed', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.MarkUnplayedRequest(
|
||||
key=key,
|
||||
)
|
||||
@@ -76,7 +100,27 @@ class Media:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.MarkUnplayedResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -101,6 +145,7 @@ class Media:
|
||||
r"""Update Media Play Progress
|
||||
This API command can be used to update the play progress of a media item.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='updatePlayProgress', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.UpdatePlayProgressRequest(
|
||||
key=key,
|
||||
time=time,
|
||||
@@ -120,7 +165,27 @@ class Media:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('POST', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.UpdatePlayProgressResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -24,6 +26,7 @@ class Playlists:
|
||||
- `uri` - The content URI for what we're playing (e.g. `server://1234/com.plexapp.plugins.library/library/metadata/1`).
|
||||
- `playQueueID` - To create a playlist from an existing play queue.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='createPlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/playlists'
|
||||
@@ -37,7 +40,27 @@ class Playlists:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('POST', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.CreatePlaylistResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -66,6 +89,7 @@ class Playlists:
|
||||
r"""Get All Playlists
|
||||
Get All Playlists given the specified filters.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getPlaylists', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetPlaylistsRequest(
|
||||
playlist_type=playlist_type,
|
||||
smart=smart,
|
||||
@@ -84,7 +108,27 @@ class Playlists:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetPlaylistsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -114,6 +158,7 @@ class Playlists:
|
||||
Gets detailed metadata for a playlist. A playlist for many purposes (rating, editing metadata, tagging), can be treated like a regular metadata item:
|
||||
Smart playlist details contain the `content` attribute. This is the content URI for the generator. This can then be parsed by a client to provide smart playlist editing.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getPlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetPlaylistRequest(
|
||||
playlist_id=playlist_id,
|
||||
)
|
||||
@@ -130,7 +175,27 @@ class Playlists:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetPlaylistResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -159,6 +224,7 @@ class Playlists:
|
||||
r"""Deletes a Playlist
|
||||
This endpoint will delete a playlist
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='deletePlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.DeletePlaylistRequest(
|
||||
playlist_id=playlist_id,
|
||||
)
|
||||
@@ -175,7 +241,27 @@ class Playlists:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('DELETE', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('DELETE', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.DeletePlaylistResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -200,6 +286,7 @@ class Playlists:
|
||||
r"""Update a Playlist
|
||||
From PMS version 1.9.1 clients can also edit playlist metadata using this endpoint as they would via `PUT /library/metadata/{playlistID}`
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='updatePlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.UpdatePlaylistRequest(
|
||||
playlist_id=playlist_id,
|
||||
title=title,
|
||||
@@ -219,7 +306,27 @@ class Playlists:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('PUT', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('PUT', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.UpdatePlaylistResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -247,6 +354,7 @@ class Playlists:
|
||||
For example, you could use this to display a list of recently added albums vis a smart playlist.
|
||||
Note that for dumb playlists, items have a `playlistItemID` attribute which is used for deleting or moving items.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getPlaylistContents', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetPlaylistContentsRequest(
|
||||
playlist_id=playlist_id,
|
||||
type=type_,
|
||||
@@ -265,7 +373,27 @@ class Playlists:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetPlaylistContentsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -294,6 +422,7 @@ class Playlists:
|
||||
r"""Delete Playlist Contents
|
||||
Clears a playlist, only works with dumb playlists. Returns the playlist.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='clearPlaylistContents', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.ClearPlaylistContentsRequest(
|
||||
playlist_id=playlist_id,
|
||||
)
|
||||
@@ -310,7 +439,27 @@ class Playlists:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('DELETE', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('DELETE', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.ClearPlaylistContentsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -336,6 +485,7 @@ class Playlists:
|
||||
Adds a generator to a playlist, same parameters as the POST to create. With a dumb playlist, this adds the specified items to the playlist.
|
||||
With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='addPlaylistContents', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.AddPlaylistContentsRequest(
|
||||
playlist_id=playlist_id,
|
||||
uri=uri,
|
||||
@@ -355,7 +505,27 @@ class Playlists:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('PUT', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('PUT', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.AddPlaylistContentsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -384,6 +554,7 @@ class Playlists:
|
||||
r"""Upload Playlist
|
||||
Imports m3u playlists by passing a path on the server to scan for m3u-formatted playlist files, or a path to a single playlist file.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='uploadPlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.UploadPlaylistRequest(
|
||||
path=path,
|
||||
force=force,
|
||||
@@ -402,7 +573,27 @@ class Playlists:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('POST', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.UploadPlaylistResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -18,6 +20,7 @@ class Plex:
|
||||
r"""Get a Pin
|
||||
Retrieve a Pin from Plex.tv for authentication flows
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getPin', oauth2_scopes=[], security_source=None)
|
||||
request = operations.GetPinRequest(
|
||||
x_plex_client_identifier=x_plex_client_identifier,
|
||||
strong=strong,
|
||||
@@ -36,7 +39,27 @@ class Plex:
|
||||
|
||||
client = self.sdk_configuration.client
|
||||
|
||||
http_res = client.request('POST', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('POST', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetPinResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -65,6 +88,7 @@ class Plex:
|
||||
r"""Get Access Token
|
||||
Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getToken', oauth2_scopes=[], security_source=None)
|
||||
request = operations.GetTokenRequest(
|
||||
pin_id=pin_id,
|
||||
x_plex_client_identifier=x_plex_client_identifier,
|
||||
@@ -82,7 +106,27 @@ class Plex:
|
||||
|
||||
client = self.sdk_configuration.client
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetTokenResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -18,6 +18,7 @@ from .statistics import Statistics
|
||||
from .updater import Updater
|
||||
from .video import Video
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import SDKHooks
|
||||
from plex_api.models import components
|
||||
from typing import Callable, Dict, Union
|
||||
|
||||
@@ -124,6 +125,16 @@ class PlexAPI:
|
||||
]
|
||||
|
||||
self.sdk_configuration = SDKConfiguration(client, security, server_url, server_idx, server_defaults, retry_config=retry_config)
|
||||
|
||||
hooks = SDKHooks()
|
||||
|
||||
current_server_url, *_ = self.sdk_configuration.get_server_details()
|
||||
server_url, self.sdk_configuration.client = hooks.sdk_init(current_server_url, self.sdk_configuration.client)
|
||||
if current_server_url != server_url:
|
||||
self.sdk_configuration.server_url = server_url
|
||||
|
||||
# pylint: disable=protected-access
|
||||
self.sdk_configuration._hooks=hooks
|
||||
|
||||
self._init_sdks()
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
import requests as requests_http
|
||||
from ._hooks import SDKHooks
|
||||
from .utils import utils
|
||||
from .utils.retries import RetryConfig
|
||||
from dataclasses import dataclass, field
|
||||
@@ -31,10 +32,11 @@ class SDKConfiguration:
|
||||
server_defaults: List[Dict[str, str]] = field(default_factory=List)
|
||||
language: str = 'python'
|
||||
openapi_doc_version: str = '0.0.3'
|
||||
sdk_version: str = '0.2.1'
|
||||
gen_version: str = '2.272.4'
|
||||
user_agent: str = 'speakeasy-sdk/python 0.2.1 2.272.4 0.0.3 plex-api-client'
|
||||
sdk_version: str = '0.3.0'
|
||||
gen_version: str = '2.275.4'
|
||||
user_agent: str = 'speakeasy-sdk/python 0.3.0 2.275.4 0.0.3 plex-api-client'
|
||||
retry_config: RetryConfig = None
|
||||
_hooks: SDKHooks = None
|
||||
|
||||
def get_server_details(self) -> Tuple[str, Dict[str, str]]:
|
||||
if self.server_url:
|
||||
@@ -43,3 +45,7 @@ class SDKConfiguration:
|
||||
self.server_idx = 0
|
||||
|
||||
return SERVERS[self.server_idx], self.server_defaults[self.server_idx]
|
||||
|
||||
|
||||
def get_hooks(self) -> SDKHooks:
|
||||
return self._hooks
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -29,6 +31,7 @@ class Search:
|
||||
|
||||
This request is intended to be very fast, and called as the user types.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='performSearch', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.PerformSearchRequest(
|
||||
query=query,
|
||||
section_id=section_id,
|
||||
@@ -48,7 +51,27 @@ class Search:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.PerformSearchResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -76,6 +99,7 @@ class Search:
|
||||
Whenever possible, clients should limit the search to the appropriate type.
|
||||
Results, as well as their containing per-type hubs, contain a `distance` attribute which can be used to judge result quality.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='performVoiceSearch', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.PerformVoiceSearchRequest(
|
||||
query=query,
|
||||
section_id=section_id,
|
||||
@@ -95,7 +119,27 @@ class Search:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.PerformVoiceSearchResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -120,6 +164,7 @@ class Search:
|
||||
r"""Get Search Results
|
||||
This will search the database for the string provided.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getSearchResults', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetSearchResultsRequest(
|
||||
query=query,
|
||||
)
|
||||
@@ -137,7 +182,27 @@ class Search:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetSearchResultsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -18,6 +20,7 @@ class Server:
|
||||
r"""Server Capabilities
|
||||
Server Capabilities
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getServerCapabilities', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/'
|
||||
@@ -30,7 +33,27 @@ class Server:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetServerCapabilitiesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -59,6 +82,7 @@ class Server:
|
||||
r"""Get Server Preferences
|
||||
Get Server Preferences
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getServerPreferences', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/:/prefs'
|
||||
@@ -71,7 +95,27 @@ class Server:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetServerPreferencesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -100,6 +144,7 @@ class Server:
|
||||
r"""Get Available Clients
|
||||
Get Available Clients
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getAvailableClients', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/clients'
|
||||
@@ -112,7 +157,27 @@ class Server:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetAvailableClientsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -141,6 +206,7 @@ class Server:
|
||||
r"""Get Devices
|
||||
Get Devices
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getDevices', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/devices'
|
||||
@@ -153,7 +219,27 @@ class Server:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetDevicesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -182,6 +268,7 @@ class Server:
|
||||
r"""Get Server Identity
|
||||
Get Server Identity
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getServerIdentity', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/identity'
|
||||
@@ -194,7 +281,27 @@ class Server:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetServerIdentityResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -223,6 +330,7 @@ class Server:
|
||||
r"""Get MyPlex Account
|
||||
Returns MyPlex Account Information
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getMyPlexAccount', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/myplex/account'
|
||||
@@ -235,7 +343,27 @@ class Server:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetMyPlexAccountResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -264,6 +392,7 @@ class Server:
|
||||
r"""Get a Resized Photo
|
||||
Plex's Photo transcoder is used throughout the service to serve images at specified sizes.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getResizedPhoto', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/photo/:/transcode'
|
||||
@@ -277,7 +406,27 @@ class Server:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetResizedPhotoResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -302,6 +451,7 @@ class Server:
|
||||
r"""Get Server List
|
||||
Get Server List
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getServerList', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/servers'
|
||||
@@ -314,7 +464,27 @@ class Server:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetServerListResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -18,6 +20,7 @@ class Sessions:
|
||||
r"""Get Active Sessions
|
||||
This will retrieve the \"Now Playing\" Information of the PMS.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getSessions', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/status/sessions'
|
||||
@@ -30,7 +33,27 @@ class Sessions:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetSessionsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -59,6 +82,7 @@ class Sessions:
|
||||
r"""Get Session History
|
||||
This will Retrieve a listing of all history views.
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getSessionHistory', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/status/sessions/history/all'
|
||||
@@ -71,7 +95,27 @@ class Sessions:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetSessionHistoryResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -100,6 +144,7 @@ class Sessions:
|
||||
r"""Get Transcode Sessions
|
||||
Get Transcode Sessions
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getTranscodeSessions', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/transcode/sessions'
|
||||
@@ -112,7 +157,27 @@ class Sessions:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetTranscodeSessionsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -141,6 +206,7 @@ class Sessions:
|
||||
r"""Stop a Transcode Session
|
||||
Stop a Transcode Session
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='stopTranscodeSession', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.StopTranscodeSessionRequest(
|
||||
session_key=session_key,
|
||||
)
|
||||
@@ -157,7 +223,27 @@ class Sessions:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('DELETE', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('DELETE', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.StopTranscodeSessionResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -18,6 +20,7 @@ class Statistics:
|
||||
r"""Get Media Statistics
|
||||
This will return the media statistics for the server
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getStatistics', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.GetStatisticsRequest(
|
||||
timespan=timespan,
|
||||
)
|
||||
@@ -35,7 +38,27 @@ class Statistics:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetStatisticsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
@@ -20,6 +22,7 @@ class Updater:
|
||||
r"""Querying status of updates
|
||||
Querying status of updates
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getUpdateStatus', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/updater/status'
|
||||
@@ -32,7 +35,27 @@ class Updater:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetUpdateStatusResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -61,6 +84,7 @@ class Updater:
|
||||
r"""Checking for updates
|
||||
Checking for updates
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='checkForUpdates', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.CheckForUpdatesRequest(
|
||||
download=download,
|
||||
)
|
||||
@@ -78,7 +102,27 @@ class Updater:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('PUT', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('PUT', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.CheckForUpdatesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -103,6 +147,7 @@ class Updater:
|
||||
r"""Apply Updates
|
||||
Note that these two parameters are effectively mutually exclusive. The `tonight` parameter takes precedence and `skip` will be ignored if `tonight` is also passed
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='applyUpdates', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
request = operations.ApplyUpdatesRequest(
|
||||
tonight=tonight,
|
||||
skip=skip,
|
||||
@@ -121,7 +166,27 @@ class Updater:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('PUT', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('PUT', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','500','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.ApplyUpdatesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
@@ -21,15 +21,16 @@ from dataclasses_json import DataClassJsonMixin
|
||||
class SecurityClient:
|
||||
client: requests.Session
|
||||
query_params: Dict[str, str] = {}
|
||||
headers: Dict[str, str] = {}
|
||||
|
||||
def __init__(self, client: requests.Session):
|
||||
self.client = client
|
||||
|
||||
def request(self, method, url, **kwargs):
|
||||
params = kwargs.get('params', {})
|
||||
kwargs["params"] = {**self.query_params, **params}
|
||||
def send(self, request: requests.PreparedRequest, **kwargs):
|
||||
request.prepare_url(url=request.url, params=self.query_params)
|
||||
request.headers.update(self.headers)
|
||||
|
||||
return self.client.request(method, url, **kwargs)
|
||||
return self.client.send(request, **kwargs)
|
||||
|
||||
|
||||
def configure_security_client(client: requests.Session, security: dataclass):
|
||||
@@ -102,20 +103,19 @@ def _parse_security_scheme_value(client: SecurityClient, scheme_metadata: Dict,
|
||||
|
||||
if scheme_type == "apiKey":
|
||||
if sub_type == 'header':
|
||||
client.client.headers[header_name] = value
|
||||
client.headers[header_name] = value
|
||||
elif sub_type == 'query':
|
||||
client.query_params[header_name] = value
|
||||
elif sub_type == 'cookie':
|
||||
client.client.cookies[header_name] = value
|
||||
else:
|
||||
raise Exception('not supported')
|
||||
elif scheme_type == "openIdConnect":
|
||||
client.client.headers[header_name] = _apply_bearer(value)
|
||||
client.headers[header_name] = _apply_bearer(value)
|
||||
elif scheme_type == 'oauth2':
|
||||
client.client.headers[header_name] = _apply_bearer(value)
|
||||
if sub_type != 'client_credentials':
|
||||
client.headers[header_name] = _apply_bearer(value)
|
||||
elif scheme_type == 'http':
|
||||
if sub_type == 'bearer':
|
||||
client.client.headers[header_name] = _apply_bearer(value)
|
||||
client.headers[header_name] = _apply_bearer(value)
|
||||
else:
|
||||
raise Exception('not supported')
|
||||
else:
|
||||
@@ -145,7 +145,7 @@ def _parse_basic_auth_scheme(client: SecurityClient, scheme: dataclass):
|
||||
password = value
|
||||
|
||||
data = f'{username}:{password}'.encode()
|
||||
client.client.headers['Authorization'] = f'Basic {base64.b64encode(data).decode()}'
|
||||
client.headers['Authorization'] = f'Basic {base64.b64encode(data).decode()}'
|
||||
|
||||
|
||||
def generate_url(clazz: type, server_url: str, path: str, path_params: dataclass,
|
||||
@@ -264,7 +264,8 @@ def get_query_params(clazz: type, query_params: dataclass, gbls: Dict[str, Dict[
|
||||
f_name = metadata.get("field_name")
|
||||
serialization = metadata.get('serialization', '')
|
||||
if serialization != '':
|
||||
serialized_parms = _get_serialized_params(metadata, field.type, f_name, value)
|
||||
serialized_parms = _get_serialized_params(
|
||||
metadata, field.type, f_name, value)
|
||||
for key, value in serialized_parms.items():
|
||||
if key in params:
|
||||
params[key].extend(value)
|
||||
@@ -312,7 +313,8 @@ def _get_serialized_params(metadata: Dict, field_type: type, field_name: str, ob
|
||||
|
||||
serialization = metadata.get('serialization', '')
|
||||
if serialization == 'json':
|
||||
params[metadata.get("field_name", field_name)] = marshal_json(obj, field_type)
|
||||
params[metadata.get("field_name", field_name)
|
||||
] = marshal_json(obj, field_type)
|
||||
|
||||
return params
|
||||
|
||||
@@ -702,7 +704,8 @@ def unmarshal_json(data, typ, decoder=None):
|
||||
|
||||
def marshal_json(val, typ, encoder=None):
|
||||
if not is_optional_type(typ) and val is None:
|
||||
raise ValueError(f"Could not marshal None into non-optional type: {typ}")
|
||||
raise ValueError(
|
||||
f"Could not marshal None into non-optional type: {typ}")
|
||||
|
||||
marshal = make_dataclass('Marshal', [('res', typ)],
|
||||
bases=(DataClassJsonMixin,))
|
||||
@@ -732,6 +735,16 @@ def match_content_type(content_type: str, pattern: str) -> boolean:
|
||||
return False
|
||||
|
||||
|
||||
def match_status_codes(status_codes: List[str], status_code: int) -> bool:
|
||||
for code in status_codes:
|
||||
if code == str(status_code):
|
||||
return True
|
||||
|
||||
if code.endswith("XX") and code.startswith(str(status_code)[:1]):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def datetimeisoformat(optional: bool):
|
||||
def isoformatoptional(val):
|
||||
if optional and val is None:
|
||||
@@ -835,6 +848,7 @@ def list_decoder(value_decoder: Callable):
|
||||
|
||||
return list_decode
|
||||
|
||||
|
||||
def union_encoder(all_encoders: Dict[str, Callable]):
|
||||
def selective_encoder(val: any):
|
||||
if type(val) in all_encoders:
|
||||
@@ -842,6 +856,7 @@ def union_encoder(all_encoders: Dict[str, Callable]):
|
||||
return val
|
||||
return selective_encoder
|
||||
|
||||
|
||||
def union_decoder(all_decoders: List[Callable]):
|
||||
def selective_decoder(val: any):
|
||||
decoded = val
|
||||
@@ -854,6 +869,7 @@ def union_decoder(all_decoders: List[Callable]):
|
||||
return decoded
|
||||
return selective_decoder
|
||||
|
||||
|
||||
def get_field_name(name):
|
||||
def override(_, _field_name=name):
|
||||
return _field_name
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
import requests as requests_http
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api._hooks import HookContext
|
||||
from plex_api.models import errors, operations
|
||||
|
||||
class Video:
|
||||
@@ -17,6 +19,7 @@ class Video:
|
||||
r"""Get the timeline for a media item
|
||||
Get the timeline for a media item
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='getTimeline', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/:/timeline'
|
||||
@@ -30,7 +33,27 @@ class Video:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.GetTimelineResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
@@ -55,6 +78,7 @@ class Video:
|
||||
r"""Start Universal Transcode
|
||||
Begin a Universal Transcode Session
|
||||
"""
|
||||
hook_ctx = HookContext(operation_id='startUniversalTranscode', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/video/:/transcode/universal/start.mpd'
|
||||
@@ -68,7 +92,27 @@ class Video:
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, params=query_params, headers=headers)
|
||||
|
||||
try:
|
||||
req = self.sdk_configuration.get_hooks().before_request(
|
||||
hook_ctx,
|
||||
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
|
||||
)
|
||||
http_res = client.send(req)
|
||||
except Exception as e:
|
||||
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
|
||||
raise e
|
||||
|
||||
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
||||
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
|
||||
if e:
|
||||
raise e
|
||||
else:
|
||||
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
|
||||
if isinstance(result, Exception):
|
||||
raise result
|
||||
http_res = result
|
||||
|
||||
content_type = http_res.headers.get('Content-Type')
|
||||
|
||||
res = operations.StartUniversalTranscodeResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
|
||||
|
||||
Reference in New Issue
Block a user