# coding: utf-8

"""
    GraphDB Workbench API

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

    OpenAPI spec version: 1.0.0
    
    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 graphdb.graphdb_workbench.api_client import ApiClient


class ImportControllerApi(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 import_server_file_using_post(self, import_body, repository_id, **kwargs):  # noqa: E501
        """Import a server file into the repository  # noqa: E501

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

        :param async_req bool
        :param ServerImportBody import_body: importBody (required)
        :param str repository_id: repositoryID (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.import_server_file_using_post_with_http_info(import_body, repository_id, **kwargs)  # noqa: E501
        else:
            (data) = self.import_server_file_using_post_with_http_info(import_body, repository_id, **kwargs)  # noqa: E501
            return data

    def import_server_file_using_post_with_http_info(self, import_body, repository_id, **kwargs):  # noqa: E501
        """Import a server file into the repository  # noqa: E501

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

        :param async_req bool
        :param ServerImportBody import_body: importBody (required)
        :param str repository_id: repositoryID (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'repository_id' in params:
            path_params['repositoryID'] = params['repository_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'import_body' in params:
            body_params = params['import_body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['*/*'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/rest/data/import/server/{repositoryID}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # 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 import_url_upload_using_post(self, import_settings, repository_id, **kwargs):  # noqa: E501
        """Import from data URL into the repository  # noqa: E501

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

        :param async_req bool
        :param ImportSettings import_settings: importSettings (required)
        :param str repository_id: repositoryID (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.import_url_upload_using_post_with_http_info(import_settings, repository_id, **kwargs)  # noqa: E501
        else:
            (data) = self.import_url_upload_using_post_with_http_info(import_settings, repository_id, **kwargs)  # noqa: E501
            return data

    def import_url_upload_using_post_with_http_info(self, import_settings, repository_id, **kwargs):  # noqa: E501
        """Import from data URL into the repository  # noqa: E501

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

        :param async_req bool
        :param ImportSettings import_settings: importSettings (required)
        :param str repository_id: repositoryID (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'repository_id' in params:
            path_params['repositoryID'] = params['repository_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'import_settings' in params:
            body_params = params['import_settings']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['*/*'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/rest/data/import/upload/{repositoryID}/url', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # 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 interrupt_server_import_using_delete(self, repository_id, **kwargs):  # noqa: E501
        """Cancel server file import operation  # noqa: E501

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

        :param async_req bool
        :param str repository_id: repositoryID (required)
        :param str name: The filename import to interrupt.
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.interrupt_server_import_using_delete_with_http_info(repository_id, **kwargs)  # noqa: E501
        else:
            (data) = self.interrupt_server_import_using_delete_with_http_info(repository_id, **kwargs)  # noqa: E501
            return data

    def interrupt_server_import_using_delete_with_http_info(self, repository_id, **kwargs):  # noqa: E501
        """Cancel server file import operation  # noqa: E501

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

        :param async_req bool
        :param str repository_id: repositoryID (required)
        :param str name: The filename import to interrupt.
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'repository_id' in params:
            path_params['repositoryID'] = params['repository_id']  # noqa: E501

        query_params = []
        if 'name' in params:
            query_params.append(('name', params['name']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['*/*'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/rest/data/import/server/{repositoryID}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # 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 list_server_files_using_get(self, repository_id, **kwargs):  # noqa: E501
        """Get server files available for import  # noqa: E501

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

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

    def list_server_files_using_get_with_http_info(self, repository_id, **kwargs):  # noqa: E501
        """Get server files available for import  # noqa: E501

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

        :param async_req bool
        :param str repository_id: repositoryID (required)
        :return: list[ImportSettings]
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'repository_id' in params:
            path_params['repositoryID'] = params['repository_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'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/rest/data/import/server/{repositoryID}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[ImportSettings]',  # 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)
