# 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 ValueFieldApi(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 value_field_get_item_values(self, item_value_keys, **kwargs):  # noqa: E501
        """Get a list of value fields, revision editors and revision selectors via a model field unique id and a parent entity 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.value_field_get_item_values(item_value_keys, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param list[ItemValueKey] item_value_keys: The list of keys (model field / parent entity) for which you want to get the values (required)
        :return: list[ItemValue]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.value_field_get_item_values_with_http_info(item_value_keys, **kwargs)  # noqa: E501
        else:
            (data) = self.value_field_get_item_values_with_http_info(item_value_keys, **kwargs)  # noqa: E501
            return data

    def value_field_get_item_values_with_http_info(self, item_value_keys, **kwargs):  # noqa: E501
        """Get a list of value fields, revision editors and revision selectors via a model field unique id and a parent entity 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.value_field_get_item_values_with_http_info(item_value_keys, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param list[ItemValueKey] item_value_keys: The list of keys (model field / parent entity) for which you want to get the values (required)
        :return: list[ItemValue]
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'item_value_keys' in params:
            body_params = params['item_value_keys']
        # 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/valuefields', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[ItemValue]',  # 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 value_field_get_value_field(self, model_field_id, parent_item_id, **kwargs):  # noqa: E501
        """Get a value field via a model field unique id and a parent entity 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.value_field_get_value_field(model_field_id, parent_item_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str model_field_id: The model field id for which you want to get the value field (required)
        :param str parent_item_id: The parent item id for which you want to get the value field (required)
        :param int row_id: The row 0 based index of the cell for which you want the value. The Row headers are included.
        :param int col_id: The column 0 based index of the cell for which you want the value
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.value_field_get_value_field_with_http_info(model_field_id, parent_item_id, **kwargs)  # noqa: E501
        else:
            (data) = self.value_field_get_value_field_with_http_info(model_field_id, parent_item_id, **kwargs)  # noqa: E501
            return data

    def value_field_get_value_field_with_http_info(self, model_field_id, parent_item_id, **kwargs):  # noqa: E501
        """Get a value field via a model field unique id and a parent entity 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.value_field_get_value_field_with_http_info(model_field_id, parent_item_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str model_field_id: The model field id for which you want to get the value field (required)
        :param str parent_item_id: The parent item id for which you want to get the value field (required)
        :param int row_id: The row 0 based index of the cell for which you want the value. The Row headers are included.
        :param int col_id: The column 0 based index of the cell for which you want the value
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'model_field_id' in params:
            path_params['modelFieldId'] = params['model_field_id']  # noqa: E501

        query_params = []
        if 'parent_item_id' in params:
            query_params.append(('parentItemId', params['parent_item_id']))  # noqa: E501
        if 'row_id' in params:
            query_params.append(('rowId', params['row_id']))  # noqa: E501
        if 'col_id' in params:
            query_params.append(('colId', params['col_id']))  # noqa: E501

        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/modelfield/{modelFieldId}/valuefield', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='object',  # 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 value_field_get_value_field(self, field_name, field_type, parent_item_id, **kwargs):  # noqa: E501
        """Retrieve the list of all values of a modelField  # noqa: E501

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

        :param async_req bool
        :param str field_name: The name of the field for which you are looking for values (required)
        :param str field_type: The type of modelField (event, car,...) (required)
        :param str parent_item_id: Id of the parent itembase (required)
        :return: list[object]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.value_field_get_value_field_with_http_info(field_name, field_type, parent_item_id, **kwargs)  # noqa: E501
        else:
            (data) = self.value_field_get_value_field_with_http_info(field_name, field_type, parent_item_id, **kwargs)  # noqa: E501
            return data

    def value_field_get_value_field_with_http_info(self, field_name, field_type, parent_item_id, **kwargs):  # noqa: E501
        """Retrieve the list of all values of a modelField  # noqa: E501

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

        :param async_req bool
        :param str field_name: The name of the field for which you are looking for values (required)
        :param str field_type: The type of modelField (event, car,...) (required)
        :param str parent_item_id: Id of the parent itembase (required)
        :return: list[object]
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'field_name' in params:
            path_params['fieldName'] = params['field_name']  # noqa: E501
        if 'field_type' in params:
            path_params['fieldType'] = params['field_type']  # noqa: E501

        query_params = []
        if 'parent_item_id' in params:
            query_params.append(('parentItemId', params['parent_item_id']))  # noqa: E501

        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/modelfield/{fieldName}/fieldType/{fieldType}/valuefield', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[object]',  # 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 value_field_set_item_values(self, item_values, **kwargs):  # noqa: E501
        """Set a list of items value fields, revision editors and revision selectors via a model field unique id and a parent entity 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.value_field_set_item_values(item_values, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param list[ItemValue] item_values: The list of values you want to set (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.value_field_set_item_values_with_http_info(item_values, **kwargs)  # noqa: E501
        else:
            (data) = self.value_field_set_item_values_with_http_info(item_values, **kwargs)  # noqa: E501
            return data

    def value_field_set_item_values_with_http_info(self, item_values, **kwargs):  # noqa: E501
        """Set a list of items value fields, revision editors and revision selectors via a model field unique id and a parent entity 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.value_field_set_item_values_with_http_info(item_values, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param list[ItemValue] item_values: The list of values you want to set (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'item_values' in params:
            body_params = params['item_values']
        # 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/valuefields', 'PUT',
            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 value_field_set_value_field(self, model_field_id, parent_item_id, value, **kwargs):  # noqa: E501
        """Set a value field via a model field unique id and a parent entity unique id.  To update a RevisionEditor call POST tracksideapi/v1/RevisionEditorValue method from RevisionEditorSelector API instead  To update a RevisionSelector call POST tracksideapi/v1/RevisionSelectorValue method from RevisionEditorSelector API instead  # noqa: E501

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

        :param async_req bool
        :param str model_field_id: The model field id for which you want to get the value field (required)
        :param str parent_item_id: The parent item id for which you want to get the value field (required)
        :param object value: The value to set in the value field. -Timespan, enter a double value in seconds 125.333 -> 02:05.333. -DateTime, use the following format 2019-02-18T18:14:32.930Z. -Image, enter the path to the file with the following format C:\\\\\\Users\\\\\\MyUser\\\\\\Downloads\\\\\\MyImage.png (note the double \\\\) (required)
        :return: ValueField
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.value_field_set_value_field_with_http_info(model_field_id, parent_item_id, value, **kwargs)  # noqa: E501
        else:
            (data) = self.value_field_set_value_field_with_http_info(model_field_id, parent_item_id, value, **kwargs)  # noqa: E501
            return data

    def value_field_set_value_field_with_http_info(self, model_field_id, parent_item_id, value, **kwargs):  # noqa: E501
        """Set a value field via a model field unique id and a parent entity unique id.  To update a RevisionEditor call POST tracksideapi/v1/RevisionEditorValue method from RevisionEditorSelector API instead  To update a RevisionSelector call POST tracksideapi/v1/RevisionSelectorValue method from RevisionEditorSelector API instead  # noqa: E501

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

        :param async_req bool
        :param str model_field_id: The model field id for which you want to get the value field (required)
        :param str parent_item_id: The parent item id for which you want to get the value field (required)
        :param object value: The value to set in the value field. -Timespan, enter a double value in seconds 125.333 -> 02:05.333. -DateTime, use the following format 2019-02-18T18:14:32.930Z. -Image, enter the path to the file with the following format C:\\\\\\Users\\\\\\MyUser\\\\\\Downloads\\\\\\MyImage.png (note the double \\\\) (required)
        :return: ValueField
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'model_field_id' in params:
            path_params['modelFieldId'] = params['model_field_id']  # noqa: E501

        query_params = []
        if 'parent_item_id' in params:
            query_params.append(('parentItemId', params['parent_item_id']))  # noqa: E501

        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/modelfield/{modelFieldId}/valuefield', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ValueField',  # 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)
