# coding: utf-8

"""
    Trackside Software TeamDB API v2.0

    This API enables you to access TeamDB data  # noqa: E501

    OpenAPI spec version: 2.0
    Contact: support@trackside.fr
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from teamdbapi.api_client import ApiClient


class LapApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

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

    def lap_create_new_lap(self, run_id, **kwargs):  # noqa: E501
        """Create a new lap  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_create_new_lap(run_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str run_id: The run id to which you want to add a new lap. (required)
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.lap_create_new_lap_with_http_info(run_id, **kwargs)  # noqa: E501
        else:
            (data) = self.lap_create_new_lap_with_http_info(run_id, **kwargs)  # noqa: E501
            return data

    def lap_create_new_lap_with_http_info(self, run_id, **kwargs):  # noqa: E501
        """Create a new lap  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_create_new_lap_with_http_info(run_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str run_id: The run id to which you want to add a new lap. (required)
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['run_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method lap_create_new_lap" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'run_id' is set
        if self.api_client.client_side_validation and ('run_id' not in params or
                                                       params['run_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `run_id` when calling `lap_create_new_lap`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'run_id' in params:
            path_params['runId'] = params['run_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/teamdbapi/v2.0/run/{runId}/addlap', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Lap',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def lap_delete_lap(self, lap_id, **kwargs):  # noqa: E501
        """Delete an existing lap  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_delete_lap(lap_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str lap_id: The unique lap id for which you want to delete the lap (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.lap_delete_lap_with_http_info(lap_id, **kwargs)  # noqa: E501
        else:
            (data) = self.lap_delete_lap_with_http_info(lap_id, **kwargs)  # noqa: E501
            return data

    def lap_delete_lap_with_http_info(self, lap_id, **kwargs):  # noqa: E501
        """Delete an existing lap  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_delete_lap_with_http_info(lap_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str lap_id: The unique lap id for which you want to delete the lap (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['lap_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method lap_delete_lap" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'lap_id' is set
        if self.api_client.client_side_validation and ('lap_id' not in params or
                                                       params['lap_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `lap_id` when calling `lap_delete_lap`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'lap_id' in params:
            path_params['lapId'] = params['lap_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/teamdbapi/v2.0/lap/{lapId}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def lap_get_current_lap(self, **kwargs):  # noqa: E501
        """Get the current lap.  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_get_current_lap(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.lap_get_current_lap_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.lap_get_current_lap_with_http_info(**kwargs)  # noqa: E501
            return data

    def lap_get_current_lap_with_http_info(self, **kwargs):  # noqa: E501
        """Get the current lap.  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_get_current_lap_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = []  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method lap_get_current_lap" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/teamdbapi/v2.0/lap/current', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Lap',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def lap_get_lap(self, lap_id, **kwargs):  # noqa: E501
        """Get a lap via a unique id.  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_get_lap(lap_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str lap_id: The unique lap id for which you want to get the lap (required)
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.lap_get_lap_with_http_info(lap_id, **kwargs)  # noqa: E501
        else:
            (data) = self.lap_get_lap_with_http_info(lap_id, **kwargs)  # noqa: E501
            return data

    def lap_get_lap_with_http_info(self, lap_id, **kwargs):  # noqa: E501
        """Get a lap via a unique id.  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_get_lap_with_http_info(lap_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str lap_id: The unique lap id for which you want to get the lap (required)
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['lap_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method lap_get_lap" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'lap_id' is set
        if self.api_client.client_side_validation and ('lap_id' not in params or
                                                       params['lap_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `lap_id` when calling `lap_get_lap`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'lap_id' in params:
            path_params['lapId'] = params['lap_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/teamdbapi/v2.0/lap/{lapId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Lap',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def lap_get_lap_list(self, run_id, **kwargs):  # noqa: E501
        """Get the list of all laps for a run.  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_get_lap_list(run_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str run_id: The unique run id for which you want to get the lap list (required)
        :return: list[CoupleGuidText]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.lap_get_lap_list_with_http_info(run_id, **kwargs)  # noqa: E501
        else:
            (data) = self.lap_get_lap_list_with_http_info(run_id, **kwargs)  # noqa: E501
            return data

    def lap_get_lap_list_with_http_info(self, run_id, **kwargs):  # noqa: E501
        """Get the list of all laps for a run.  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_get_lap_list_with_http_info(run_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str run_id: The unique run id for which you want to get the lap list (required)
        :return: list[CoupleGuidText]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['run_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method lap_get_lap_list" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'run_id' is set
        if self.api_client.client_side_validation and ('run_id' not in params or
                                                       params['run_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `run_id` when calling `lap_get_lap_list`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'run_id' in params:
            path_params['runId'] = params['run_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/teamdbapi/v2.0/run/{runId}/laps', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[CoupleGuidText]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def lap_update_lap_property(self, lap_id, property_name, value, **kwargs):  # noqa: E501
        """Update a property value for an existing lap  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_update_lap_property(lap_id, property_name, value, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str lap_id: The lap unique Id (required)
        :param str property_name: The property name to update. (Case sensitive). (required)
        :param object value: The new value. For LapDate, you need to wrap the date around \" for instance : \"2018-12-20T09:31:25.111Z\" (required)
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.lap_update_lap_property_with_http_info(lap_id, property_name, value, **kwargs)  # noqa: E501
        else:
            (data) = self.lap_update_lap_property_with_http_info(lap_id, property_name, value, **kwargs)  # noqa: E501
            return data

    def lap_update_lap_property_with_http_info(self, lap_id, property_name, value, **kwargs):  # noqa: E501
        """Update a property value for an existing lap  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_update_lap_property_with_http_info(lap_id, property_name, value, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str lap_id: The lap unique Id (required)
        :param str property_name: The property name to update. (Case sensitive). (required)
        :param object value: The new value. For LapDate, you need to wrap the date around \" for instance : \"2018-12-20T09:31:25.111Z\" (required)
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['lap_id', 'property_name', 'value']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method lap_update_lap_property" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'lap_id' is set
        if self.api_client.client_side_validation and ('lap_id' not in params or
                                                       params['lap_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `lap_id` when calling `lap_update_lap_property`")  # noqa: E501
        # verify the required parameter 'property_name' is set
        if self.api_client.client_side_validation and ('property_name' not in params or
                                                       params['property_name'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `property_name` when calling `lap_update_lap_property`")  # noqa: E501
        # verify the required parameter 'value' is set
        if self.api_client.client_side_validation and ('value' not in params or
                                                       params['value'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `value` when calling `lap_update_lap_property`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'lap_id' in params:
            path_params['lapId'] = params['lap_id']  # noqa: E501
        if 'property_name' in params:
            path_params['propertyName'] = params['property_name']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'value' in params:
            body_params = params['value']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json-patch+json', 'application/json', 'text/json', 'application/*+json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/teamdbapi/v2.0/lap/{lapId}/propertyName/{propertyName}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Lap',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def lap_update_lap(self, lap_id, lap_to_update, **kwargs):  # noqa: E501
        """Update an existing lap  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_update_lap(lap_id, lap_to_update, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str lap_id: The Id of the lap to update (required)
        :param Lap lap_to_update: The lap to update (required)
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.lap_update_lap_with_http_info(lap_id, lap_to_update, **kwargs)  # noqa: E501
        else:
            (data) = self.lap_update_lap_with_http_info(lap_id, lap_to_update, **kwargs)  # noqa: E501
            return data

    def lap_update_lap_with_http_info(self, lap_id, lap_to_update, **kwargs):  # noqa: E501
        """Update an existing lap  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.lap_update_lap_with_http_info(lap_id, lap_to_update, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str lap_id: The Id of the lap to update (required)
        :param Lap lap_to_update: The lap to update (required)
        :return: Lap
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['lap_id', 'lap_to_update']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method lap_update_lap" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'lap_id' is set
        if self.api_client.client_side_validation and ('lap_id' not in params or
                                                       params['lap_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `lap_id` when calling `lap_update_lap`")  # noqa: E501
        # verify the required parameter 'lap_to_update' is set
        if self.api_client.client_side_validation and ('lap_to_update' not in params or
                                                       params['lap_to_update'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `lap_to_update` when calling `lap_update_lap`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'lap_id' in params:
            path_params['lapId'] = params['lap_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'lap_to_update' in params:
            body_params = params['lap_to_update']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json-patch+json', 'application/json', 'text/json', 'application/*+json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/teamdbapi/v2.0/lap/{lapId}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Lap',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)
