mirror of
https://github.com/LukeHagar/plexpy.git
synced 2025-12-06 20:57:46 +00:00
Regenerated with pythonv2 and newest spec
This commit is contained in:
788
src/plex_api_client/sessions.py
Normal file
788
src/plex_api_client/sessions.py
Normal file
@@ -0,0 +1,788 @@
|
||||
"""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, 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,
|
||||
) -> 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
|
||||
"""
|
||||
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
|
||||
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",
|
||||
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(
|
||||
operation_id="getSessions",
|
||||
oauth2_scopes=[],
|
||||
security_source=self.sdk_configuration.security,
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "4XX", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
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"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetSessionsSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetSessionsSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
||||
raise errors.SDKError(
|
||||
"API error occurred", http_res.status_code, http_res.text, http_res
|
||||
)
|
||||
|
||||
content_type = http_res.headers.get("Content-Type")
|
||||
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,
|
||||
) -> 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
|
||||
"""
|
||||
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
|
||||
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",
|
||||
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(
|
||||
operation_id="getSessions",
|
||||
oauth2_scopes=[],
|
||||
security_source=self.sdk_configuration.security,
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "4XX", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
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"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetSessionsSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetSessionsSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
||||
raise errors.SDKError(
|
||||
"API error occurred", http_res.status_code, http_res.text, http_res
|
||||
)
|
||||
|
||||
content_type = http_res.headers.get("Content-Type")
|
||||
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,
|
||||
) -> 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
|
||||
"""
|
||||
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
|
||||
|
||||
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",
|
||||
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(
|
||||
operation_id="getSessionHistory",
|
||||
oauth2_scopes=[],
|
||||
security_source=self.sdk_configuration.security,
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "4XX", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
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"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetSessionHistoryResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetSessionHistoryResponseBody(data=data)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetSessionHistorySessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetSessionHistorySessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
||||
raise errors.SDKError(
|
||||
"API error occurred", http_res.status_code, http_res.text, http_res
|
||||
)
|
||||
|
||||
content_type = http_res.headers.get("Content-Type")
|
||||
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,
|
||||
) -> 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
|
||||
"""
|
||||
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
|
||||
|
||||
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",
|
||||
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(
|
||||
operation_id="getSessionHistory",
|
||||
oauth2_scopes=[],
|
||||
security_source=self.sdk_configuration.security,
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "4XX", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
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"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetSessionHistoryResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetSessionHistoryResponseBody(data=data)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetSessionHistorySessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetSessionHistorySessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
||||
raise errors.SDKError(
|
||||
"API error occurred", http_res.status_code, http_res.text, http_res
|
||||
)
|
||||
|
||||
content_type = http_res.headers.get("Content-Type")
|
||||
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,
|
||||
) -> 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
|
||||
"""
|
||||
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
|
||||
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",
|
||||
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(
|
||||
operation_id="getTranscodeSessions",
|
||||
oauth2_scopes=[],
|
||||
security_source=self.sdk_configuration.security,
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "4XX", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
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"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetTranscodeSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetTranscodeSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetTranscodeSessionsSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetTranscodeSessionsSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
||||
raise errors.SDKError(
|
||||
"API error occurred", http_res.status_code, http_res.text, http_res
|
||||
)
|
||||
|
||||
content_type = http_res.headers.get("Content-Type")
|
||||
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,
|
||||
) -> 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
|
||||
"""
|
||||
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
|
||||
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",
|
||||
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(
|
||||
operation_id="getTranscodeSessions",
|
||||
oauth2_scopes=[],
|
||||
security_source=self.sdk_configuration.security,
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "4XX", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
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"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetTranscodeSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetTranscodeSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.GetTranscodeSessionsSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.GetTranscodeSessionsSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
||||
raise errors.SDKError(
|
||||
"API error occurred", http_res.status_code, http_res.text, http_res
|
||||
)
|
||||
|
||||
content_type = http_res.headers.get("Content-Type")
|
||||
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,
|
||||
) -> 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
|
||||
"""
|
||||
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
|
||||
|
||||
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",
|
||||
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(
|
||||
operation_id="stopTranscodeSession",
|
||||
oauth2_scopes=[],
|
||||
security_source=self.sdk_configuration.security,
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "4XX", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
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"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.StopTranscodeSessionResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.StopTranscodeSessionResponseBody(data=data)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.StopTranscodeSessionSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.StopTranscodeSessionSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
||||
raise errors.SDKError(
|
||||
"API error occurred", http_res.status_code, http_res.text, http_res
|
||||
)
|
||||
|
||||
content_type = http_res.headers.get("Content-Type")
|
||||
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,
|
||||
) -> 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
|
||||
"""
|
||||
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
|
||||
|
||||
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",
|
||||
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(
|
||||
operation_id="stopTranscodeSession",
|
||||
oauth2_scopes=[],
|
||||
security_source=self.sdk_configuration.security,
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "4XX", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
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"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.StopTranscodeSessionResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.StopTranscodeSessionResponseBody(data=data)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
data = utils.unmarshal_json(
|
||||
http_res.text, errors.StopTranscodeSessionSessionsResponseBodyData
|
||||
)
|
||||
data.raw_response = http_res
|
||||
raise errors.StopTranscodeSessionSessionsResponseBody(data=data)
|
||||
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
||||
raise errors.SDKError(
|
||||
"API error occurred", http_res.status_code, http_res.text, http_res
|
||||
)
|
||||
|
||||
content_type = http_res.headers.get("Content-Type")
|
||||
raise errors.SDKError(
|
||||
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
||||
http_res.status_code,
|
||||
http_res.text,
|
||||
http_res,
|
||||
)
|
||||
Reference in New Issue
Block a user