# coding: utf-8

"""
    3blades API

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

    OpenAPI spec version: 1.0
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


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 HostsApi(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 hosts_create(self, namespace, **kwargs):
        """
        Create a new host
        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.hosts_create(namespace, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param DockerHostData dockerhost_data:
        :return: DockerHost
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.hosts_create_with_http_info(namespace, **kwargs)
        else:
            (data) = self.hosts_create_with_http_info(namespace, **kwargs)
            return data

    def hosts_create_with_http_info(self, namespace, **kwargs):
        """
        Create a new host
        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.hosts_create_with_http_info(namespace, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param DockerHostData dockerhost_data:
        :return: DockerHost
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['namespace', 'dockerhost_data']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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


        collection_formats = {}

        path_params = {}
        if 'namespace' in params:
            path_params['namespace'] = params['namespace']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'dockerhost_data' in params:
            body_params = params['dockerhost_data']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json', 'text/html'])

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

        # Authentication setting
        auth_settings = ['jwt']

        return self.api_client.call_api('/v1/{namespace}/hosts/', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='DockerHost',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _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 hosts_delete(self, namespace, host, **kwargs):
        """
        Delete a host
        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.hosts_delete(namespace, host, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param str host: DockerHost unique identifier expressed as UUID. (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.hosts_delete_with_http_info(namespace, host, **kwargs)
        else:
            (data) = self.hosts_delete_with_http_info(namespace, host, **kwargs)
            return data

    def hosts_delete_with_http_info(self, namespace, host, **kwargs):
        """
        Delete a host
        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.hosts_delete_with_http_info(namespace, host, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param str host: DockerHost unique identifier expressed as UUID. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['namespace', 'host']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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


        collection_formats = {}

        path_params = {}
        if 'namespace' in params:
            path_params['namespace'] = params['namespace']
        if 'host' in params:
            path_params['host'] = params['host']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json', 'text/html'])

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

        # Authentication setting
        auth_settings = ['jwt']

        return self.api_client.call_api('/v1/{namespace}/hosts/{host}/', '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'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def hosts_list(self, namespace, **kwargs):
        """
        Get available hosts
        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.hosts_list(namespace, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team data. (required)
        :param str limit: Limite when getting items.
        :param str offset: Offset when getting items.
        :param str name: Name, when getting items.
        :param str ordering: Ordering when getting items.
        :return: list[DockerHost]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.hosts_list_with_http_info(namespace, **kwargs)
        else:
            (data) = self.hosts_list_with_http_info(namespace, **kwargs)
            return data

    def hosts_list_with_http_info(self, namespace, **kwargs):
        """
        Get available hosts
        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.hosts_list_with_http_info(namespace, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team data. (required)
        :param str limit: Limite when getting items.
        :param str offset: Offset when getting items.
        :param str name: Name, when getting items.
        :param str ordering: Ordering when getting items.
        :return: list[DockerHost]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['namespace', 'limit', 'offset', 'name', 'ordering']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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


        collection_formats = {}

        path_params = {}
        if 'namespace' in params:
            path_params['namespace'] = params['namespace']

        query_params = []
        if 'limit' in params:
            query_params.append(('limit', params['limit']))
        if 'offset' in params:
            query_params.append(('offset', params['offset']))
        if 'name' in params:
            query_params.append(('name', params['name']))
        if 'ordering' in params:
            query_params.append(('ordering', params['ordering']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json', 'text/html'])

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

        # Authentication setting
        auth_settings = ['jwt']

        return self.api_client.call_api('/v1/{namespace}/hosts/', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='list[DockerHost]',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _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 hosts_read(self, namespace, host, **kwargs):
        """
        Get a host
        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.hosts_read(namespace, host, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param str host: Unique identifier expressed as UUID or name. (required)
        :return: DockerHost
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.hosts_read_with_http_info(namespace, host, **kwargs)
        else:
            (data) = self.hosts_read_with_http_info(namespace, host, **kwargs)
            return data

    def hosts_read_with_http_info(self, namespace, host, **kwargs):
        """
        Get a host
        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.hosts_read_with_http_info(namespace, host, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param str host: Unique identifier expressed as UUID or name. (required)
        :return: DockerHost
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['namespace', 'host']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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


        collection_formats = {}

        path_params = {}
        if 'namespace' in params:
            path_params['namespace'] = params['namespace']
        if 'host' in params:
            path_params['host'] = params['host']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json', 'text/html'])

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

        # Authentication setting
        auth_settings = ['jwt']

        return self.api_client.call_api('/v1/{namespace}/hosts/{host}/', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='DockerHost',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _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 hosts_replace(self, namespace, host, **kwargs):
        """
        Replace a host
        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.hosts_replace(namespace, host, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param str host:  (required)
        :param DockerHostData dockerhost_data:
        :return: DockerHost
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.hosts_replace_with_http_info(namespace, host, **kwargs)
        else:
            (data) = self.hosts_replace_with_http_info(namespace, host, **kwargs)
            return data

    def hosts_replace_with_http_info(self, namespace, host, **kwargs):
        """
        Replace a host
        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.hosts_replace_with_http_info(namespace, host, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param str host:  (required)
        :param DockerHostData dockerhost_data:
        :return: DockerHost
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['namespace', 'host', 'dockerhost_data']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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


        collection_formats = {}

        path_params = {}
        if 'namespace' in params:
            path_params['namespace'] = params['namespace']
        if 'host' in params:
            path_params['host'] = params['host']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'dockerhost_data' in params:
            body_params = params['dockerhost_data']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json', 'text/html'])

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

        # Authentication setting
        auth_settings = ['jwt']

        return self.api_client.call_api('/v1/{namespace}/hosts/{host}/', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='DockerHost',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _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 hosts_update(self, namespace, host, **kwargs):
        """
        Update a host
        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.hosts_update(namespace, host, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param str host:  (required)
        :param DockerHostData dockerhost_data:
        :return: DockerHost
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.hosts_update_with_http_info(namespace, host, **kwargs)
        else:
            (data) = self.hosts_update_with_http_info(namespace, host, **kwargs)
            return data

    def hosts_update_with_http_info(self, namespace, host, **kwargs):
        """
        Update a host
        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.hosts_update_with_http_info(namespace, host, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str namespace: User or team name. (required)
        :param str host:  (required)
        :param DockerHostData dockerhost_data:
        :return: DockerHost
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['namespace', 'host', 'dockerhost_data']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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


        collection_formats = {}

        path_params = {}
        if 'namespace' in params:
            path_params['namespace'] = params['namespace']
        if 'host' in params:
            path_params['host'] = params['host']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'dockerhost_data' in params:
            body_params = params['dockerhost_data']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json', 'text/html'])

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

        # Authentication setting
        auth_settings = ['jwt']

        return self.api_client.call_api('/v1/{namespace}/hosts/{host}/', 'PATCH',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='DockerHost',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _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)
