mirror of
https://github.com/LukeHagar/plexpy.git
synced 2025-12-06 04:20:52 +00:00
893 lines
36 KiB
Python
893 lines
36 KiB
Python
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
|
|
from .basesdk import BaseSDK
|
|
from plex_api_client import utils
|
|
from plex_api_client._hooks import HookContext
|
|
from plex_api_client.models import errors, operations
|
|
from plex_api_client.types import OptionalNullable, UNSET
|
|
from typing import Any, Mapping, Optional, Union
|
|
|
|
|
|
class Sessions(BaseSDK):
|
|
r"""API Calls that perform search operations with Plex Media Server Sessions"""
|
|
|
|
def get_sessions(
|
|
self,
|
|
*,
|
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
server_url: Optional[str] = None,
|
|
timeout_ms: Optional[int] = None,
|
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
) -> operations.GetSessionsResponse:
|
|
r"""Get Active Sessions
|
|
|
|
This will retrieve the \"Now Playing\" Information of the PMS.
|
|
|
|
:param retries: Override the default retry configuration for this method
|
|
:param server_url: Override the default server URL for this method
|
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
:param http_headers: Additional headers to set or replace on requests.
|
|
"""
|
|
base_url = None
|
|
url_variables = None
|
|
if timeout_ms is None:
|
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
|
|
if server_url is not None:
|
|
base_url = server_url
|
|
else:
|
|
base_url = self._get_url(base_url, url_variables)
|
|
req = self._build_request(
|
|
method="GET",
|
|
path="/status/sessions",
|
|
base_url=base_url,
|
|
url_variables=url_variables,
|
|
request=None,
|
|
request_body_required=False,
|
|
request_has_path_params=False,
|
|
request_has_query_params=True,
|
|
user_agent_header="user-agent",
|
|
accept_header_value="application/json",
|
|
http_headers=http_headers,
|
|
security=self.sdk_configuration.security,
|
|
timeout_ms=timeout_ms,
|
|
)
|
|
|
|
if retries == UNSET:
|
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
retries = self.sdk_configuration.retry_config
|
|
|
|
retry_config = None
|
|
if isinstance(retries, utils.RetryConfig):
|
|
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
|
|
http_res = self.do_request(
|
|
hook_ctx=HookContext(
|
|
base_url=base_url or "",
|
|
operation_id="getSessions",
|
|
oauth2_scopes=[],
|
|
security_source=self.sdk_configuration.security,
|
|
),
|
|
request=req,
|
|
error_status_codes=["400", "401", "4XX", "5XX"],
|
|
retry_config=retry_config,
|
|
)
|
|
|
|
response_data: Any = None
|
|
if utils.match_response(http_res, "200", "application/json"):
|
|
return operations.GetSessionsResponse(
|
|
object=utils.unmarshal_json(
|
|
http_res.text, Optional[operations.GetSessionsResponseBody]
|
|
),
|
|
status_code=http_res.status_code,
|
|
content_type=http_res.headers.get("Content-Type") or "",
|
|
raw_response=http_res,
|
|
)
|
|
if utils.match_response(http_res, "400", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetSessionsBadRequestData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetSessionsBadRequest(data=response_data)
|
|
if utils.match_response(http_res, "401", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetSessionsUnauthorizedData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetSessionsUnauthorized(data=response_data)
|
|
if utils.match_response(http_res, "4XX", "*"):
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
if utils.match_response(http_res, "5XX", "*"):
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
|
|
content_type = http_res.headers.get("Content-Type")
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
http_res.status_code,
|
|
http_res_text,
|
|
http_res,
|
|
)
|
|
|
|
async def get_sessions_async(
|
|
self,
|
|
*,
|
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
server_url: Optional[str] = None,
|
|
timeout_ms: Optional[int] = None,
|
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
) -> operations.GetSessionsResponse:
|
|
r"""Get Active Sessions
|
|
|
|
This will retrieve the \"Now Playing\" Information of the PMS.
|
|
|
|
:param retries: Override the default retry configuration for this method
|
|
:param server_url: Override the default server URL for this method
|
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
:param http_headers: Additional headers to set or replace on requests.
|
|
"""
|
|
base_url = None
|
|
url_variables = None
|
|
if timeout_ms is None:
|
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
|
|
if server_url is not None:
|
|
base_url = server_url
|
|
else:
|
|
base_url = self._get_url(base_url, url_variables)
|
|
req = self._build_request_async(
|
|
method="GET",
|
|
path="/status/sessions",
|
|
base_url=base_url,
|
|
url_variables=url_variables,
|
|
request=None,
|
|
request_body_required=False,
|
|
request_has_path_params=False,
|
|
request_has_query_params=True,
|
|
user_agent_header="user-agent",
|
|
accept_header_value="application/json",
|
|
http_headers=http_headers,
|
|
security=self.sdk_configuration.security,
|
|
timeout_ms=timeout_ms,
|
|
)
|
|
|
|
if retries == UNSET:
|
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
retries = self.sdk_configuration.retry_config
|
|
|
|
retry_config = None
|
|
if isinstance(retries, utils.RetryConfig):
|
|
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
|
|
http_res = await self.do_request_async(
|
|
hook_ctx=HookContext(
|
|
base_url=base_url or "",
|
|
operation_id="getSessions",
|
|
oauth2_scopes=[],
|
|
security_source=self.sdk_configuration.security,
|
|
),
|
|
request=req,
|
|
error_status_codes=["400", "401", "4XX", "5XX"],
|
|
retry_config=retry_config,
|
|
)
|
|
|
|
response_data: Any = None
|
|
if utils.match_response(http_res, "200", "application/json"):
|
|
return operations.GetSessionsResponse(
|
|
object=utils.unmarshal_json(
|
|
http_res.text, Optional[operations.GetSessionsResponseBody]
|
|
),
|
|
status_code=http_res.status_code,
|
|
content_type=http_res.headers.get("Content-Type") or "",
|
|
raw_response=http_res,
|
|
)
|
|
if utils.match_response(http_res, "400", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetSessionsBadRequestData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetSessionsBadRequest(data=response_data)
|
|
if utils.match_response(http_res, "401", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetSessionsUnauthorizedData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetSessionsUnauthorized(data=response_data)
|
|
if utils.match_response(http_res, "4XX", "*"):
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
if utils.match_response(http_res, "5XX", "*"):
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
|
|
content_type = http_res.headers.get("Content-Type")
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
http_res.status_code,
|
|
http_res_text,
|
|
http_res,
|
|
)
|
|
|
|
def get_session_history(
|
|
self,
|
|
*,
|
|
sort: Optional[str] = None,
|
|
account_id: Optional[int] = None,
|
|
filter_: Optional[
|
|
Union[operations.QueryParamFilter, operations.QueryParamFilterTypedDict]
|
|
] = None,
|
|
library_section_id: Optional[int] = None,
|
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
server_url: Optional[str] = None,
|
|
timeout_ms: Optional[int] = None,
|
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
) -> operations.GetSessionHistoryResponse:
|
|
r"""Get Session History
|
|
|
|
This will Retrieve a listing of all history views.
|
|
|
|
:param sort: Sorts the results by the specified field followed by the direction (asc, desc)
|
|
:param account_id: Filter results by those that are related to a specific users id
|
|
:param filter_: Filters content by field and direction/equality (Unknown if viewedAt is the only supported column)
|
|
:param library_section_id: Filters the results based on the id of a valid library section
|
|
:param retries: Override the default retry configuration for this method
|
|
:param server_url: Override the default server URL for this method
|
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
:param http_headers: Additional headers to set or replace on requests.
|
|
"""
|
|
base_url = None
|
|
url_variables = None
|
|
if timeout_ms is None:
|
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
|
|
if server_url is not None:
|
|
base_url = server_url
|
|
else:
|
|
base_url = self._get_url(base_url, url_variables)
|
|
|
|
request = operations.GetSessionHistoryRequest(
|
|
sort=sort,
|
|
account_id=account_id,
|
|
filter_=utils.get_pydantic_model(
|
|
filter_, Optional[operations.QueryParamFilter]
|
|
),
|
|
library_section_id=library_section_id,
|
|
)
|
|
|
|
req = self._build_request(
|
|
method="GET",
|
|
path="/status/sessions/history/all",
|
|
base_url=base_url,
|
|
url_variables=url_variables,
|
|
request=request,
|
|
request_body_required=False,
|
|
request_has_path_params=False,
|
|
request_has_query_params=True,
|
|
user_agent_header="user-agent",
|
|
accept_header_value="application/json",
|
|
http_headers=http_headers,
|
|
security=self.sdk_configuration.security,
|
|
timeout_ms=timeout_ms,
|
|
)
|
|
|
|
if retries == UNSET:
|
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
retries = self.sdk_configuration.retry_config
|
|
|
|
retry_config = None
|
|
if isinstance(retries, utils.RetryConfig):
|
|
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
|
|
http_res = self.do_request(
|
|
hook_ctx=HookContext(
|
|
base_url=base_url or "",
|
|
operation_id="getSessionHistory",
|
|
oauth2_scopes=[],
|
|
security_source=self.sdk_configuration.security,
|
|
),
|
|
request=req,
|
|
error_status_codes=["400", "401", "4XX", "5XX"],
|
|
retry_config=retry_config,
|
|
)
|
|
|
|
response_data: Any = None
|
|
if utils.match_response(http_res, "200", "application/json"):
|
|
return operations.GetSessionHistoryResponse(
|
|
object=utils.unmarshal_json(
|
|
http_res.text, Optional[operations.GetSessionHistoryResponseBody]
|
|
),
|
|
status_code=http_res.status_code,
|
|
content_type=http_res.headers.get("Content-Type") or "",
|
|
raw_response=http_res,
|
|
)
|
|
if utils.match_response(http_res, "400", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetSessionHistoryBadRequestData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetSessionHistoryBadRequest(data=response_data)
|
|
if utils.match_response(http_res, "401", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetSessionHistoryUnauthorizedData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetSessionHistoryUnauthorized(data=response_data)
|
|
if utils.match_response(http_res, "4XX", "*"):
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
if utils.match_response(http_res, "5XX", "*"):
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
|
|
content_type = http_res.headers.get("Content-Type")
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
http_res.status_code,
|
|
http_res_text,
|
|
http_res,
|
|
)
|
|
|
|
async def get_session_history_async(
|
|
self,
|
|
*,
|
|
sort: Optional[str] = None,
|
|
account_id: Optional[int] = None,
|
|
filter_: Optional[
|
|
Union[operations.QueryParamFilter, operations.QueryParamFilterTypedDict]
|
|
] = None,
|
|
library_section_id: Optional[int] = None,
|
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
server_url: Optional[str] = None,
|
|
timeout_ms: Optional[int] = None,
|
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
) -> operations.GetSessionHistoryResponse:
|
|
r"""Get Session History
|
|
|
|
This will Retrieve a listing of all history views.
|
|
|
|
:param sort: Sorts the results by the specified field followed by the direction (asc, desc)
|
|
:param account_id: Filter results by those that are related to a specific users id
|
|
:param filter_: Filters content by field and direction/equality (Unknown if viewedAt is the only supported column)
|
|
:param library_section_id: Filters the results based on the id of a valid library section
|
|
:param retries: Override the default retry configuration for this method
|
|
:param server_url: Override the default server URL for this method
|
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
:param http_headers: Additional headers to set or replace on requests.
|
|
"""
|
|
base_url = None
|
|
url_variables = None
|
|
if timeout_ms is None:
|
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
|
|
if server_url is not None:
|
|
base_url = server_url
|
|
else:
|
|
base_url = self._get_url(base_url, url_variables)
|
|
|
|
request = operations.GetSessionHistoryRequest(
|
|
sort=sort,
|
|
account_id=account_id,
|
|
filter_=utils.get_pydantic_model(
|
|
filter_, Optional[operations.QueryParamFilter]
|
|
),
|
|
library_section_id=library_section_id,
|
|
)
|
|
|
|
req = self._build_request_async(
|
|
method="GET",
|
|
path="/status/sessions/history/all",
|
|
base_url=base_url,
|
|
url_variables=url_variables,
|
|
request=request,
|
|
request_body_required=False,
|
|
request_has_path_params=False,
|
|
request_has_query_params=True,
|
|
user_agent_header="user-agent",
|
|
accept_header_value="application/json",
|
|
http_headers=http_headers,
|
|
security=self.sdk_configuration.security,
|
|
timeout_ms=timeout_ms,
|
|
)
|
|
|
|
if retries == UNSET:
|
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
retries = self.sdk_configuration.retry_config
|
|
|
|
retry_config = None
|
|
if isinstance(retries, utils.RetryConfig):
|
|
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
|
|
http_res = await self.do_request_async(
|
|
hook_ctx=HookContext(
|
|
base_url=base_url or "",
|
|
operation_id="getSessionHistory",
|
|
oauth2_scopes=[],
|
|
security_source=self.sdk_configuration.security,
|
|
),
|
|
request=req,
|
|
error_status_codes=["400", "401", "4XX", "5XX"],
|
|
retry_config=retry_config,
|
|
)
|
|
|
|
response_data: Any = None
|
|
if utils.match_response(http_res, "200", "application/json"):
|
|
return operations.GetSessionHistoryResponse(
|
|
object=utils.unmarshal_json(
|
|
http_res.text, Optional[operations.GetSessionHistoryResponseBody]
|
|
),
|
|
status_code=http_res.status_code,
|
|
content_type=http_res.headers.get("Content-Type") or "",
|
|
raw_response=http_res,
|
|
)
|
|
if utils.match_response(http_res, "400", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetSessionHistoryBadRequestData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetSessionHistoryBadRequest(data=response_data)
|
|
if utils.match_response(http_res, "401", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetSessionHistoryUnauthorizedData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetSessionHistoryUnauthorized(data=response_data)
|
|
if utils.match_response(http_res, "4XX", "*"):
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
if utils.match_response(http_res, "5XX", "*"):
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
|
|
content_type = http_res.headers.get("Content-Type")
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
http_res.status_code,
|
|
http_res_text,
|
|
http_res,
|
|
)
|
|
|
|
def get_transcode_sessions(
|
|
self,
|
|
*,
|
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
server_url: Optional[str] = None,
|
|
timeout_ms: Optional[int] = None,
|
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
) -> operations.GetTranscodeSessionsResponse:
|
|
r"""Get Transcode Sessions
|
|
|
|
Get Transcode Sessions
|
|
|
|
:param retries: Override the default retry configuration for this method
|
|
:param server_url: Override the default server URL for this method
|
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
:param http_headers: Additional headers to set or replace on requests.
|
|
"""
|
|
base_url = None
|
|
url_variables = None
|
|
if timeout_ms is None:
|
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
|
|
if server_url is not None:
|
|
base_url = server_url
|
|
else:
|
|
base_url = self._get_url(base_url, url_variables)
|
|
req = self._build_request(
|
|
method="GET",
|
|
path="/transcode/sessions",
|
|
base_url=base_url,
|
|
url_variables=url_variables,
|
|
request=None,
|
|
request_body_required=False,
|
|
request_has_path_params=False,
|
|
request_has_query_params=True,
|
|
user_agent_header="user-agent",
|
|
accept_header_value="application/json",
|
|
http_headers=http_headers,
|
|
security=self.sdk_configuration.security,
|
|
timeout_ms=timeout_ms,
|
|
)
|
|
|
|
if retries == UNSET:
|
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
retries = self.sdk_configuration.retry_config
|
|
|
|
retry_config = None
|
|
if isinstance(retries, utils.RetryConfig):
|
|
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
|
|
http_res = self.do_request(
|
|
hook_ctx=HookContext(
|
|
base_url=base_url or "",
|
|
operation_id="getTranscodeSessions",
|
|
oauth2_scopes=[],
|
|
security_source=self.sdk_configuration.security,
|
|
),
|
|
request=req,
|
|
error_status_codes=["400", "401", "4XX", "5XX"],
|
|
retry_config=retry_config,
|
|
)
|
|
|
|
response_data: Any = None
|
|
if utils.match_response(http_res, "200", "application/json"):
|
|
return operations.GetTranscodeSessionsResponse(
|
|
object=utils.unmarshal_json(
|
|
http_res.text, Optional[operations.GetTranscodeSessionsResponseBody]
|
|
),
|
|
status_code=http_res.status_code,
|
|
content_type=http_res.headers.get("Content-Type") or "",
|
|
raw_response=http_res,
|
|
)
|
|
if utils.match_response(http_res, "400", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetTranscodeSessionsBadRequestData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetTranscodeSessionsBadRequest(data=response_data)
|
|
if utils.match_response(http_res, "401", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetTranscodeSessionsUnauthorizedData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetTranscodeSessionsUnauthorized(data=response_data)
|
|
if utils.match_response(http_res, "4XX", "*"):
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
if utils.match_response(http_res, "5XX", "*"):
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
|
|
content_type = http_res.headers.get("Content-Type")
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
http_res.status_code,
|
|
http_res_text,
|
|
http_res,
|
|
)
|
|
|
|
async def get_transcode_sessions_async(
|
|
self,
|
|
*,
|
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
server_url: Optional[str] = None,
|
|
timeout_ms: Optional[int] = None,
|
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
) -> operations.GetTranscodeSessionsResponse:
|
|
r"""Get Transcode Sessions
|
|
|
|
Get Transcode Sessions
|
|
|
|
:param retries: Override the default retry configuration for this method
|
|
:param server_url: Override the default server URL for this method
|
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
:param http_headers: Additional headers to set or replace on requests.
|
|
"""
|
|
base_url = None
|
|
url_variables = None
|
|
if timeout_ms is None:
|
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
|
|
if server_url is not None:
|
|
base_url = server_url
|
|
else:
|
|
base_url = self._get_url(base_url, url_variables)
|
|
req = self._build_request_async(
|
|
method="GET",
|
|
path="/transcode/sessions",
|
|
base_url=base_url,
|
|
url_variables=url_variables,
|
|
request=None,
|
|
request_body_required=False,
|
|
request_has_path_params=False,
|
|
request_has_query_params=True,
|
|
user_agent_header="user-agent",
|
|
accept_header_value="application/json",
|
|
http_headers=http_headers,
|
|
security=self.sdk_configuration.security,
|
|
timeout_ms=timeout_ms,
|
|
)
|
|
|
|
if retries == UNSET:
|
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
retries = self.sdk_configuration.retry_config
|
|
|
|
retry_config = None
|
|
if isinstance(retries, utils.RetryConfig):
|
|
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
|
|
http_res = await self.do_request_async(
|
|
hook_ctx=HookContext(
|
|
base_url=base_url or "",
|
|
operation_id="getTranscodeSessions",
|
|
oauth2_scopes=[],
|
|
security_source=self.sdk_configuration.security,
|
|
),
|
|
request=req,
|
|
error_status_codes=["400", "401", "4XX", "5XX"],
|
|
retry_config=retry_config,
|
|
)
|
|
|
|
response_data: Any = None
|
|
if utils.match_response(http_res, "200", "application/json"):
|
|
return operations.GetTranscodeSessionsResponse(
|
|
object=utils.unmarshal_json(
|
|
http_res.text, Optional[operations.GetTranscodeSessionsResponseBody]
|
|
),
|
|
status_code=http_res.status_code,
|
|
content_type=http_res.headers.get("Content-Type") or "",
|
|
raw_response=http_res,
|
|
)
|
|
if utils.match_response(http_res, "400", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetTranscodeSessionsBadRequestData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetTranscodeSessionsBadRequest(data=response_data)
|
|
if utils.match_response(http_res, "401", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.GetTranscodeSessionsUnauthorizedData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.GetTranscodeSessionsUnauthorized(data=response_data)
|
|
if utils.match_response(http_res, "4XX", "*"):
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
if utils.match_response(http_res, "5XX", "*"):
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
|
|
content_type = http_res.headers.get("Content-Type")
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
http_res.status_code,
|
|
http_res_text,
|
|
http_res,
|
|
)
|
|
|
|
def stop_transcode_session(
|
|
self,
|
|
*,
|
|
session_key: str,
|
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
server_url: Optional[str] = None,
|
|
timeout_ms: Optional[int] = None,
|
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
) -> operations.StopTranscodeSessionResponse:
|
|
r"""Stop a Transcode Session
|
|
|
|
Stop a Transcode Session
|
|
|
|
:param session_key: the Key of the transcode session to stop
|
|
:param retries: Override the default retry configuration for this method
|
|
:param server_url: Override the default server URL for this method
|
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
:param http_headers: Additional headers to set or replace on requests.
|
|
"""
|
|
base_url = None
|
|
url_variables = None
|
|
if timeout_ms is None:
|
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
|
|
if server_url is not None:
|
|
base_url = server_url
|
|
else:
|
|
base_url = self._get_url(base_url, url_variables)
|
|
|
|
request = operations.StopTranscodeSessionRequest(
|
|
session_key=session_key,
|
|
)
|
|
|
|
req = self._build_request(
|
|
method="DELETE",
|
|
path="/transcode/sessions/{sessionKey}",
|
|
base_url=base_url,
|
|
url_variables=url_variables,
|
|
request=request,
|
|
request_body_required=False,
|
|
request_has_path_params=True,
|
|
request_has_query_params=True,
|
|
user_agent_header="user-agent",
|
|
accept_header_value="application/json",
|
|
http_headers=http_headers,
|
|
security=self.sdk_configuration.security,
|
|
timeout_ms=timeout_ms,
|
|
)
|
|
|
|
if retries == UNSET:
|
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
retries = self.sdk_configuration.retry_config
|
|
|
|
retry_config = None
|
|
if isinstance(retries, utils.RetryConfig):
|
|
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
|
|
http_res = self.do_request(
|
|
hook_ctx=HookContext(
|
|
base_url=base_url or "",
|
|
operation_id="stopTranscodeSession",
|
|
oauth2_scopes=[],
|
|
security_source=self.sdk_configuration.security,
|
|
),
|
|
request=req,
|
|
error_status_codes=["400", "401", "4XX", "5XX"],
|
|
retry_config=retry_config,
|
|
)
|
|
|
|
response_data: Any = None
|
|
if utils.match_response(http_res, "204", "*"):
|
|
return operations.StopTranscodeSessionResponse(
|
|
status_code=http_res.status_code,
|
|
content_type=http_res.headers.get("Content-Type") or "",
|
|
raw_response=http_res,
|
|
)
|
|
if utils.match_response(http_res, "400", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.StopTranscodeSessionBadRequestData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.StopTranscodeSessionBadRequest(data=response_data)
|
|
if utils.match_response(http_res, "401", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.StopTranscodeSessionUnauthorizedData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.StopTranscodeSessionUnauthorized(data=response_data)
|
|
if utils.match_response(http_res, "4XX", "*"):
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
if utils.match_response(http_res, "5XX", "*"):
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
|
|
content_type = http_res.headers.get("Content-Type")
|
|
http_res_text = utils.stream_to_text(http_res)
|
|
raise errors.SDKError(
|
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
http_res.status_code,
|
|
http_res_text,
|
|
http_res,
|
|
)
|
|
|
|
async def stop_transcode_session_async(
|
|
self,
|
|
*,
|
|
session_key: str,
|
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
server_url: Optional[str] = None,
|
|
timeout_ms: Optional[int] = None,
|
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
) -> operations.StopTranscodeSessionResponse:
|
|
r"""Stop a Transcode Session
|
|
|
|
Stop a Transcode Session
|
|
|
|
:param session_key: the Key of the transcode session to stop
|
|
:param retries: Override the default retry configuration for this method
|
|
:param server_url: Override the default server URL for this method
|
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
:param http_headers: Additional headers to set or replace on requests.
|
|
"""
|
|
base_url = None
|
|
url_variables = None
|
|
if timeout_ms is None:
|
|
timeout_ms = self.sdk_configuration.timeout_ms
|
|
|
|
if server_url is not None:
|
|
base_url = server_url
|
|
else:
|
|
base_url = self._get_url(base_url, url_variables)
|
|
|
|
request = operations.StopTranscodeSessionRequest(
|
|
session_key=session_key,
|
|
)
|
|
|
|
req = self._build_request_async(
|
|
method="DELETE",
|
|
path="/transcode/sessions/{sessionKey}",
|
|
base_url=base_url,
|
|
url_variables=url_variables,
|
|
request=request,
|
|
request_body_required=False,
|
|
request_has_path_params=True,
|
|
request_has_query_params=True,
|
|
user_agent_header="user-agent",
|
|
accept_header_value="application/json",
|
|
http_headers=http_headers,
|
|
security=self.sdk_configuration.security,
|
|
timeout_ms=timeout_ms,
|
|
)
|
|
|
|
if retries == UNSET:
|
|
if self.sdk_configuration.retry_config is not UNSET:
|
|
retries = self.sdk_configuration.retry_config
|
|
|
|
retry_config = None
|
|
if isinstance(retries, utils.RetryConfig):
|
|
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
|
|
http_res = await self.do_request_async(
|
|
hook_ctx=HookContext(
|
|
base_url=base_url or "",
|
|
operation_id="stopTranscodeSession",
|
|
oauth2_scopes=[],
|
|
security_source=self.sdk_configuration.security,
|
|
),
|
|
request=req,
|
|
error_status_codes=["400", "401", "4XX", "5XX"],
|
|
retry_config=retry_config,
|
|
)
|
|
|
|
response_data: Any = None
|
|
if utils.match_response(http_res, "204", "*"):
|
|
return operations.StopTranscodeSessionResponse(
|
|
status_code=http_res.status_code,
|
|
content_type=http_res.headers.get("Content-Type") or "",
|
|
raw_response=http_res,
|
|
)
|
|
if utils.match_response(http_res, "400", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.StopTranscodeSessionBadRequestData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.StopTranscodeSessionBadRequest(data=response_data)
|
|
if utils.match_response(http_res, "401", "application/json"):
|
|
response_data = utils.unmarshal_json(
|
|
http_res.text, errors.StopTranscodeSessionUnauthorizedData
|
|
)
|
|
response_data.raw_response = http_res
|
|
raise errors.StopTranscodeSessionUnauthorized(data=response_data)
|
|
if utils.match_response(http_res, "4XX", "*"):
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
if utils.match_response(http_res, "5XX", "*"):
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
)
|
|
|
|
content_type = http_res.headers.get("Content-Type")
|
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
raise errors.SDKError(
|
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
http_res.status_code,
|
|
http_res_text,
|
|
http_res,
|
|
)
|