"""
    Query API v1

    The `query` service provides a way to get information (metadata) about layers and partitions stored in a catalog. This service exposes the metadata for single partitions that users can query one by one or by specifying a parent tile.  # noqa: E501

    The version of the OpenAPI document: 1.0.3
    Generated by: https://openapi-generator.tech
"""


import re  # noqa: F401
import sys  # noqa: F401

from here_data_query_v1_client.api_client import ApiClient, Endpoint
from here_data_query_v1_client.model_utils import (  # noqa: F401
    check_allowed_values,
    check_validations,
    date,
    datetime,
    file_type,
    none_type,
    validate_and_convert_types
)
from here_data_query_v1_client.model.index import Index
from here_data_query_v1_client.model.partitions import Partitions


class QueryApi(object):
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

        def __get_changes_by_id(
            self,
            layer_id,
            partition,
            **kwargs
        ):
            """Gets changes for the version or time range for the specific partition(s).  # noqa: E501

            Gets the latest partition changes for a version range in a versioned layer or a time range for a volatile layer. Only the latest change for each changed partition is returned, not intermediate changes. If the response contains a partition with an empty 'dataHandle' value, the partition was deleted at the version indicated by the 'version' field of the partition object. If a partition was created and deleted between the versions specified in the 'startVersion' and 'endVersion' parameters, the partition is not included in the response. For example, if you request versions 0 to 10, and a partition was created in version 3 then deleted in version 7, it is not included in the response.  # noqa: E501
            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please pass async_req=True

            >>> thread = api.get_changes_by_id(layer_id, partition, async_req=True)
            >>> result = thread.get()

            Args:
                layer_id (str): The ID of the layer specified in the request. The value of this parameter must refer to a valid layer already configured in the catalog configuration. You can specify multiple layers as additional parameters.
                partition ([str]): The partitions you want to include in the response. This allows you to limit the response to specific partitions. You can specify multiple partitions by using this parameter multiple times. The maximum number of partitions per call is 100.

            Keyword Args:
                start_version (str): Start version for the catalog (exclusive). By convention -1 indicates the virtual initial version before the first publication which will have version 0.. [optional]
                end_version (str): End version (inclusive). This has to be a valid catalog version greater than the startVersion.. [optional]
                since_time (int): Will return partitions whose data has been modified since this time, in milliseconds since epoch, inclusive.. [optional]
                additional_fields ([str]): Additional fields - `dataSize`, `checksum`, `compressedDataSize`, `crc`.. [optional]
                billing_tag (str): Billing Tag is an optional free-form tag which is used for grouping billing records together. If supplied, it must be between 4 - 16 characters, contain only alpha/numeric ASCII characters  [A-Za-z0-9]. Grouping billing records by billing tag will be available in future releases.. [optional]
                _return_http_data_only (bool): response data without head status
                    code and headers. Default is True.
                _preload_content (bool): if False, the urllib3.HTTPResponse object
                    will be returned without reading/decoding response data.
                    Default is True.
                _request_timeout (float/tuple): timeout setting for this request. If one
                    number provided, it will be total request timeout. It can also
                    be a pair (tuple) of (connection, read) timeouts.
                    Default is None.
                _check_input_type (bool): specifies if type checking
                    should be done one the data sent to the server.
                    Default is True.
                _check_return_type (bool): specifies if type checking
                    should be done one the data received from the server.
                    Default is True.
                _host_index (int/None): specifies the index of the server
                    that we want to use.
                    Default is read from the configuration.
                async_req (bool): execute request asynchronously

            Returns:
                Partitions
                    If the method is called asynchronously, returns the request
                    thread.
            """
            kwargs['async_req'] = kwargs.get(
                'async_req', False
            )
            kwargs['_return_http_data_only'] = kwargs.get(
                '_return_http_data_only', True
            )
            kwargs['_preload_content'] = kwargs.get(
                '_preload_content', True
            )
            kwargs['_request_timeout'] = kwargs.get(
                '_request_timeout', None
            )
            kwargs['_check_input_type'] = kwargs.get(
                '_check_input_type', True
            )
            kwargs['_check_return_type'] = kwargs.get(
                '_check_return_type', True
            )
            kwargs['_host_index'] = kwargs.get('_host_index')
            kwargs['layer_id'] = \
                layer_id
            kwargs['partition'] = \
                partition
            return self.call_with_http_info(**kwargs)

        self.get_changes_by_id = Endpoint(
            settings={
                'response_type': (Partitions,),
                'auth': [
                    'Bearer'
                ],
                'endpoint_path': '/layers/{layerId}/changes',
                'operation_id': 'get_changes_by_id',
                'http_method': 'GET',
                'servers': None,
            },
            params_map={
                'all': [
                    'layer_id',
                    'partition',
                    'start_version',
                    'end_version',
                    'since_time',
                    'additional_fields',
                    'billing_tag',
                ],
                'required': [
                    'layer_id',
                    'partition',
                ],
                'nullable': [
                ],
                'enum': [
                    'additional_fields',
                ],
                'validation': [
                ]
            },
            root_map={
                'validations': {
                },
                'allowed_values': {
                    ('additional_fields',): {

                        "DATASIZE": "dataSize",
                        "CHECKSUM": "checksum",
                        "COMPRESSEDDATASIZE": "compressedDataSize",
                        "CRC": "crc"
                    },
                },
                'openapi_types': {
                    'layer_id':
                        (str,),
                    'partition':
                        ([str],),
                    'start_version':
                        (str,),
                    'end_version':
                        (str,),
                    'since_time':
                        (int,),
                    'additional_fields':
                        ([str],),
                    'billing_tag':
                        (str,),
                },
                'attribute_map': {
                    'layer_id': 'layerId',
                    'partition': 'partition',
                    'start_version': 'startVersion',
                    'end_version': 'endVersion',
                    'since_time': 'sinceTime',
                    'additional_fields': 'additionalFields',
                    'billing_tag': 'billingTag',
                },
                'location_map': {
                    'layer_id': 'path',
                    'partition': 'query',
                    'start_version': 'query',
                    'end_version': 'query',
                    'since_time': 'query',
                    'additional_fields': 'query',
                    'billing_tag': 'query',
                },
                'collection_format_map': {
                    'partition': 'multi',
                    'additional_fields': 'csv',
                }
            },
            headers_map={
                'accept': [
                    'application/json'
                ],
                'content_type': [],
            },
            api_client=api_client,
            callable=__get_changes_by_id
        )

        def __get_partitions_by_id(
            self,
            layer_id,
            partition,
            **kwargs
        ):
            """Gets metadata for the requested partitions  # noqa: E501

            Gets metadata for specific partition ids. If the layer specified in the request does not exist, the request results in an error. If a partition specified in the request does not exist, the response does not include this partition. Maximun allowed number of partitions ids per call is 100.  # noqa: E501
            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please pass async_req=True

            >>> thread = api.get_partitions_by_id(layer_id, partition, async_req=True)
            >>> result = thread.get()

            Args:
                layer_id (str): The ID of the layer specified in the request. The content of this parameter must refer to a valid layer already configured in the catalog configuration. You can specify multiple partitions by using this parameter multiple times.
                partition ([str]): Partition ids to use for filtering. You can specify multiple partitions by using this parameter multiple times. Maximum allowed partitions ids per call is 100.

            Keyword Args:
                version (str): The version of the catalog against which to run the query. Must be a valid catalog version.. [optional]
                additional_fields ([str]): Additional fields - `dataSize`, `checksum`, `compressedDataSize`, `crc`.. [optional]
                billing_tag (str): Billing Tag is an optional free-form tag which is used for grouping billing records together. If supplied, it must be between 4 - 16 characters, contain only alpha/numeric ASCII characters  [A-Za-z0-9]. Grouping billing records by billing tag will be available in future releases.. [optional]
                _return_http_data_only (bool): response data without head status
                    code and headers. Default is True.
                _preload_content (bool): if False, the urllib3.HTTPResponse object
                    will be returned without reading/decoding response data.
                    Default is True.
                _request_timeout (float/tuple): timeout setting for this request. If one
                    number provided, it will be total request timeout. It can also
                    be a pair (tuple) of (connection, read) timeouts.
                    Default is None.
                _check_input_type (bool): specifies if type checking
                    should be done one the data sent to the server.
                    Default is True.
                _check_return_type (bool): specifies if type checking
                    should be done one the data received from the server.
                    Default is True.
                _host_index (int/None): specifies the index of the server
                    that we want to use.
                    Default is read from the configuration.
                async_req (bool): execute request asynchronously

            Returns:
                Partitions
                    If the method is called asynchronously, returns the request
                    thread.
            """
            kwargs['async_req'] = kwargs.get(
                'async_req', False
            )
            kwargs['_return_http_data_only'] = kwargs.get(
                '_return_http_data_only', True
            )
            kwargs['_preload_content'] = kwargs.get(
                '_preload_content', True
            )
            kwargs['_request_timeout'] = kwargs.get(
                '_request_timeout', None
            )
            kwargs['_check_input_type'] = kwargs.get(
                '_check_input_type', True
            )
            kwargs['_check_return_type'] = kwargs.get(
                '_check_return_type', True
            )
            kwargs['_host_index'] = kwargs.get('_host_index')
            kwargs['layer_id'] = \
                layer_id
            kwargs['partition'] = \
                partition
            return self.call_with_http_info(**kwargs)

        self.get_partitions_by_id = Endpoint(
            settings={
                'response_type': (Partitions,),
                'auth': [
                    'Bearer'
                ],
                'endpoint_path': '/layers/{layerId}/partitions',
                'operation_id': 'get_partitions_by_id',
                'http_method': 'GET',
                'servers': None,
            },
            params_map={
                'all': [
                    'layer_id',
                    'partition',
                    'version',
                    'additional_fields',
                    'billing_tag',
                ],
                'required': [
                    'layer_id',
                    'partition',
                ],
                'nullable': [
                ],
                'enum': [
                    'additional_fields',
                ],
                'validation': [
                ]
            },
            root_map={
                'validations': {
                },
                'allowed_values': {
                    ('additional_fields',): {

                        "DATASIZE": "dataSize",
                        "CHECKSUM": "checksum",
                        "COMPRESSEDDATASIZE": "compressedDataSize",
                        "CRC": "crc"
                    },
                },
                'openapi_types': {
                    'layer_id':
                        (str,),
                    'partition':
                        ([str],),
                    'version':
                        (str,),
                    'additional_fields':
                        ([str],),
                    'billing_tag':
                        (str,),
                },
                'attribute_map': {
                    'layer_id': 'layerId',
                    'partition': 'partition',
                    'version': 'version',
                    'additional_fields': 'additionalFields',
                    'billing_tag': 'billingTag',
                },
                'location_map': {
                    'layer_id': 'path',
                    'partition': 'query',
                    'version': 'query',
                    'additional_fields': 'query',
                    'billing_tag': 'query',
                },
                'collection_format_map': {
                    'partition': 'multi',
                    'additional_fields': 'csv',
                }
            },
            headers_map={
                'accept': [
                    'application/json'
                ],
                'content_type': [],
            },
            api_client=api_client,
            callable=__get_partitions_by_id
        )

        def __quad_tree_index(
            self,
            layer_id,
            version,
            quad_key,
            depth,
            **kwargs
        ):
            """Gets index metadata of versioned  # noqa: E501

            Gets metadata for the requested index. Only available for versioned layers where the partitioning scheme is `heretile`.  # noqa: E501
            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please pass async_req=True

            >>> thread = api.quad_tree_index(layer_id, version, quad_key, depth, async_req=True)
            >>> result = thread.get()

            Args:
                layer_id (str): The ID of the layer specified in the request. Content of this parameter must refer to a valid layer already configured in the catalog configuration. Exactly one layer ID must be provided.
                version (int): The version of the catalog against which to run the query. Must be a valid catalog version.
                quad_key (str): The geometric area specified by an index in the request, represented as a HERE tile
                depth (int): The recursion depth of the response. If set to 0, the response includes only data for the quadKey specified in the request. In this way, depth describes the maximum length of the subQuadKeys in the response. The maximum allowed value for the depth parameter is 4.

            Keyword Args:
                additional_fields ([str]): Additional fields - `dataSize`, `checksum`, `compressedDataSize`, `crc`.. [optional]
                billing_tag (str): Billing Tag is an optional free-form tag used to group billing records together. If supplied, it must be between 4 - 16 characters and  contain only alphanumeric ASCII characters  [A-Za-z0-9]. Grouping billing records by billing tag will be available in a future release.. [optional]
                _return_http_data_only (bool): response data without head status
                    code and headers. Default is True.
                _preload_content (bool): if False, the urllib3.HTTPResponse object
                    will be returned without reading/decoding response data.
                    Default is True.
                _request_timeout (float/tuple): timeout setting for this request. If one
                    number provided, it will be total request timeout. It can also
                    be a pair (tuple) of (connection, read) timeouts.
                    Default is None.
                _check_input_type (bool): specifies if type checking
                    should be done one the data sent to the server.
                    Default is True.
                _check_return_type (bool): specifies if type checking
                    should be done one the data received from the server.
                    Default is True.
                _host_index (int/None): specifies the index of the server
                    that we want to use.
                    Default is read from the configuration.
                async_req (bool): execute request asynchronously

            Returns:
                Index
                    If the method is called asynchronously, returns the request
                    thread.
            """
            kwargs['async_req'] = kwargs.get(
                'async_req', False
            )
            kwargs['_return_http_data_only'] = kwargs.get(
                '_return_http_data_only', True
            )
            kwargs['_preload_content'] = kwargs.get(
                '_preload_content', True
            )
            kwargs['_request_timeout'] = kwargs.get(
                '_request_timeout', None
            )
            kwargs['_check_input_type'] = kwargs.get(
                '_check_input_type', True
            )
            kwargs['_check_return_type'] = kwargs.get(
                '_check_return_type', True
            )
            kwargs['_host_index'] = kwargs.get('_host_index')
            kwargs['layer_id'] = \
                layer_id
            kwargs['version'] = \
                version
            kwargs['quad_key'] = \
                quad_key
            kwargs['depth'] = \
                depth
            return self.call_with_http_info(**kwargs)

        self.quad_tree_index = Endpoint(
            settings={
                'response_type': (Index,),
                'auth': [
                    'Bearer'
                ],
                'endpoint_path': '/layers/{layerId}/versions/{version}/quadkeys/{quadKey}/depths/{depth}',
                'operation_id': 'quad_tree_index',
                'http_method': 'GET',
                'servers': None,
            },
            params_map={
                'all': [
                    'layer_id',
                    'version',
                    'quad_key',
                    'depth',
                    'additional_fields',
                    'billing_tag',
                ],
                'required': [
                    'layer_id',
                    'version',
                    'quad_key',
                    'depth',
                ],
                'nullable': [
                ],
                'enum': [
                    'additional_fields',
                ],
                'validation': [
                ]
            },
            root_map={
                'validations': {
                },
                'allowed_values': {
                    ('additional_fields',): {

                        "DATASIZE": "dataSize",
                        "CHECKSUM": "checksum",
                        "COMPRESSEDDATASIZE": "compressedDataSize",
                        "CRC": "crc"
                    },
                },
                'openapi_types': {
                    'layer_id':
                        (str,),
                    'version':
                        (int,),
                    'quad_key':
                        (str,),
                    'depth':
                        (int,),
                    'additional_fields':
                        ([str],),
                    'billing_tag':
                        (str,),
                },
                'attribute_map': {
                    'layer_id': 'layerId',
                    'version': 'version',
                    'quad_key': 'quadKey',
                    'depth': 'depth',
                    'additional_fields': 'additionalFields',
                    'billing_tag': 'billingTag',
                },
                'location_map': {
                    'layer_id': 'path',
                    'version': 'path',
                    'quad_key': 'path',
                    'depth': 'path',
                    'additional_fields': 'query',
                    'billing_tag': 'query',
                },
                'collection_format_map': {
                    'additional_fields': 'csv',
                }
            },
            headers_map={
                'accept': [
                    'application/json'
                ],
                'content_type': [],
            },
            api_client=api_client,
            callable=__quad_tree_index
        )

        def __quad_tree_index_volatile(
            self,
            layer_id,
            quad_key,
            depth,
            **kwargs
        ):
            """Gets index metadata for volatile layers  # noqa: E501

            Gets metadata for the requested index. Only available for volatile layers where the partitioning scheme is `heretile`.  # noqa: E501
            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please pass async_req=True

            >>> thread = api.quad_tree_index_volatile(layer_id, quad_key, depth, async_req=True)
            >>> result = thread.get()

            Args:
                layer_id (str): The ID of the layer specified in the request. Content of this parameter must refer to a valid layer already configured in the catalog configuration. Exactly one layer ID must be provided.
                quad_key (str): The geometric area specified by an index in the request, represented as a HERE tile
                depth (int): The recursion depth of the response. If set to 0, the response includes only data for the quadKey specified in the request. In this way, depth describes the maximum length of the subQuadKeys in the response. The maximum allowed value for the depth parameter is 4.

            Keyword Args:
                additional_fields ([str]): Additional fields - `dataSize`, `checksum`, `compressedDataSize`, `crc`.. [optional]
                billing_tag (str): Billing Tag is an optional free-form tag used to group billing records together. If supplied, it must be between 4 - 16 characters and  contain only alphanumeric ASCII characters  [A-Za-z0-9]. Grouping billing records by billing tag will be available in a future release.. [optional]
                _return_http_data_only (bool): response data without head status
                    code and headers. Default is True.
                _preload_content (bool): if False, the urllib3.HTTPResponse object
                    will be returned without reading/decoding response data.
                    Default is True.
                _request_timeout (float/tuple): timeout setting for this request. If one
                    number provided, it will be total request timeout. It can also
                    be a pair (tuple) of (connection, read) timeouts.
                    Default is None.
                _check_input_type (bool): specifies if type checking
                    should be done one the data sent to the server.
                    Default is True.
                _check_return_type (bool): specifies if type checking
                    should be done one the data received from the server.
                    Default is True.
                _host_index (int/None): specifies the index of the server
                    that we want to use.
                    Default is read from the configuration.
                async_req (bool): execute request asynchronously

            Returns:
                Index
                    If the method is called asynchronously, returns the request
                    thread.
            """
            kwargs['async_req'] = kwargs.get(
                'async_req', False
            )
            kwargs['_return_http_data_only'] = kwargs.get(
                '_return_http_data_only', True
            )
            kwargs['_preload_content'] = kwargs.get(
                '_preload_content', True
            )
            kwargs['_request_timeout'] = kwargs.get(
                '_request_timeout', None
            )
            kwargs['_check_input_type'] = kwargs.get(
                '_check_input_type', True
            )
            kwargs['_check_return_type'] = kwargs.get(
                '_check_return_type', True
            )
            kwargs['_host_index'] = kwargs.get('_host_index')
            kwargs['layer_id'] = \
                layer_id
            kwargs['quad_key'] = \
                quad_key
            kwargs['depth'] = \
                depth
            return self.call_with_http_info(**kwargs)

        self.quad_tree_index_volatile = Endpoint(
            settings={
                'response_type': (Index,),
                'auth': [
                    'Bearer'
                ],
                'endpoint_path': '/layers/{layerId}/quadkeys/{quadKey}/depths/{depth}',
                'operation_id': 'quad_tree_index_volatile',
                'http_method': 'GET',
                'servers': None,
            },
            params_map={
                'all': [
                    'layer_id',
                    'quad_key',
                    'depth',
                    'additional_fields',
                    'billing_tag',
                ],
                'required': [
                    'layer_id',
                    'quad_key',
                    'depth',
                ],
                'nullable': [
                ],
                'enum': [
                    'additional_fields',
                ],
                'validation': [
                ]
            },
            root_map={
                'validations': {
                },
                'allowed_values': {
                    ('additional_fields',): {

                        "DATASIZE": "dataSize",
                        "CHECKSUM": "checksum",
                        "COMPRESSEDDATASIZE": "compressedDataSize",
                        "CRC": "crc"
                    },
                },
                'openapi_types': {
                    'layer_id':
                        (str,),
                    'quad_key':
                        (str,),
                    'depth':
                        (int,),
                    'additional_fields':
                        ([str],),
                    'billing_tag':
                        (str,),
                },
                'attribute_map': {
                    'layer_id': 'layerId',
                    'quad_key': 'quadKey',
                    'depth': 'depth',
                    'additional_fields': 'additionalFields',
                    'billing_tag': 'billingTag',
                },
                'location_map': {
                    'layer_id': 'path',
                    'quad_key': 'path',
                    'depth': 'path',
                    'additional_fields': 'query',
                    'billing_tag': 'query',
                },
                'collection_format_map': {
                    'additional_fields': 'csv',
                }
            },
            headers_map={
                'accept': [
                    'application/json'
                ],
                'content_type': [],
            },
            api_client=api_client,
            callable=__quad_tree_index_volatile
        )
