# 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 TargetApi(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 target_create_target(self, target, **kwargs):  # noqa: E501
        """Create a target  # noqa: E501

        Set the Target.Id to Guid.Empty (00000000-0000-0000-0000-000000000000) if you want to create a new target. The id will be generated by the server.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.target_create_target(target, async_req=True)
        >>> result = thread.get()

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

    def target_create_target_with_http_info(self, target, **kwargs):  # noqa: E501
        """Create a target  # noqa: E501

        Set the Target.Id to Guid.Empty (00000000-0000-0000-0000-000000000000) if you want to create a new target. The id will be generated by the server.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.target_create_target_with_http_info(target, async_req=True)
        >>> result = thread.get()

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

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'target' in params:
            body_params = params['target']
        # 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/target', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Target',  # 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 target_get_target(self, id, **kwargs):  # noqa: E501
        """Get a target corresponding to 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.target_get_target(id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: The unique target id that corresponds to the searched target (required)
        :return: Target
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.target_get_target_with_http_info(id, **kwargs)  # noqa: E501
        else:
            (data) = self.target_get_target_with_http_info(id, **kwargs)  # noqa: E501
            return data

    def target_get_target_with_http_info(self, id, **kwargs):  # noqa: E501
        """Get a target corresponding to 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.target_get_target_with_http_info(id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: The unique target id that corresponds to the searched target (required)
        :return: Target
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['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/target/{id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Target',  # 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 target_get_targets(self, **kwargs):  # noqa: E501
        """Get the list of all targets depending on your rights.  # noqa: E501

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

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

    def target_get_targets_with_http_info(self, **kwargs):  # noqa: E501
        """Get the list of all targets depending on your rights.  # noqa: E501

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

        :param async_req bool
        :return: list[Target]
                 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 target_get_targets" % 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/targets', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[Target]',  # 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 target_update_target(self, target_id, updated_target, **kwargs):  # noqa: E501
        """Update a target  # noqa: E501

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

        :param async_req bool
        :param str target_id: The target id corresponding to the target you want to update (required)
        :param Target updated_target: The target to update. (required)
        :return: Target
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.target_update_target_with_http_info(target_id, updated_target, **kwargs)  # noqa: E501
        else:
            (data) = self.target_update_target_with_http_info(target_id, updated_target, **kwargs)  # noqa: E501
            return data

    def target_update_target_with_http_info(self, target_id, updated_target, **kwargs):  # noqa: E501
        """Update a target  # noqa: E501

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

        :param async_req bool
        :param str target_id: The target id corresponding to the target you want to update (required)
        :param Target updated_target: The target to update. (required)
        :return: Target
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'target_id' in params:
            path_params['targetId'] = params['target_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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