# 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 ModelFieldApi(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 model_field_create_model_field(self, new_model_field, **kwargs):  # noqa: E501
        """Create a new model field  # noqa: E501

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

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

    def model_field_create_model_field_with_http_info(self, new_model_field, **kwargs):  # noqa: E501
        """Create a new model field  # noqa: E501

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

        :param async_req bool
        :param ModelField new_model_field: The model field to create. (required)
        :return: ModelField
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'new_model_field' in params:
            body_params = params['new_model_field']
        # 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', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ModelField',  # 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 model_field_delete_model_field(self, model_field_id, **kwargs):  # noqa: E501
        """Delete an existing model field  # noqa: E501

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

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

    def model_field_delete_model_field_with_http_info(self, model_field_id, **kwargs):  # noqa: E501
        """Delete an existing model field  # noqa: E501

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

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

        all_params = ['model_field_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 model_field_delete_model_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 `model_field_delete_model_field`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'model_field_id' in params:
            path_params['modelFieldId'] = params['model_field_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/modelfield/{modelFieldId}', '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 model_field_get_model_field_authorizations(self, model_field_id, **kwargs):  # noqa: E501
        """Get authorizations for a model field via its 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.model_field_get_model_field_authorizations(model_field_id, async_req=True)
        >>> result = thread.get()

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

    def model_field_get_model_field_authorizations_with_http_info(self, model_field_id, **kwargs):  # noqa: E501
        """Get authorizations for a model field via its 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.model_field_get_model_field_authorizations_with_http_info(model_field_id, async_req=True)
        >>> result = thread.get()

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

        all_params = ['model_field_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 model_field_get_model_field_authorizations" % 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 `model_field_get_model_field_authorizations`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'model_field_id' in params:
            path_params['modelFieldId'] = params['model_field_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/modelfield/{modelFieldId}/auths', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[ModelFieldAuthorization]',  # 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 model_field_get_model_field(self, model_field_id, **kwargs):  # noqa: E501
        """Get a model field 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.model_field_get_model_field(model_field_id, async_req=True)
        >>> result = thread.get()

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

    def model_field_get_model_field_with_http_info(self, model_field_id, **kwargs):  # noqa: E501
        """Get a model field 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.model_field_get_model_field_with_http_info(model_field_id, async_req=True)
        >>> result = thread.get()

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

        all_params = ['model_field_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 model_field_get_model_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 `model_field_get_model_field`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'model_field_id' in params:
            path_params['modelFieldId'] = params['model_field_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/modelfield/{modelFieldId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ModelField',  # 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 model_field_get_model_fields(self, field_type, **kwargs):  # noqa: E501
        """Get the list of all model fields.  # noqa: E501

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

        :param async_req bool
        :param str field_type: The field type for which to return the model fields. (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.model_field_get_model_fields_with_http_info(field_type, **kwargs)  # noqa: E501
        else:
            (data) = self.model_field_get_model_fields_with_http_info(field_type, **kwargs)  # noqa: E501
            return data

    def model_field_get_model_fields_with_http_info(self, field_type, **kwargs):  # noqa: E501
        """Get the list of all model fields.  # noqa: E501

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

        :param async_req bool
        :param str field_type: The field type for which to return the model fields. (required)
        :return: list[CoupleGuidText]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['field_type']  # 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 model_field_get_model_fields" % key
                )
            params[key] = val
        del params['kwargs']
        # 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 `model_field_get_model_fields`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'field_type' in params:
            query_params.append(('fieldType', params['field_type']))  # 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/modelfields', '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 model_field_update_model_field(self, model_field_id, updated_model_field, **kwargs):  # noqa: E501
        """Update an existing model field  # noqa: E501

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

        :param async_req bool
        :param str model_field_id: The unique model field id for which you want to update the modelfield (required)
        :param ModelField updated_model_field: The model field to update. (required)
        :return: ModelField
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.model_field_update_model_field_with_http_info(model_field_id, updated_model_field, **kwargs)  # noqa: E501
        else:
            (data) = self.model_field_update_model_field_with_http_info(model_field_id, updated_model_field, **kwargs)  # noqa: E501
            return data

    def model_field_update_model_field_with_http_info(self, model_field_id, updated_model_field, **kwargs):  # noqa: E501
        """Update an existing model field  # noqa: E501

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

        :param async_req bool
        :param str model_field_id: The unique model field id for which you want to update the modelfield (required)
        :param ModelField updated_model_field: The model field to update. (required)
        :return: ModelField
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'updated_model_field' in params:
            body_params = params['updated_model_field']
        # 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}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ModelField',  # 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 model_field_update_model_field_authorization(self, model_field_id, **kwargs):  # noqa: E501
        """Set/Update a model field authorization  # noqa: E501

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

        :param async_req bool
        :param str model_field_id: The unique model field id for which you want to set/update the authorizations (required)
        :param ModelFieldAuthorization authorization: The authorization for the model field.
        :return: ModelFieldAuthorization
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.model_field_update_model_field_authorization_with_http_info(model_field_id, **kwargs)  # noqa: E501
        else:
            (data) = self.model_field_update_model_field_authorization_with_http_info(model_field_id, **kwargs)  # noqa: E501
            return data

    def model_field_update_model_field_authorization_with_http_info(self, model_field_id, **kwargs):  # noqa: E501
        """Set/Update a model field authorization  # noqa: E501

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

        :param async_req bool
        :param str model_field_id: The unique model field id for which you want to set/update the authorizations (required)
        :param ModelFieldAuthorization authorization: The authorization for the model field.
        :return: ModelFieldAuthorization
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['model_field_id', 'authorization']  # 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 model_field_update_model_field_authorization" % 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 `model_field_update_model_field_authorization`")  # noqa: E501

        collection_formats = {}

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

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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