mirror of
https://github.com/LukeHagar/plexpy.git
synced 2025-12-09 12:47:44 +00:00
ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.161.0
This commit is contained in:
143
src/plex_api/updater.py
Normal file
143
src/plex_api/updater.py
Normal file
@@ -0,0 +1,143 @@
|
||||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
||||
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from plex_api import utils
|
||||
from plex_api.models import errors, operations
|
||||
from typing import Optional
|
||||
|
||||
class Updater:
|
||||
r"""This describes the API for searching and applying updates to the Plex Media Server.
|
||||
Updates to the status can be observed via the Event API.
|
||||
"""
|
||||
sdk_configuration: SDKConfiguration
|
||||
|
||||
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
||||
self.sdk_configuration = sdk_config
|
||||
|
||||
|
||||
|
||||
def get_update_status(self) -> operations.GetUpdateStatusResponse:
|
||||
r"""Querying status of updates
|
||||
Querying status of updates
|
||||
"""
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/updater/status'
|
||||
headers = {}
|
||||
headers['Accept'] = 'application/json'
|
||||
headers['user-agent'] = self.sdk_configuration.user_agent
|
||||
|
||||
if callable(self.sdk_configuration.security):
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security())
|
||||
else:
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
|
||||
|
||||
http_res = client.request('GET', url, headers=headers)
|
||||
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)
|
||||
|
||||
if http_res.status_code == 200:
|
||||
if utils.match_content_type(content_type, 'application/json'):
|
||||
out = utils.unmarshal_json(http_res.text, Optional[operations.GetUpdateStatusResponseBody])
|
||||
res.object = out
|
||||
else:
|
||||
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
||||
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
||||
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
||||
elif http_res.status_code == 401:
|
||||
if utils.match_content_type(content_type, 'application/json'):
|
||||
out = utils.unmarshal_json(http_res.text, errors.GetUpdateStatusResponseBody)
|
||||
out.raw_response = http_res
|
||||
raise out
|
||||
else:
|
||||
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def check_for_updates(self, download: Optional[operations.Download] = None) -> operations.CheckForUpdatesResponse:
|
||||
r"""Checking for updates
|
||||
Checking for updates
|
||||
"""
|
||||
request = operations.CheckForUpdatesRequest(
|
||||
download=download,
|
||||
)
|
||||
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/updater/check'
|
||||
headers = {}
|
||||
query_params = utils.get_query_params(operations.CheckForUpdatesRequest, request)
|
||||
headers['Accept'] = 'application/json'
|
||||
headers['user-agent'] = self.sdk_configuration.user_agent
|
||||
|
||||
if callable(self.sdk_configuration.security):
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security())
|
||||
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)
|
||||
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)
|
||||
|
||||
if http_res.status_code == 200:
|
||||
pass
|
||||
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
||||
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
||||
elif http_res.status_code == 401:
|
||||
if utils.match_content_type(content_type, 'application/json'):
|
||||
out = utils.unmarshal_json(http_res.text, errors.CheckForUpdatesResponseBody)
|
||||
out.raw_response = http_res
|
||||
raise out
|
||||
else:
|
||||
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def apply_updates(self, tonight: Optional[operations.Tonight] = None, skip: Optional[operations.Skip] = None) -> operations.ApplyUpdatesResponse:
|
||||
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
|
||||
"""
|
||||
request = operations.ApplyUpdatesRequest(
|
||||
tonight=tonight,
|
||||
skip=skip,
|
||||
)
|
||||
|
||||
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
||||
|
||||
url = base_url + '/updater/apply'
|
||||
headers = {}
|
||||
query_params = utils.get_query_params(operations.ApplyUpdatesRequest, request)
|
||||
headers['Accept'] = 'application/json'
|
||||
headers['user-agent'] = self.sdk_configuration.user_agent
|
||||
|
||||
if callable(self.sdk_configuration.security):
|
||||
client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security())
|
||||
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)
|
||||
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)
|
||||
|
||||
if http_res.status_code == 200:
|
||||
pass
|
||||
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code == 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
||||
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
||||
elif http_res.status_code == 401:
|
||||
if utils.match_content_type(content_type, 'application/json'):
|
||||
out = utils.unmarshal_json(http_res.text, errors.ApplyUpdatesResponseBody)
|
||||
out.raw_response = http_res
|
||||
raise out
|
||||
else:
|
||||
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user