# coding: utf-8

"""
    PDF stamper

    The PDF Stamper API enables the possibility to add both static and dynamic stamps on existing PDFs. The stamps can consist of one or more barcode, hyperlink, image, line or text elements.    The flow is generally as follows:  1. Make a configuration containing the stamp information  2. Create a job specifying the desired configuration  3. Add one or more PDF files to the job  4. Start the job for processing  5. Retrieve the processed files    Full API Documentation: https://docs.sphereon.com/api/pdf-stamper/1.0  Interactive testing: A web based test console is available in the Sphereon API Store at https://store.sphereon.com

    OpenAPI spec version: 1.0
    Contact: dev@sphereon.com
    Generated by: https://github.com/swagger-api/swagger-codegen.git

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""

from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..configuration import Configuration
from ..api_client import ApiClient


class ConfigApi(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):
        config = Configuration()
        if api_client:
            self.api_client = api_client
        else:
            if not config.api_client:
                config.api_client = ApiClient()
            self.api_client = config.api_client

    def create_configuration(self, stamp_configuration, **kwargs):
        """
        Create PDF stamper configuration
        Create / initialize a new PDF stamper configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.create_configuration(stamp_configuration, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param StamperConfig stamp_configuration: The PDF stamper configuration (required)
        :return: StamperConfigResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.create_configuration_with_http_info(stamp_configuration, **kwargs)
        else:
            (data) = self.create_configuration_with_http_info(stamp_configuration, **kwargs)
            return data

    def create_configuration_with_http_info(self, stamp_configuration, **kwargs):
        """
        Create PDF stamper configuration
        Create / initialize a new PDF stamper configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.create_configuration_with_http_info(stamp_configuration, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param StamperConfig stamp_configuration: The PDF stamper configuration (required)
        :return: StamperConfigResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['stamp_configuration']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_configuration" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'stamp_configuration' is set
        if ('stamp_configuration' not in params) or (params['stamp_configuration'] is None):
            raise ValueError("Missing the required parameter `stamp_configuration` when calling `create_configuration`")

        resource_path = '/config'.replace('{format}', 'json')
        path_params = {}

        query_params = {}

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'stamp_configuration' in params:
            body_params = params['stamp_configuration']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json;charset=UTF-8'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json;charset=UTF-8'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api(resource_path, 'POST',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='StamperConfigResponse',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))

    def delete_configuration(self, config_id, **kwargs):
        """
        Delete PDF stamper configuration
        Delete a PDF stamper configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.delete_configuration(config_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: The PDF stamper configuration id (required)
        :return: StamperConfigResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.delete_configuration_with_http_info(config_id, **kwargs)
        else:
            (data) = self.delete_configuration_with_http_info(config_id, **kwargs)
            return data

    def delete_configuration_with_http_info(self, config_id, **kwargs):
        """
        Delete PDF stamper configuration
        Delete a PDF stamper configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.delete_configuration_with_http_info(config_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: The PDF stamper configuration id (required)
        :return: StamperConfigResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['config_id']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_configuration" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'config_id' is set
        if ('config_id' not in params) or (params['config_id'] is None):
            raise ValueError("Missing the required parameter `config_id` when calling `delete_configuration`")

        resource_path = '/config/{configId}'.replace('{format}', 'json')
        path_params = {}
        if 'config_id' in params:
            path_params['configId'] = params['config_id']

        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;charset=UTF-8'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type([])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api(resource_path, 'DELETE',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='StamperConfigResponse',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))

    def delete_resources(self, config_id, stream_locations, **kwargs):
        """
        Delete resources
        Delete resources referenced by a configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.delete_resources(config_id, stream_locations, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: The PDF stamper configuration id (required)
        :param list[StreamLocation] stream_locations: The resource locations in storage (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.delete_resources_with_http_info(config_id, stream_locations, **kwargs)
        else:
            (data) = self.delete_resources_with_http_info(config_id, stream_locations, **kwargs)
            return data

    def delete_resources_with_http_info(self, config_id, stream_locations, **kwargs):
        """
        Delete resources
        Delete resources referenced by a configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.delete_resources_with_http_info(config_id, stream_locations, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: The PDF stamper configuration id (required)
        :param list[StreamLocation] stream_locations: The resource locations in storage (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['config_id', 'stream_locations']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_resources" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'config_id' is set
        if ('config_id' not in params) or (params['config_id'] is None):
            raise ValueError("Missing the required parameter `config_id` when calling `delete_resources`")
        # verify the required parameter 'stream_locations' is set
        if ('stream_locations' not in params) or (params['stream_locations'] is None):
            raise ValueError("Missing the required parameter `stream_locations` when calling `delete_resources`")

        resource_path = '/config/{configId}/streams'.replace('{format}', 'json')
        path_params = {}
        if 'config_id' in params:
            path_params['configId'] = params['config_id']

        query_params = {}

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'stream_locations' in params:
            body_params = params['stream_locations']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['*/*'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type([])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api(resource_path, 'DELETE',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type=None,
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))

    def get_configuration(self, config_id, **kwargs):
        """
        Get PDF stamper configuration
        Retrieve a PDF stamper configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_configuration(config_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: The PDF stamper configuration id (required)
        :return: StamperConfigResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.get_configuration_with_http_info(config_id, **kwargs)
        else:
            (data) = self.get_configuration_with_http_info(config_id, **kwargs)
            return data

    def get_configuration_with_http_info(self, config_id, **kwargs):
        """
        Get PDF stamper configuration
        Retrieve a PDF stamper configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.get_configuration_with_http_info(config_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: The PDF stamper configuration id (required)
        :return: StamperConfigResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['config_id']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_configuration" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'config_id' is set
        if ('config_id' not in params) or (params['config_id'] is None):
            raise ValueError("Missing the required parameter `config_id` when calling `get_configuration`")

        resource_path = '/config/{configId}'.replace('{format}', 'json')
        path_params = {}
        if 'config_id' in params:
            path_params['configId'] = params['config_id']

        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;charset=UTF-8'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type([])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='StamperConfigResponse',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))

    def update_configuration(self, config_id, stamp_configuration, **kwargs):
        """
        Update PDF stamper configuration
        Update an existing PDF stamper configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.update_configuration(config_id, stamp_configuration, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: The PDF stamper configuration id (required)
        :param StamperConfig stamp_configuration: The PDF stamper configuration (required)
        :return: StamperConfigResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.update_configuration_with_http_info(config_id, stamp_configuration, **kwargs)
        else:
            (data) = self.update_configuration_with_http_info(config_id, stamp_configuration, **kwargs)
            return data

    def update_configuration_with_http_info(self, config_id, stamp_configuration, **kwargs):
        """
        Update PDF stamper configuration
        Update an existing PDF stamper configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.update_configuration_with_http_info(config_id, stamp_configuration, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: The PDF stamper configuration id (required)
        :param StamperConfig stamp_configuration: The PDF stamper configuration (required)
        :return: StamperConfigResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['config_id', 'stamp_configuration']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_configuration" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'config_id' is set
        if ('config_id' not in params) or (params['config_id'] is None):
            raise ValueError("Missing the required parameter `config_id` when calling `update_configuration`")
        # verify the required parameter 'stamp_configuration' is set
        if ('stamp_configuration' not in params) or (params['stamp_configuration'] is None):
            raise ValueError("Missing the required parameter `stamp_configuration` when calling `update_configuration`")

        resource_path = '/config/{configId}'.replace('{format}', 'json')
        path_params = {}
        if 'config_id' in params:
            path_params['configId'] = params['config_id']

        query_params = {}

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'stamp_configuration' in params:
            body_params = params['stamp_configuration']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json;charset=UTF-8'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json;charset=UTF-8'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api(resource_path, 'PUT',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='StamperConfigResponse',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))

    def upload_resource(self, config_id, stream, **kwargs):
        """
        Upload a configuration resource
        Upload a resource needed by a configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.upload_resource(config_id, stream, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: configId (required)
        :param file stream: The resource data (required)
        :return: StreamLocation
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.upload_resource_with_http_info(config_id, stream, **kwargs)
        else:
            (data) = self.upload_resource_with_http_info(config_id, stream, **kwargs)
            return data

    def upload_resource_with_http_info(self, config_id, stream, **kwargs):
        """
        Upload a configuration resource
        Upload a resource needed by a configuration.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.upload_resource_with_http_info(config_id, stream, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str config_id: configId (required)
        :param file stream: The resource data (required)
        :return: StreamLocation
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['config_id', 'stream']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method upload_resource" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'config_id' is set
        if ('config_id' not in params) or (params['config_id'] is None):
            raise ValueError("Missing the required parameter `config_id` when calling `upload_resource`")
        # verify the required parameter 'stream' is set
        if ('stream' not in params) or (params['stream'] is None):
            raise ValueError("Missing the required parameter `stream` when calling `upload_resource`")

        resource_path = '/config/{configId}/streams/multipart'.replace('{format}', 'json')
        path_params = {}
        if 'config_id' in params:
            path_params['configId'] = params['config_id']

        query_params = {}

        header_params = {}

        form_params = []
        local_var_files = {}
        if 'stream' in params:
            local_var_files['stream'] = params['stream']

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json;charset=UTF-8'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['multipart/form-data'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api(resource_path, 'POST',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='StreamLocation',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))
