"""
    Publish API v2

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501

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


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

from here_data_publish_v2_client.api_client import ApiClient, Endpoint as _Endpoint
from here_data_publish_v2_client.model_utils import (  # noqa: F401
    check_allowed_values,
    check_validations,
    date,
    datetime,
    file_type,
    none_type,
    validate_and_convert_types
)
from here_data_publish_v2_client.model.publication import Publication
from here_data_publish_v2_client.model.publish_partitions import PublishPartitions


class PublishApi(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 __cancel_publication(
            self,
            publication_id,
            **kwargs
        ):
            """Cancels a publication  # noqa: E501

            Cancels a publication if it has not yet been submitted. Will fail if attempting to cancel a submitted publication. This allows the specified publication to be abandoned.  See Data API Developer’s Guide in the Documentation section for publication states diagram and all possible publication states transitions.  # noqa: E501
            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please pass async_req=True

            >>> thread = api.cancel_publication(publication_id, async_req=True)
            >>> result = thread.get()

            Args:
                publication_id (str): The ID of the publication to cancel.

            Keyword Args:
                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 and contain only alphanumeric 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:
                None
                    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['publication_id'] = \
                publication_id
            return self.call_with_http_info(**kwargs)

        self.cancel_publication = _Endpoint(
            settings={
                'response_type': None,
                'auth': [
                    'Bearer'
                ],
                'endpoint_path': '/publications/{publicationId}',
                'operation_id': 'cancel_publication',
                'http_method': 'DELETE',
                'servers': None,
            },
            params_map={
                'all': [
                    'publication_id',
                    'billing_tag',
                ],
                'required': [
                    'publication_id',
                ],
                'nullable': [
                ],
                'enum': [
                ],
                'validation': [
                ]
            },
            root_map={
                'validations': {
                },
                'allowed_values': {
                },
                'openapi_types': {
                    'publication_id':
                        (str,),
                    'billing_tag':
                        (str,),
                },
                'attribute_map': {
                    'publication_id': 'publicationId',
                    'billing_tag': 'billingTag',
                },
                'location_map': {
                    'publication_id': 'path',
                    'billing_tag': 'query',
                },
                'collection_format_map': {
                }
            },
            headers_map={
                'accept': [],
                'content_type': [],
            },
            api_client=api_client,
            callable=__cancel_publication
        )

        def __get_publication(
            self,
            publication_id,
            **kwargs
        ):
            """Gets a publication  # noqa: E501

            Returns the details of the specified publication. Publication can be in one of these states: Initialized, Submitted, Cancelled, Failed, Succeeded, Expired. See Data API Developer’s Guide in the Documentation section for the publication state diagram.  # 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_publication(publication_id, async_req=True)
            >>> result = thread.get()

            Args:
                publication_id (str): The ID of the publication to retrieve.

            Keyword Args:
                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 and contain only alphanumeric 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:
                Publication
                    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['publication_id'] = \
                publication_id
            return self.call_with_http_info(**kwargs)

        self.get_publication = _Endpoint(
            settings={
                'response_type': (Publication,),
                'auth': [
                    'Bearer'
                ],
                'endpoint_path': '/publications/{publicationId}',
                'operation_id': 'get_publication',
                'http_method': 'GET',
                'servers': None,
            },
            params_map={
                'all': [
                    'publication_id',
                    'billing_tag',
                ],
                'required': [
                    'publication_id',
                ],
                'nullable': [
                ],
                'enum': [
                ],
                'validation': [
                ]
            },
            root_map={
                'validations': {
                },
                'allowed_values': {
                },
                'openapi_types': {
                    'publication_id':
                        (str,),
                    'billing_tag':
                        (str,),
                },
                'attribute_map': {
                    'publication_id': 'publicationId',
                    'billing_tag': 'billingTag',
                },
                'location_map': {
                    'publication_id': 'path',
                    'billing_tag': 'query',
                },
                'collection_format_map': {
                }
            },
            headers_map={
                'accept': [
                    'application/json'
                ],
                'content_type': [],
            },
            api_client=api_client,
            callable=__get_publication
        )

        def __init_publication(
            self,
            body,
            **kwargs
        ):
            """Initialize a new publication  # noqa: E501

            Initializes a new publication for publishing metadata. Determines the publication type based on the provided layer IDs. A publication can only consist of layer IDs that have the same layer type. For example, you can have a publication for multiple layers of type `versioned`, but you cannot have a single publication that publishes to both `versioned` and `stream` layers. In addition, you may only have one `versioned` or `volatile` publication in process at a time. You cannot have multiple active publications to the same catalog for `versioned` and `volatile` layer types. The body field `versionDependencies` is optional and is used for `versioned` layers to declare version dependencies.  # noqa: E501
            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please pass async_req=True

            >>> thread = api.init_publication(body, async_req=True)
            >>> result = thread.get()

            Args:
                body (Publication): Fields to initialize a publication.

            Keyword Args:
                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:
                Publication
                    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['body'] = \
                body
            return self.call_with_http_info(**kwargs)

        self.init_publication = _Endpoint(
            settings={
                'response_type': (Publication,),
                'auth': [
                    'Bearer'
                ],
                'endpoint_path': '/publications',
                'operation_id': 'init_publication',
                'http_method': 'POST',
                'servers': None,
            },
            params_map={
                'all': [
                    'body',
                    'billing_tag',
                ],
                'required': [
                    'body',
                ],
                'nullable': [
                ],
                'enum': [
                ],
                'validation': [
                ]
            },
            root_map={
                'validations': {
                },
                'allowed_values': {
                },
                'openapi_types': {
                    'body':
                        (Publication,),
                    'billing_tag':
                        (str,),
                },
                'attribute_map': {
                    'billing_tag': 'billingTag',
                },
                'location_map': {
                    'body': 'body',
                    'billing_tag': 'query',
                },
                'collection_format_map': {
                }
            },
            headers_map={
                'accept': [
                    'application/json'
                ],
                'content_type': [
                    'application/json'
                ]
            },
            api_client=api_client,
            callable=__init_publication
        )

        def __submit_publication(
            self,
            publication_id,
            **kwargs
        ):
            """Submits a publication  # noqa: E501

            Submits the publication and initiates post processing if necessary. Publication state becomes `Submitted` directly after submission and `Succeeded` after successful processing. See Data API Developer’s Guide in the Documentation section for complete publication states diagram.  # noqa: E501
            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please pass async_req=True

            >>> thread = api.submit_publication(publication_id, async_req=True)
            >>> result = thread.get()

            Args:
                publication_id (str): ID of publication to submit.

            Keyword Args:
                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 and contain only alphanumeric 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:
                None
                    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['publication_id'] = \
                publication_id
            return self.call_with_http_info(**kwargs)

        self.submit_publication = _Endpoint(
            settings={
                'response_type': None,
                'auth': [
                    'Bearer'
                ],
                'endpoint_path': '/publications/{publicationId}',
                'operation_id': 'submit_publication',
                'http_method': 'PUT',
                'servers': None,
            },
            params_map={
                'all': [
                    'publication_id',
                    'billing_tag',
                ],
                'required': [
                    'publication_id',
                ],
                'nullable': [
                ],
                'enum': [
                ],
                'validation': [
                ]
            },
            root_map={
                'validations': {
                },
                'allowed_values': {
                },
                'openapi_types': {
                    'publication_id':
                        (str,),
                    'billing_tag':
                        (str,),
                },
                'attribute_map': {
                    'publication_id': 'publicationId',
                    'billing_tag': 'billingTag',
                },
                'location_map': {
                    'publication_id': 'path',
                    'billing_tag': 'query',
                },
                'collection_format_map': {
                }
            },
            headers_map={
                'accept': [],
                'content_type': [],
            },
            api_client=api_client,
            callable=__submit_publication
        )

        def __upload_partitions(
            self,
            layer_id,
            publication_id,
            body,
            **kwargs
        ):
            """Upload partitions  # noqa: E501

            Upload partitions to the given layer. Dependending on the publication type, post processing may be required before the partitions are published. For better performance batch your partitions (e.g. 1000 per request), rather than uploading them individually.  # noqa: E501
            This method makes a synchronous HTTP request by default. To make an
            asynchronous HTTP request, please pass async_req=True

            >>> thread = api.upload_partitions(layer_id, publication_id, body, async_req=True)
            >>> result = thread.get()

            Args:
                layer_id (str): The ID of the layer to publish to.
                publication_id (str): The ID of publication to publish to.
                body (PublishPartitions): Publication partitions. Data and DataHandle fields cannot be populated at the same time. See Partition object for more details on body fields

            Keyword Args:
                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 and contain only alphanumeric 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:
                None
                    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['publication_id'] = \
                publication_id
            kwargs['body'] = \
                body
            return self.call_with_http_info(**kwargs)

        self.upload_partitions = _Endpoint(
            settings={
                'response_type': None,
                'auth': [
                    'Bearer'
                ],
                'endpoint_path': '/layers/{layerId}/publications/{publicationId}/partitions',
                'operation_id': 'upload_partitions',
                'http_method': 'POST',
                'servers': None,
            },
            params_map={
                'all': [
                    'layer_id',
                    'publication_id',
                    'body',
                    'billing_tag',
                ],
                'required': [
                    'layer_id',
                    'publication_id',
                    'body',
                ],
                'nullable': [
                ],
                'enum': [
                ],
                'validation': [
                ]
            },
            root_map={
                'validations': {
                },
                'allowed_values': {
                },
                'openapi_types': {
                    'layer_id':
                        (str,),
                    'publication_id':
                        (str,),
                    'body':
                        (PublishPartitions,),
                    'billing_tag':
                        (str,),
                },
                'attribute_map': {
                    'layer_id': 'layerId',
                    'publication_id': 'publicationId',
                    'billing_tag': 'billingTag',
                },
                'location_map': {
                    'layer_id': 'path',
                    'publication_id': 'path',
                    'body': 'body',
                    'billing_tag': 'query',
                },
                'collection_format_map': {
                }
            },
            headers_map={
                'accept': [],
                'content_type': [
                    'application/json'
                ]
            },
            api_client=api_client,
            callable=__upload_partitions
        )
