# 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 TrackLayoutApi(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 track_layout_create_track_layout(self, new_track_layout, **kwargs):  # noqa: E501
        """Create a new trackLayout  # noqa: E501

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

        :param async_req bool
        :param TrackLayout new_track_layout: The trackLayout to create. (required)
        :return: TrackLayout
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.track_layout_create_track_layout_with_http_info(new_track_layout, **kwargs)  # noqa: E501
        else:
            (data) = self.track_layout_create_track_layout_with_http_info(new_track_layout, **kwargs)  # noqa: E501
            return data

    def track_layout_create_track_layout_with_http_info(self, new_track_layout, **kwargs):  # noqa: E501
        """Create a new trackLayout  # noqa: E501

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

        :param async_req bool
        :param TrackLayout new_track_layout: The trackLayout to create. (required)
        :return: TrackLayout
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['new_track_layout']  # 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 track_layout_create_track_layout" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'new_track_layout' is set
        if self.api_client.client_side_validation and ('new_track_layout' not in params or
                                                       params['new_track_layout'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `new_track_layout` when calling `track_layout_create_track_layout`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'new_track_layout' in params:
            body_params = params['new_track_layout']
        # 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/tracklayout', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='TrackLayout',  # 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 track_layout_delete_track_layout(self, track_layout_id, **kwargs):  # noqa: E501
        """Delete an existing trackLayout  # noqa: E501

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

        :param async_req bool
        :param str track_layout_id: The unique trackLayout id for which you want to delete the trackLayout (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.track_layout_delete_track_layout_with_http_info(track_layout_id, **kwargs)  # noqa: E501
        else:
            (data) = self.track_layout_delete_track_layout_with_http_info(track_layout_id, **kwargs)  # noqa: E501
            return data

    def track_layout_delete_track_layout_with_http_info(self, track_layout_id, **kwargs):  # noqa: E501
        """Delete an existing trackLayout  # noqa: E501

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

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

        all_params = ['track_layout_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 track_layout_delete_track_layout" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'track_layout_id' is set
        if self.api_client.client_side_validation and ('track_layout_id' not in params or
                                                       params['track_layout_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `track_layout_id` when calling `track_layout_delete_track_layout`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'track_layout_id' in params:
            path_params['trackLayoutId'] = params['track_layout_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/tracklayout/{trackLayoutId}', '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 track_layout_get_track_layout(self, track_layout_id, **kwargs):  # noqa: E501
        """Get an trackLayout 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.track_layout_get_track_layout(track_layout_id, async_req=True)
        >>> result = thread.get()

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

    def track_layout_get_track_layout_with_http_info(self, track_layout_id, **kwargs):  # noqa: E501
        """Get an trackLayout 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.track_layout_get_track_layout_with_http_info(track_layout_id, async_req=True)
        >>> result = thread.get()

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

        all_params = ['track_layout_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 track_layout_get_track_layout" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'track_layout_id' is set
        if self.api_client.client_side_validation and ('track_layout_id' not in params or
                                                       params['track_layout_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `track_layout_id` when calling `track_layout_get_track_layout`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'track_layout_id' in params:
            path_params['trackLayoutId'] = params['track_layout_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/tracklayout/{trackLayoutId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='TrackLayout',  # 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 track_layout_get_track_layouts(self, track_id, **kwargs):  # noqa: E501
        """Get the list of all track layouts  # noqa: E501

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

        :param async_req bool
        :param str track_id: The unique track id for which you want to get the trackLayouts (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.track_layout_get_track_layouts_with_http_info(track_id, **kwargs)  # noqa: E501
        else:
            (data) = self.track_layout_get_track_layouts_with_http_info(track_id, **kwargs)  # noqa: E501
            return data

    def track_layout_get_track_layouts_with_http_info(self, track_id, **kwargs):  # noqa: E501
        """Get the list of all track layouts  # noqa: E501

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

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

        all_params = ['track_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 track_layout_get_track_layouts" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'track_id' is set
        if self.api_client.client_side_validation and ('track_id' not in params or
                                                       params['track_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `track_id` when calling `track_layout_get_track_layouts`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'track_id' in params:
            path_params['trackId'] = params['track_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/track/{trackId}/layouts', '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 track_layout_update_track_layout(self, track_layout_id, updated_track_layout, **kwargs):  # noqa: E501
        """Update an existing trackLayout  # noqa: E501

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

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

    def track_layout_update_track_layout_with_http_info(self, track_layout_id, updated_track_layout, **kwargs):  # noqa: E501
        """Update an existing trackLayout  # noqa: E501

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

        :param async_req bool
        :param str track_layout_id: The unique trackLayout id for which you want to update the trackLayout (required)
        :param TrackLayout updated_track_layout: The trackLayout to update. (required)
        :return: TrackLayout
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['track_layout_id', 'updated_track_layout']  # 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 track_layout_update_track_layout" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'track_layout_id' is set
        if self.api_client.client_side_validation and ('track_layout_id' not in params or
                                                       params['track_layout_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `track_layout_id` when calling `track_layout_update_track_layout`")  # noqa: E501
        # verify the required parameter 'updated_track_layout' is set
        if self.api_client.client_side_validation and ('updated_track_layout' not in params or
                                                       params['updated_track_layout'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `updated_track_layout` when calling `track_layout_update_track_layout`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'track_layout_id' in params:
            path_params['trackLayoutId'] = params['track_layout_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'updated_track_layout' in params:
            body_params = params['updated_track_layout']
        # 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/tracklayout/{trackLayoutId}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='TrackLayout',  # 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)
