# coding: utf-8

"""
    BioT Device Service

    APIs document (version: 8.9.1)

    The version of the OpenAPI document: 8.9.1
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501

import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from pydantic import Field, StrictStr, field_validator
from typing import Optional
from typing_extensions import Annotated
from uuid import UUID
from biotmed_device_sdk.models.create_session_by_usage_type_request_v2 import CreateSessionByUsageTypeRequestV2
from biotmed_device_sdk.models.create_session_request_v2 import CreateSessionRequestV2
from biotmed_device_sdk.models.delete_orphan_sessions_response import DeleteOrphanSessionsResponse
from biotmed_device_sdk.models.search_request_v2 import SearchRequestV2
from biotmed_device_sdk.models.search_response_device_sessions_response_v2 import SearchResponseDeviceSessionsResponseV2
from biotmed_device_sdk.models.search_response_session_response_v2 import SearchResponseSessionResponseV2
from biotmed_device_sdk.models.session_response_v2 import SessionResponseV2
from biotmed_device_sdk.models.update_session_request_v2 import UpdateSessionRequestV2

from biotmed_device_sdk.api_client import ApiClient, RequestSerialized
from biotmed_device_sdk.api_response import ApiResponse
from biotmed_device_sdk.rest import RESTResponseType


class UsageSessionAPIApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client


    @validate_call
    def create_session(
        self,
        create_session_request_v2: CreateSessionRequestV2,
        device_id: StrictStr,
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> SessionResponseV2:
        """Create a new Usage Session by Template id

        Create a new Usage Session by Template id    If patient is null in the request, the patient id will be read from the device entity  (*)This parameter is mandatory only if its optional parent attribute is defined. Click <a href=\"https://docs.biot-med.com/docs/biot-rest-api#api-optional-parameters\" target=\"_blank\">here</a> for more information.  Request Body Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Regular custom attribute 1 value|| |&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Regular custom attribute N value|| |_configuration|object|false|An object that holds the entity configuration attributes|| |_configuration.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Configuration custom attribute 1 value|| |_configuration.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Configuration custom attribute N value|| |_endTime|string|false|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_name|string|false|The name of the session|| |_patient|object|false||| |_patient.id|string|true(*)|A UUID formatted string|3fa85f64-5717-4562-b3fc-2c963f66afa6| |_startTime|string|true|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_state|string|true|The Sessions state Values:ACTIVE,DONE,PAUSED,ACTIVATING,PAUSING,RESUMING,STOPPING|ACTIVE| |_summary|object|false||| |_summary.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Summary custom attribute 1 value|| |_summary.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Summary custom attribute N value|| |_summary._stopReason|string|false|The reason the session was stopped|Manual Stop| |_summary._stopReasonCode|string|false|The code of the stop reason Values:COMPLETION,GENERAL_DEVICE_ERROR,TIMEOUT|COMPLETION| |_templateId|string|true|The id of a template that is configured in the settings service.|3fa85f64-5717-4562-b3fc-2c963f66afa6| Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null||   This API requires **PROTECTED_API** permission(s).  

        :param create_session_request_v2: (required)
        :type create_session_request_v2: CreateSessionRequestV2
        :param device_id: (required)
        :type device_id: str
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._create_session_serialize(
            create_session_request_v2=create_session_request_v2,
            device_id=device_id,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '201': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def create_session_with_http_info(
        self,
        create_session_request_v2: CreateSessionRequestV2,
        device_id: StrictStr,
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[SessionResponseV2]:
        """Create a new Usage Session by Template id

        Create a new Usage Session by Template id    If patient is null in the request, the patient id will be read from the device entity  (*)This parameter is mandatory only if its optional parent attribute is defined. Click <a href=\"https://docs.biot-med.com/docs/biot-rest-api#api-optional-parameters\" target=\"_blank\">here</a> for more information.  Request Body Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Regular custom attribute 1 value|| |&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Regular custom attribute N value|| |_configuration|object|false|An object that holds the entity configuration attributes|| |_configuration.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Configuration custom attribute 1 value|| |_configuration.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Configuration custom attribute N value|| |_endTime|string|false|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_name|string|false|The name of the session|| |_patient|object|false||| |_patient.id|string|true(*)|A UUID formatted string|3fa85f64-5717-4562-b3fc-2c963f66afa6| |_startTime|string|true|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_state|string|true|The Sessions state Values:ACTIVE,DONE,PAUSED,ACTIVATING,PAUSING,RESUMING,STOPPING|ACTIVE| |_summary|object|false||| |_summary.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Summary custom attribute 1 value|| |_summary.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Summary custom attribute N value|| |_summary._stopReason|string|false|The reason the session was stopped|Manual Stop| |_summary._stopReasonCode|string|false|The code of the stop reason Values:COMPLETION,GENERAL_DEVICE_ERROR,TIMEOUT|COMPLETION| |_templateId|string|true|The id of a template that is configured in the settings service.|3fa85f64-5717-4562-b3fc-2c963f66afa6| Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null||   This API requires **PROTECTED_API** permission(s).  

        :param create_session_request_v2: (required)
        :type create_session_request_v2: CreateSessionRequestV2
        :param device_id: (required)
        :type device_id: str
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._create_session_serialize(
            create_session_request_v2=create_session_request_v2,
            device_id=device_id,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '201': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def create_session_without_preload_content(
        self,
        create_session_request_v2: CreateSessionRequestV2,
        device_id: StrictStr,
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Create a new Usage Session by Template id

        Create a new Usage Session by Template id    If patient is null in the request, the patient id will be read from the device entity  (*)This parameter is mandatory only if its optional parent attribute is defined. Click <a href=\"https://docs.biot-med.com/docs/biot-rest-api#api-optional-parameters\" target=\"_blank\">here</a> for more information.  Request Body Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Regular custom attribute 1 value|| |&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Regular custom attribute N value|| |_configuration|object|false|An object that holds the entity configuration attributes|| |_configuration.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Configuration custom attribute 1 value|| |_configuration.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Configuration custom attribute N value|| |_endTime|string|false|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_name|string|false|The name of the session|| |_patient|object|false||| |_patient.id|string|true(*)|A UUID formatted string|3fa85f64-5717-4562-b3fc-2c963f66afa6| |_startTime|string|true|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_state|string|true|The Sessions state Values:ACTIVE,DONE,PAUSED,ACTIVATING,PAUSING,RESUMING,STOPPING|ACTIVE| |_summary|object|false||| |_summary.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Summary custom attribute 1 value|| |_summary.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Summary custom attribute N value|| |_summary._stopReason|string|false|The reason the session was stopped|Manual Stop| |_summary._stopReasonCode|string|false|The code of the stop reason Values:COMPLETION,GENERAL_DEVICE_ERROR,TIMEOUT|COMPLETION| |_templateId|string|true|The id of a template that is configured in the settings service.|3fa85f64-5717-4562-b3fc-2c963f66afa6| Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null||   This API requires **PROTECTED_API** permission(s).  

        :param create_session_request_v2: (required)
        :type create_session_request_v2: CreateSessionRequestV2
        :param device_id: (required)
        :type device_id: str
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._create_session_serialize(
            create_session_request_v2=create_session_request_v2,
            device_id=device_id,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '201': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _create_session_serialize(
        self,
        create_session_request_v2,
        device_id,
        x_execution_mode,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if device_id is not None:
            _path_params['deviceId'] = device_id
        # process the query parameters
        # process the header parameters
        if x_execution_mode is not None:
            _header_params['x-execution-mode'] = x_execution_mode
        # process the form parameters
        # process the body parameter
        if create_session_request_v2 is not None:
            _body_params = create_session_request_v2


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )

        # set the HTTP header `Content-Type`
        if _content_type:
            _header_params['Content-Type'] = _content_type
        else:
            _default_content_type = (
                self.api_client.select_header_content_type(
                    [
                        'application/json'
                    ]
                )
            )
            if _default_content_type is not None:
                _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='POST',
            resource_path='/v1/devices/{deviceId}/usage-sessions',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def create_session_by_usage_type(
        self,
        create_session_by_usage_type_request_v2: CreateSessionByUsageTypeRequestV2,
        device_id: StrictStr,
        usage_type: StrictStr,
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> SessionResponseV2:
        """Create a new Usage Session by Template name

        Create a new Usage Session by Template name    If patient is null in the request, the patient id will be read from the device entity.  (*)This parameter is mandatory only if its optional parent attribute is defined. Click <a href=\"https://docs.biot-med.com/docs/biot-rest-api#api-optional-parameters\" target=\"_blank\">here</a> for more information.  Request Body Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Regular custom attribute 1 value|| |&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Regular custom attribute N value|| |_configuration|object|false|An object that holds the entity configuration attributes|| |_configuration.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Configuration custom attribute 1 value|| |_configuration.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Configuration custom attribute N value|| |_endTime|string|false|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_name|string|false|The name of the session|| |_patient|object|false||| |_patient.id|string|true(*)|A UUID formatted string|3fa85f64-5717-4562-b3fc-2c963f66afa6| |_startTime|string|true|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_state|string|true|The Sessions state Values:ACTIVE,DONE,PAUSED,ACTIVATING,PAUSING,RESUMING,STOPPING|ACTIVE| |_summary|object|false||| |_summary.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Summary custom attribute 1 value|| |_summary.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Summary custom attribute N value|| |_summary._stopReason|string|false|The reason the session was stopped|Manual Stop| |_summary._stopReasonCode|string|false|The code of the stop reason Values:COMPLETION,GENERAL_DEVICE_ERROR,TIMEOUT|COMPLETION| Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |usageType|string|true|null||   This API requires **PROTECTED_API** permission(s).  

        :param create_session_by_usage_type_request_v2: (required)
        :type create_session_by_usage_type_request_v2: CreateSessionByUsageTypeRequestV2
        :param device_id: (required)
        :type device_id: str
        :param usage_type: (required)
        :type usage_type: str
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._create_session_by_usage_type_serialize(
            create_session_by_usage_type_request_v2=create_session_by_usage_type_request_v2,
            device_id=device_id,
            usage_type=usage_type,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '201': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def create_session_by_usage_type_with_http_info(
        self,
        create_session_by_usage_type_request_v2: CreateSessionByUsageTypeRequestV2,
        device_id: StrictStr,
        usage_type: StrictStr,
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[SessionResponseV2]:
        """Create a new Usage Session by Template name

        Create a new Usage Session by Template name    If patient is null in the request, the patient id will be read from the device entity.  (*)This parameter is mandatory only if its optional parent attribute is defined. Click <a href=\"https://docs.biot-med.com/docs/biot-rest-api#api-optional-parameters\" target=\"_blank\">here</a> for more information.  Request Body Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Regular custom attribute 1 value|| |&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Regular custom attribute N value|| |_configuration|object|false|An object that holds the entity configuration attributes|| |_configuration.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Configuration custom attribute 1 value|| |_configuration.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Configuration custom attribute N value|| |_endTime|string|false|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_name|string|false|The name of the session|| |_patient|object|false||| |_patient.id|string|true(*)|A UUID formatted string|3fa85f64-5717-4562-b3fc-2c963f66afa6| |_startTime|string|true|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_state|string|true|The Sessions state Values:ACTIVE,DONE,PAUSED,ACTIVATING,PAUSING,RESUMING,STOPPING|ACTIVE| |_summary|object|false||| |_summary.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Summary custom attribute 1 value|| |_summary.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Summary custom attribute N value|| |_summary._stopReason|string|false|The reason the session was stopped|Manual Stop| |_summary._stopReasonCode|string|false|The code of the stop reason Values:COMPLETION,GENERAL_DEVICE_ERROR,TIMEOUT|COMPLETION| Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |usageType|string|true|null||   This API requires **PROTECTED_API** permission(s).  

        :param create_session_by_usage_type_request_v2: (required)
        :type create_session_by_usage_type_request_v2: CreateSessionByUsageTypeRequestV2
        :param device_id: (required)
        :type device_id: str
        :param usage_type: (required)
        :type usage_type: str
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._create_session_by_usage_type_serialize(
            create_session_by_usage_type_request_v2=create_session_by_usage_type_request_v2,
            device_id=device_id,
            usage_type=usage_type,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '201': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def create_session_by_usage_type_without_preload_content(
        self,
        create_session_by_usage_type_request_v2: CreateSessionByUsageTypeRequestV2,
        device_id: StrictStr,
        usage_type: StrictStr,
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Create a new Usage Session by Template name

        Create a new Usage Session by Template name    If patient is null in the request, the patient id will be read from the device entity.  (*)This parameter is mandatory only if its optional parent attribute is defined. Click <a href=\"https://docs.biot-med.com/docs/biot-rest-api#api-optional-parameters\" target=\"_blank\">here</a> for more information.  Request Body Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Regular custom attribute 1 value|| |&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Regular custom attribute N value|| |_configuration|object|false|An object that holds the entity configuration attributes|| |_configuration.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Configuration custom attribute 1 value|| |_configuration.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Configuration custom attribute N value|| |_endTime|string|false|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_name|string|false|The name of the session|| |_patient|object|false||| |_patient.id|string|true(*)|A UUID formatted string|3fa85f64-5717-4562-b3fc-2c963f66afa6| |_startTime|string|true|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_state|string|true|The Sessions state Values:ACTIVE,DONE,PAUSED,ACTIVATING,PAUSING,RESUMING,STOPPING|ACTIVE| |_summary|object|false||| |_summary.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Summary custom attribute 1 value|| |_summary.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Summary custom attribute N value|| |_summary._stopReason|string|false|The reason the session was stopped|Manual Stop| |_summary._stopReasonCode|string|false|The code of the stop reason Values:COMPLETION,GENERAL_DEVICE_ERROR,TIMEOUT|COMPLETION| Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |usageType|string|true|null||   This API requires **PROTECTED_API** permission(s).  

        :param create_session_by_usage_type_request_v2: (required)
        :type create_session_by_usage_type_request_v2: CreateSessionByUsageTypeRequestV2
        :param device_id: (required)
        :type device_id: str
        :param usage_type: (required)
        :type usage_type: str
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._create_session_by_usage_type_serialize(
            create_session_by_usage_type_request_v2=create_session_by_usage_type_request_v2,
            device_id=device_id,
            usage_type=usage_type,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '201': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _create_session_by_usage_type_serialize(
        self,
        create_session_by_usage_type_request_v2,
        device_id,
        usage_type,
        x_execution_mode,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if device_id is not None:
            _path_params['deviceId'] = device_id
        if usage_type is not None:
            _path_params['usageType'] = usage_type
        # process the query parameters
        # process the header parameters
        if x_execution_mode is not None:
            _header_params['x-execution-mode'] = x_execution_mode
        # process the form parameters
        # process the body parameter
        if create_session_by_usage_type_request_v2 is not None:
            _body_params = create_session_by_usage_type_request_v2


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )

        # set the HTTP header `Content-Type`
        if _content_type:
            _header_params['Content-Type'] = _content_type
        else:
            _default_content_type = (
                self.api_client.select_header_content_type(
                    [
                        'application/json'
                    ]
                )
            )
            if _default_content_type is not None:
                _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='POST',
            resource_path='/v1/devices/{deviceId}/usage-sessions/usage-type/{usageType}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def delete_orphan_sessions(
        self,
        delete_orphan_sessions_enum: StrictStr,
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> DeleteOrphanSessionsResponse:
        """Delete Usage Session

        Delete Usage Session    This api will delete up to 500 sessions that have a null value in the requested field. Supported Values: DEVICE, PATIENT  Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deleteOrphanSessionsEnum|string|true|null||   This API requires **SESSION_DELETE_ORPHANS** permission(s).  

        :param delete_orphan_sessions_enum: (required)
        :type delete_orphan_sessions_enum: str
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_orphan_sessions_serialize(
            delete_orphan_sessions_enum=delete_orphan_sessions_enum,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "DeleteOrphanSessionsResponse",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '504': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def delete_orphan_sessions_with_http_info(
        self,
        delete_orphan_sessions_enum: StrictStr,
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[DeleteOrphanSessionsResponse]:
        """Delete Usage Session

        Delete Usage Session    This api will delete up to 500 sessions that have a null value in the requested field. Supported Values: DEVICE, PATIENT  Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deleteOrphanSessionsEnum|string|true|null||   This API requires **SESSION_DELETE_ORPHANS** permission(s).  

        :param delete_orphan_sessions_enum: (required)
        :type delete_orphan_sessions_enum: str
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_orphan_sessions_serialize(
            delete_orphan_sessions_enum=delete_orphan_sessions_enum,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "DeleteOrphanSessionsResponse",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '504': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def delete_orphan_sessions_without_preload_content(
        self,
        delete_orphan_sessions_enum: StrictStr,
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Delete Usage Session

        Delete Usage Session    This api will delete up to 500 sessions that have a null value in the requested field. Supported Values: DEVICE, PATIENT  Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deleteOrphanSessionsEnum|string|true|null||   This API requires **SESSION_DELETE_ORPHANS** permission(s).  

        :param delete_orphan_sessions_enum: (required)
        :type delete_orphan_sessions_enum: str
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_orphan_sessions_serialize(
            delete_orphan_sessions_enum=delete_orphan_sessions_enum,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "DeleteOrphanSessionsResponse",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '504': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _delete_orphan_sessions_serialize(
        self,
        delete_orphan_sessions_enum,
        x_execution_mode,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if delete_orphan_sessions_enum is not None:
            _path_params['deleteOrphanSessionsEnum'] = delete_orphan_sessions_enum
        # process the query parameters
        # process the header parameters
        if x_execution_mode is not None:
            _header_params['x-execution-mode'] = x_execution_mode
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='DELETE',
            resource_path='/v1/devices/usage-sessions/maintenance/orphans/{deleteOrphanSessionsEnum}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def delete_session(
        self,
        device_id: StrictStr,
        id: Annotated[UUID, Field(description="Usage Session ID that needs to be deleted")],
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> None:
        """Delete Usage Session

        Delete Usage Session    Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |id|string|true|Usage Session ID that needs to be deleted|3fa85f64-5717-4562-b3fc-2c963f66afa6|   This API requires **PROTECTED_API** permission(s).  

        :param device_id: (required)
        :type device_id: str
        :param id: Usage Session ID that needs to be deleted (required)
        :type id: UUID
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_session_serialize(
            device_id=device_id,
            id=id,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '204': None,
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def delete_session_with_http_info(
        self,
        device_id: StrictStr,
        id: Annotated[UUID, Field(description="Usage Session ID that needs to be deleted")],
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[None]:
        """Delete Usage Session

        Delete Usage Session    Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |id|string|true|Usage Session ID that needs to be deleted|3fa85f64-5717-4562-b3fc-2c963f66afa6|   This API requires **PROTECTED_API** permission(s).  

        :param device_id: (required)
        :type device_id: str
        :param id: Usage Session ID that needs to be deleted (required)
        :type id: UUID
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_session_serialize(
            device_id=device_id,
            id=id,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '204': None,
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def delete_session_without_preload_content(
        self,
        device_id: StrictStr,
        id: Annotated[UUID, Field(description="Usage Session ID that needs to be deleted")],
        x_execution_mode: Annotated[Optional[StrictStr], Field(description="X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). ")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Delete Usage Session

        Delete Usage Session    Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |id|string|true|Usage Session ID that needs to be deleted|3fa85f64-5717-4562-b3fc-2c963f66afa6|   This API requires **PROTECTED_API** permission(s).  

        :param device_id: (required)
        :type device_id: str
        :param id: Usage Session ID that needs to be deleted (required)
        :type id: UUID
        :param x_execution_mode: X-Execution-Mode — Optional header to control execution mode.  Use sync to make the API wait until all background operations complete before returning a response.  If omitted, the request is processed asynchronously (default). 
        :type x_execution_mode: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._delete_session_serialize(
            device_id=device_id,
            id=id,
            x_execution_mode=x_execution_mode,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '204': None,
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _delete_session_serialize(
        self,
        device_id,
        id,
        x_execution_mode,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if device_id is not None:
            _path_params['deviceId'] = device_id
        if id is not None:
            _path_params['id'] = id
        # process the query parameters
        # process the header parameters
        if x_execution_mode is not None:
            _header_params['x-execution-mode'] = x_execution_mode
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='DELETE',
            resource_path='/v1/devices/{deviceId}/usage-sessions/{id}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def get_session(
        self,
        device_id: StrictStr,
        id: Annotated[UUID, Field(description="Usage Session ID that needs to be fetched")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> SessionResponseV2:
        """Get Usage Session by ID

        Get Usage Session by ID    Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |id|string|true|Usage Session ID that needs to be fetched|3fa85f64-5717-4562-b3fc-2c963f66afa6|   This API requires **PROTECTED_API** permission(s).  

        :param device_id: (required)
        :type device_id: str
        :param id: Usage Session ID that needs to be fetched (required)
        :type id: UUID
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_session_serialize(
            device_id=device_id,
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def get_session_with_http_info(
        self,
        device_id: StrictStr,
        id: Annotated[UUID, Field(description="Usage Session ID that needs to be fetched")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[SessionResponseV2]:
        """Get Usage Session by ID

        Get Usage Session by ID    Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |id|string|true|Usage Session ID that needs to be fetched|3fa85f64-5717-4562-b3fc-2c963f66afa6|   This API requires **PROTECTED_API** permission(s).  

        :param device_id: (required)
        :type device_id: str
        :param id: Usage Session ID that needs to be fetched (required)
        :type id: UUID
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_session_serialize(
            device_id=device_id,
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def get_session_without_preload_content(
        self,
        device_id: StrictStr,
        id: Annotated[UUID, Field(description="Usage Session ID that needs to be fetched")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Get Usage Session by ID

        Get Usage Session by ID    Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |id|string|true|Usage Session ID that needs to be fetched|3fa85f64-5717-4562-b3fc-2c963f66afa6|   This API requires **PROTECTED_API** permission(s).  

        :param device_id: (required)
        :type device_id: str
        :param id: Usage Session ID that needs to be fetched (required)
        :type id: UUID
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_session_serialize(
            device_id=device_id,
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _get_session_serialize(
        self,
        device_id,
        id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if device_id is not None:
            _path_params['deviceId'] = device_id
        if id is not None:
            _path_params['id'] = id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v1/devices/{deviceId}/usage-sessions/{id}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def search_device_sessions(
        self,
        search_request: Annotated[Optional[SearchRequestV2], Field(description="Search request parameters: filter, sort and page")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> SearchResponseDeviceSessionsResponseV2:
        """Search currently in progress devices' sessions entities by filter

        Search currently in progress devices' sessions entities by filter  Returns list of currently in progress devices' sessions, the response can be filtered, sorted and supports pagination   **For more information and examples on creating search requests, click <a href=\"https://docs.biot-med.com/docs/using-biot-search-apis\" target=\"_blank\">here.</a>** ## Filter Each additionalProp can filter one field, inside additionalProp there are many optional conditions that can be used for filtering that field  By using the logical additionalProps $AND, $OR, $NOT, you can add complex nested logic filters. When sending these props, you must send only the nested filter field inside the filter value. This will allow you to group additional filters using logical AND/OR/NOT operators. When not sending a logic prop (including when not sending a nested logic prop), the props are bundled together using logical AND operators, this means that only the items that match all filter conditions for that field will be returned.  ***filter*** items possible values: [ *_ownerOrganization.id*,*_id(device)*,*_patient.id* ]   ## Sort Results can be sorted by multiple fields, the order of the fields in the sort request governs the hierarchy of the sort  The first field is the primary sort, the second is used when two values of the first field are the same, and so forth  ***sort.order*** default value is DESC  ***sort.prop*** possible values:[  ]  If sort was not specified, the result will be sorted by: creationTime DESC  ## Free text search When freeTextSearch is passed, the free text search will be performed on every field except those of type Date  If used together with filters, freeTextSearch will be bundled to the filters with the logical AND operator, this means that only items that match all filters (and each filter's conditions) and the free text search will be returned  ## Page ***limit*** max number of results that will be returned for each page. If not specify, the default will be 100  ***page*** page number starting from 0. If not specify, the default will be 0  ## Build URL Encode the JSON object and use the encoded string as the searchRequest parameter:  https://&lt;URL&gt;?searchRequest=<ENCODED_JSON_STRING>  Query Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |searchRequest||false|Search request parameters: filter, sort and page||   This API requires **PROTECTED_API** permission(s).  

        :param search_request: Search request parameters: filter, sort and page
        :type search_request: SearchRequestV2
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._search_device_sessions_serialize(
            search_request=search_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SearchResponseDeviceSessionsResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '504': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def search_device_sessions_with_http_info(
        self,
        search_request: Annotated[Optional[SearchRequestV2], Field(description="Search request parameters: filter, sort and page")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[SearchResponseDeviceSessionsResponseV2]:
        """Search currently in progress devices' sessions entities by filter

        Search currently in progress devices' sessions entities by filter  Returns list of currently in progress devices' sessions, the response can be filtered, sorted and supports pagination   **For more information and examples on creating search requests, click <a href=\"https://docs.biot-med.com/docs/using-biot-search-apis\" target=\"_blank\">here.</a>** ## Filter Each additionalProp can filter one field, inside additionalProp there are many optional conditions that can be used for filtering that field  By using the logical additionalProps $AND, $OR, $NOT, you can add complex nested logic filters. When sending these props, you must send only the nested filter field inside the filter value. This will allow you to group additional filters using logical AND/OR/NOT operators. When not sending a logic prop (including when not sending a nested logic prop), the props are bundled together using logical AND operators, this means that only the items that match all filter conditions for that field will be returned.  ***filter*** items possible values: [ *_ownerOrganization.id*,*_id(device)*,*_patient.id* ]   ## Sort Results can be sorted by multiple fields, the order of the fields in the sort request governs the hierarchy of the sort  The first field is the primary sort, the second is used when two values of the first field are the same, and so forth  ***sort.order*** default value is DESC  ***sort.prop*** possible values:[  ]  If sort was not specified, the result will be sorted by: creationTime DESC  ## Free text search When freeTextSearch is passed, the free text search will be performed on every field except those of type Date  If used together with filters, freeTextSearch will be bundled to the filters with the logical AND operator, this means that only items that match all filters (and each filter's conditions) and the free text search will be returned  ## Page ***limit*** max number of results that will be returned for each page. If not specify, the default will be 100  ***page*** page number starting from 0. If not specify, the default will be 0  ## Build URL Encode the JSON object and use the encoded string as the searchRequest parameter:  https://&lt;URL&gt;?searchRequest=<ENCODED_JSON_STRING>  Query Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |searchRequest||false|Search request parameters: filter, sort and page||   This API requires **PROTECTED_API** permission(s).  

        :param search_request: Search request parameters: filter, sort and page
        :type search_request: SearchRequestV2
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._search_device_sessions_serialize(
            search_request=search_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SearchResponseDeviceSessionsResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '504': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def search_device_sessions_without_preload_content(
        self,
        search_request: Annotated[Optional[SearchRequestV2], Field(description="Search request parameters: filter, sort and page")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Search currently in progress devices' sessions entities by filter

        Search currently in progress devices' sessions entities by filter  Returns list of currently in progress devices' sessions, the response can be filtered, sorted and supports pagination   **For more information and examples on creating search requests, click <a href=\"https://docs.biot-med.com/docs/using-biot-search-apis\" target=\"_blank\">here.</a>** ## Filter Each additionalProp can filter one field, inside additionalProp there are many optional conditions that can be used for filtering that field  By using the logical additionalProps $AND, $OR, $NOT, you can add complex nested logic filters. When sending these props, you must send only the nested filter field inside the filter value. This will allow you to group additional filters using logical AND/OR/NOT operators. When not sending a logic prop (including when not sending a nested logic prop), the props are bundled together using logical AND operators, this means that only the items that match all filter conditions for that field will be returned.  ***filter*** items possible values: [ *_ownerOrganization.id*,*_id(device)*,*_patient.id* ]   ## Sort Results can be sorted by multiple fields, the order of the fields in the sort request governs the hierarchy of the sort  The first field is the primary sort, the second is used when two values of the first field are the same, and so forth  ***sort.order*** default value is DESC  ***sort.prop*** possible values:[  ]  If sort was not specified, the result will be sorted by: creationTime DESC  ## Free text search When freeTextSearch is passed, the free text search will be performed on every field except those of type Date  If used together with filters, freeTextSearch will be bundled to the filters with the logical AND operator, this means that only items that match all filters (and each filter's conditions) and the free text search will be returned  ## Page ***limit*** max number of results that will be returned for each page. If not specify, the default will be 100  ***page*** page number starting from 0. If not specify, the default will be 0  ## Build URL Encode the JSON object and use the encoded string as the searchRequest parameter:  https://&lt;URL&gt;?searchRequest=<ENCODED_JSON_STRING>  Query Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |searchRequest||false|Search request parameters: filter, sort and page||   This API requires **PROTECTED_API** permission(s).  

        :param search_request: Search request parameters: filter, sort and page
        :type search_request: SearchRequestV2
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._search_device_sessions_serialize(
            search_request=search_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SearchResponseDeviceSessionsResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '504': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _search_device_sessions_serialize(
        self,
        search_request,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if search_request is not None:
            
            _query_params.append(('searchRequest', search_request))
            
        # process the header parameters
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v1/devices/current/usage-sessions',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def search_sessions(
        self,
        search_request: Annotated[Optional[SearchRequestV2], Field(description="Search request parameters: filter, sort and page")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> SearchResponseSessionResponseV2:
        """Search Usage Session entities by filter

        Search Usage Session entities by filter  Returns list of Usage Session, the response can be filtered, sorted and supports pagination   **For more information and examples on creating search requests, click <a href=\"https://docs.biot-med.com/docs/using-biot-search-apis\" target=\"_blank\">here.</a>** ## Filter Each additionalProp can filter one field, inside additionalProp there are many optional conditions that can be used for filtering that field  By using the logical additionalProps $AND, $OR, $NOT, you can add complex nested logic filters. When sending these props, you must send only the nested filter field inside the filter value. This will allow you to group additional filters using logical AND/OR/NOT operators. When not sending a logic prop (including when not sending a nested logic prop), the props are bundled together using logical AND operators, this means that only the items that match all filter conditions for that field will be returned.  ***filter*** items possible values: [ *_templateId*,*_templateName*,*_id*,*_patient.id*,*_device.id*,*_startTime*,*_endTime*,*_initiator*,*_state*,*_ownerOrganization.id*,*_requiredMeasurementIntervalMilliseconds*,*_summary._stopReason*,*_summary._stopReasonCode*,*_name*,*_creationTime*,*_lastModifiedTime* ] and all custom attributes of all templates  ## Sort Results can be sorted by multiple fields, the order of the fields in the sort request governs the hierarchy of the sort  The first field is the primary sort, the second is used when two values of the first field are the same, and so forth  ***sort.order*** default value is DESC  ***sort.prop*** possible values:[ *_id*,*_patient.id*,*_device.id*,*_startTime*,*_endTime*,*_initiator*,*_state*,*_ownerOrganization.id*,*_requiredMeasurementIntervalMilliseconds*,*_summary._stopReason*,*_summary._stopReasonCode*,*_name*,*_creationTime*,*_lastModifiedTime* ]  If sort was not specified, the result will be sorted by: *_creationTime* DESC  ## Free text search When freeTextSearch is passed, the free text search will be performed on every field except those of type Date  If used together with filters, freeTextSearch will be bundled to the filters with the logical AND operator, this means that only items that match all filters (and each filter's conditions) and the free text search will be returned  ## Page ***limit*** max number of results that will be returned for each page. If not specify, the default will be 100  ***page*** page number starting from 0. If not specify, the default will be 0  ## Build URL Encode the JSON object and use the encoded string as the searchRequest parameter:  https://&lt;URL&gt;?searchRequest=<ENCODED_JSON_STRING>  Query Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |searchRequest||false|Search request parameters: filter, sort and page||   This API requires **PROTECTED_API** permission(s).  

        :param search_request: Search request parameters: filter, sort and page
        :type search_request: SearchRequestV2
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._search_sessions_serialize(
            search_request=search_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SearchResponseSessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '504': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def search_sessions_with_http_info(
        self,
        search_request: Annotated[Optional[SearchRequestV2], Field(description="Search request parameters: filter, sort and page")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[SearchResponseSessionResponseV2]:
        """Search Usage Session entities by filter

        Search Usage Session entities by filter  Returns list of Usage Session, the response can be filtered, sorted and supports pagination   **For more information and examples on creating search requests, click <a href=\"https://docs.biot-med.com/docs/using-biot-search-apis\" target=\"_blank\">here.</a>** ## Filter Each additionalProp can filter one field, inside additionalProp there are many optional conditions that can be used for filtering that field  By using the logical additionalProps $AND, $OR, $NOT, you can add complex nested logic filters. When sending these props, you must send only the nested filter field inside the filter value. This will allow you to group additional filters using logical AND/OR/NOT operators. When not sending a logic prop (including when not sending a nested logic prop), the props are bundled together using logical AND operators, this means that only the items that match all filter conditions for that field will be returned.  ***filter*** items possible values: [ *_templateId*,*_templateName*,*_id*,*_patient.id*,*_device.id*,*_startTime*,*_endTime*,*_initiator*,*_state*,*_ownerOrganization.id*,*_requiredMeasurementIntervalMilliseconds*,*_summary._stopReason*,*_summary._stopReasonCode*,*_name*,*_creationTime*,*_lastModifiedTime* ] and all custom attributes of all templates  ## Sort Results can be sorted by multiple fields, the order of the fields in the sort request governs the hierarchy of the sort  The first field is the primary sort, the second is used when two values of the first field are the same, and so forth  ***sort.order*** default value is DESC  ***sort.prop*** possible values:[ *_id*,*_patient.id*,*_device.id*,*_startTime*,*_endTime*,*_initiator*,*_state*,*_ownerOrganization.id*,*_requiredMeasurementIntervalMilliseconds*,*_summary._stopReason*,*_summary._stopReasonCode*,*_name*,*_creationTime*,*_lastModifiedTime* ]  If sort was not specified, the result will be sorted by: *_creationTime* DESC  ## Free text search When freeTextSearch is passed, the free text search will be performed on every field except those of type Date  If used together with filters, freeTextSearch will be bundled to the filters with the logical AND operator, this means that only items that match all filters (and each filter's conditions) and the free text search will be returned  ## Page ***limit*** max number of results that will be returned for each page. If not specify, the default will be 100  ***page*** page number starting from 0. If not specify, the default will be 0  ## Build URL Encode the JSON object and use the encoded string as the searchRequest parameter:  https://&lt;URL&gt;?searchRequest=<ENCODED_JSON_STRING>  Query Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |searchRequest||false|Search request parameters: filter, sort and page||   This API requires **PROTECTED_API** permission(s).  

        :param search_request: Search request parameters: filter, sort and page
        :type search_request: SearchRequestV2
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._search_sessions_serialize(
            search_request=search_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SearchResponseSessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '504': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def search_sessions_without_preload_content(
        self,
        search_request: Annotated[Optional[SearchRequestV2], Field(description="Search request parameters: filter, sort and page")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Search Usage Session entities by filter

        Search Usage Session entities by filter  Returns list of Usage Session, the response can be filtered, sorted and supports pagination   **For more information and examples on creating search requests, click <a href=\"https://docs.biot-med.com/docs/using-biot-search-apis\" target=\"_blank\">here.</a>** ## Filter Each additionalProp can filter one field, inside additionalProp there are many optional conditions that can be used for filtering that field  By using the logical additionalProps $AND, $OR, $NOT, you can add complex nested logic filters. When sending these props, you must send only the nested filter field inside the filter value. This will allow you to group additional filters using logical AND/OR/NOT operators. When not sending a logic prop (including when not sending a nested logic prop), the props are bundled together using logical AND operators, this means that only the items that match all filter conditions for that field will be returned.  ***filter*** items possible values: [ *_templateId*,*_templateName*,*_id*,*_patient.id*,*_device.id*,*_startTime*,*_endTime*,*_initiator*,*_state*,*_ownerOrganization.id*,*_requiredMeasurementIntervalMilliseconds*,*_summary._stopReason*,*_summary._stopReasonCode*,*_name*,*_creationTime*,*_lastModifiedTime* ] and all custom attributes of all templates  ## Sort Results can be sorted by multiple fields, the order of the fields in the sort request governs the hierarchy of the sort  The first field is the primary sort, the second is used when two values of the first field are the same, and so forth  ***sort.order*** default value is DESC  ***sort.prop*** possible values:[ *_id*,*_patient.id*,*_device.id*,*_startTime*,*_endTime*,*_initiator*,*_state*,*_ownerOrganization.id*,*_requiredMeasurementIntervalMilliseconds*,*_summary._stopReason*,*_summary._stopReasonCode*,*_name*,*_creationTime*,*_lastModifiedTime* ]  If sort was not specified, the result will be sorted by: *_creationTime* DESC  ## Free text search When freeTextSearch is passed, the free text search will be performed on every field except those of type Date  If used together with filters, freeTextSearch will be bundled to the filters with the logical AND operator, this means that only items that match all filters (and each filter's conditions) and the free text search will be returned  ## Page ***limit*** max number of results that will be returned for each page. If not specify, the default will be 100  ***page*** page number starting from 0. If not specify, the default will be 0  ## Build URL Encode the JSON object and use the encoded string as the searchRequest parameter:  https://&lt;URL&gt;?searchRequest=<ENCODED_JSON_STRING>  Query Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |searchRequest||false|Search request parameters: filter, sort and page||   This API requires **PROTECTED_API** permission(s).  

        :param search_request: Search request parameters: filter, sort and page
        :type search_request: SearchRequestV2
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._search_sessions_serialize(
            search_request=search_request,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SearchResponseSessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '504': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _search_sessions_serialize(
        self,
        search_request,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if search_request is not None:
            
            _query_params.append(('searchRequest', search_request))
            
        # process the header parameters
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v1/devices/usage-sessions',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def update_session(
        self,
        update_session_request_v2: UpdateSessionRequestV2,
        device_id: StrictStr,
        id: Annotated[UUID, Field(description="Usage Session ID that needs to be updated")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> SessionResponseV2:
        """Update Usage Session

        Update Usage Session  Performs partial update, if a field is specified in the request it will be updated  Request Body Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Regular custom attribute 1 value|| |&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Regular custom attribute N value|| |_configuration|object|false|An object that holds the entity configuration attributes|| |_configuration.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Configuration custom attribute 1 value|| |_configuration.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Configuration custom attribute N value|| |_endTime|string|false|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_name|string|false|The name of the session|| |_startTime|string|true|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_state|string|true|The Sessions state Values:ACTIVE,DONE,PAUSED,ACTIVATING,PAUSING,RESUMING,STOPPING|ACTIVE| |_summary|object|false||| |_summary.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Summary custom attribute 1 value|| |_summary.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Summary custom attribute N value|| |_summary._stopReason|string|false|The reason the session was stopped|Manual Stop| |_summary._stopReasonCode|string|false|The code of the stop reason Values:COMPLETION,GENERAL_DEVICE_ERROR,TIMEOUT|COMPLETION| Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |id|string|true|Usage Session ID that needs to be updated|3fa85f64-5717-4562-b3fc-2c963f66afa6|   This API requires **PROTECTED_API** permission(s).  

        :param update_session_request_v2: (required)
        :type update_session_request_v2: UpdateSessionRequestV2
        :param device_id: (required)
        :type device_id: str
        :param id: Usage Session ID that needs to be updated (required)
        :type id: UUID
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._update_session_serialize(
            update_session_request_v2=update_session_request_v2,
            device_id=device_id,
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def update_session_with_http_info(
        self,
        update_session_request_v2: UpdateSessionRequestV2,
        device_id: StrictStr,
        id: Annotated[UUID, Field(description="Usage Session ID that needs to be updated")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[SessionResponseV2]:
        """Update Usage Session

        Update Usage Session  Performs partial update, if a field is specified in the request it will be updated  Request Body Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Regular custom attribute 1 value|| |&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Regular custom attribute N value|| |_configuration|object|false|An object that holds the entity configuration attributes|| |_configuration.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Configuration custom attribute 1 value|| |_configuration.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Configuration custom attribute N value|| |_endTime|string|false|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_name|string|false|The name of the session|| |_startTime|string|true|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_state|string|true|The Sessions state Values:ACTIVE,DONE,PAUSED,ACTIVATING,PAUSING,RESUMING,STOPPING|ACTIVE| |_summary|object|false||| |_summary.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Summary custom attribute 1 value|| |_summary.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Summary custom attribute N value|| |_summary._stopReason|string|false|The reason the session was stopped|Manual Stop| |_summary._stopReasonCode|string|false|The code of the stop reason Values:COMPLETION,GENERAL_DEVICE_ERROR,TIMEOUT|COMPLETION| Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |id|string|true|Usage Session ID that needs to be updated|3fa85f64-5717-4562-b3fc-2c963f66afa6|   This API requires **PROTECTED_API** permission(s).  

        :param update_session_request_v2: (required)
        :type update_session_request_v2: UpdateSessionRequestV2
        :param device_id: (required)
        :type device_id: str
        :param id: Usage Session ID that needs to be updated (required)
        :type id: UUID
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._update_session_serialize(
            update_session_request_v2=update_session_request_v2,
            device_id=device_id,
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def update_session_without_preload_content(
        self,
        update_session_request_v2: UpdateSessionRequestV2,
        device_id: StrictStr,
        id: Annotated[UUID, Field(description="Usage Session ID that needs to be updated")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Update Usage Session

        Update Usage Session  Performs partial update, if a field is specified in the request it will be updated  Request Body Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Regular custom attribute 1 value|| |&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Regular custom attribute N value|| |_configuration|object|false|An object that holds the entity configuration attributes|| |_configuration.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Configuration custom attribute 1 value|| |_configuration.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Configuration custom attribute N value|| |_endTime|string|false|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_name|string|false|The name of the session|| |_startTime|string|true|A UTC date-time in the ISO-8601 format|2007-12-20T10:15:30Z| |_state|string|true|The Sessions state Values:ACTIVE,DONE,PAUSED,ACTIVATING,PAUSING,RESUMING,STOPPING|ACTIVE| |_summary|object|false||| |_summary.&lt;customAttribute1&gt;|&lt;customAttribute1Type&gt;|false|Summary custom attribute 1 value|| |_summary.&lt;customAttributeN&gt;|&lt;customAttributeNType&gt;|false|Summary custom attribute N value|| |_summary._stopReason|string|false|The reason the session was stopped|Manual Stop| |_summary._stopReasonCode|string|false|The code of the stop reason Values:COMPLETION,GENERAL_DEVICE_ERROR,TIMEOUT|COMPLETION| Path Parameters:  | Parameter   |Type   | Mandatory| Description          | Example   | |-------------|-------|----------|----------------------|-----------| |deviceId|string|true|null|| |id|string|true|Usage Session ID that needs to be updated|3fa85f64-5717-4562-b3fc-2c963f66afa6|   This API requires **PROTECTED_API** permission(s).  

        :param update_session_request_v2: (required)
        :type update_session_request_v2: UpdateSessionRequestV2
        :param device_id: (required)
        :type device_id: str
        :param id: Usage Session ID that needs to be updated (required)
        :type id: UUID
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._update_session_serialize(
            update_session_request_v2=update_session_request_v2,
            device_id=device_id,
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '400': "ErrorResponse",
            '200': "SessionResponseV2",
            '500': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
            '504': "ErrorResponse",
            '409': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _update_session_serialize(
        self,
        update_session_request_v2,
        device_id,
        id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if device_id is not None:
            _path_params['deviceId'] = device_id
        if id is not None:
            _path_params['id'] = id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter
        if update_session_request_v2 is not None:
            _body_params = update_session_request_v2


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )

        # set the HTTP header `Content-Type`
        if _content_type:
            _header_params['Content-Type'] = _content_type
        else:
            _default_content_type = (
                self.api_client.select_header_content_type(
                    [
                        'application/json'
                    ]
                )
            )
            if _default_content_type is not None:
                _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='PATCH',
            resource_path='/v1/devices/{deviceId}/usage-sessions/{id}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )


