# coding: utf-8

"""
    CartoVista.Server.API.v1

    No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)  # noqa: E501

    OpenAPI spec version: v1
    
    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 swagger_client.api_client import ApiClient


class MapApi(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 map_create_map(self, param, **kwargs):  # noqa: E501
        """Create a map based on the provided parameters.  # noqa: E501

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

        :param async_req bool
        :param MapCreateParameter param: Parameters used to create the map. (required)
        :return: Map
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.map_create_map_with_http_info(param, **kwargs)  # noqa: E501
        else:
            (data) = self.map_create_map_with_http_info(param, **kwargs)  # noqa: E501
            return data

    def map_create_map_with_http_info(self, param, **kwargs):  # noqa: E501
        """Create a map based on the provided parameters.  # noqa: E501

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

        :param async_req bool
        :param MapCreateParameter param: Parameters used to create the map. (required)
        :return: Map
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'param' in params:
            body_params = params['param']
        # 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', 'text/json', 'application/x-www-form-urlencoded'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/api/v1/maps', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Map',  # 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 map_delete_map(self, map_id, **kwargs):  # noqa: E501
        """Delete a map by map id or a friendly identifier.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (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.map_delete_map_with_http_info(map_id, **kwargs)  # noqa: E501
        else:
            (data) = self.map_delete_map_with_http_info(map_id, **kwargs)  # noqa: E501
            return data

    def map_delete_map_with_http_info(self, map_id, **kwargs):  # noqa: E501
        """Delete a map by map id or a friendly identifier.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'map_id' in params:
            path_params['mapId'] = params['map_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/api/v1/maps/{mapId}', '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 map_get_grid_layers_by_map(self, map_id, **kwargs):  # noqa: E501
        """Get the list of grid layers used in a map.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (required)
        :return: list[GridLayer]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.map_get_grid_layers_by_map_with_http_info(map_id, **kwargs)  # noqa: E501
        else:
            (data) = self.map_get_grid_layers_by_map_with_http_info(map_id, **kwargs)  # noqa: E501
            return data

    def map_get_grid_layers_by_map_with_http_info(self, map_id, **kwargs):  # noqa: E501
        """Get the list of grid layers used in a map.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (required)
        :return: list[GridLayer]
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'map_id' in params:
            path_params['mapId'] = params['map_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(
            '/api/v1/maps/{mapId}/gridLayers', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[GridLayer]',  # 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 map_get_layers_by_map(self, map_id, **kwargs):  # noqa: E501
        """Get the list of Layers used in a map.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (required)
        :return: list[Layer]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.map_get_layers_by_map_with_http_info(map_id, **kwargs)  # noqa: E501
        else:
            (data) = self.map_get_layers_by_map_with_http_info(map_id, **kwargs)  # noqa: E501
            return data

    def map_get_layers_by_map_with_http_info(self, map_id, **kwargs):  # noqa: E501
        """Get the list of Layers used in a map.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (required)
        :return: list[Layer]
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'map_id' in params:
            path_params['mapId'] = params['map_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(
            '/api/v1/maps/{mapId}/layers', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[Layer]',  # 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 map_get_map(self, map_id, **kwargs):  # noqa: E501
        """Get a map based on the map id or a friendly identifier.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (required)
        :return: Map
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.map_get_map_with_http_info(map_id, **kwargs)  # noqa: E501
        else:
            (data) = self.map_get_map_with_http_info(map_id, **kwargs)  # noqa: E501
            return data

    def map_get_map_with_http_info(self, map_id, **kwargs):  # noqa: E501
        """Get a map based on the map id or a friendly identifier.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (required)
        :return: Map
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'map_id' in params:
            path_params['mapId'] = params['map_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(
            '/api/v1/maps/{mapId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Map',  # 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 map_get_maps(self, **kwargs):  # noqa: E501
        """Get all maps the requesting user has access to.  # noqa: E501

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

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

    def map_get_maps_with_http_info(self, **kwargs):  # noqa: E501
        """Get all maps the requesting user has access to.  # noqa: E501

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

        :param async_req bool
        :return: list[Map]
                 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 map_get_maps" % 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(
            '/api/v1/maps', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[Map]',  # 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 map_update_map(self, map_id, param, **kwargs):  # noqa: E501
        """Update a map properties based on the given parameters.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (required)
        :param MapUpdateParameter param: Parameters used to update the map. (required)
        :return: Map
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.map_update_map_with_http_info(map_id, param, **kwargs)  # noqa: E501
        else:
            (data) = self.map_update_map_with_http_info(map_id, param, **kwargs)  # noqa: E501
            return data

    def map_update_map_with_http_info(self, map_id, param, **kwargs):  # noqa: E501
        """Update a map properties based on the given parameters.  # noqa: E501

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

        :param async_req bool
        :param str map_id: Map id or a friendly identifier. (required)
        :param MapUpdateParameter param: Parameters used to update the map. (required)
        :return: Map
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'map_id' in params:
            path_params['mapId'] = params['map_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'param' in params:
            body_params = params['param']
        # 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', 'text/json', 'application/x-www-form-urlencoded'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/api/v1/maps/{mapId}', 'PATCH',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Map',  # 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)
