# coding: utf-8

"""
    herd

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

    OpenAPI spec version: 0.178.0-SNAPSHOT
    Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from herdsdk.api_client import ApiClient


class NamespaceApi(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 namespace_create_namespace(self, namespace_create_request, **kwargs):  # noqa: E501
        """createNamespace  # noqa: E501

        Creates a new namespace.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_create_namespace(namespace_create_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param NamespaceCreateRequest namespace_create_request: the information needed to create the namespace (required)
        :return: Namespace
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.namespace_create_namespace_with_http_info(namespace_create_request, **kwargs)  # noqa: E501
        else:
            (data) = self.namespace_create_namespace_with_http_info(namespace_create_request, **kwargs)  # noqa: E501
            return data

    def namespace_create_namespace_with_http_info(self, namespace_create_request, **kwargs):  # noqa: E501
        """createNamespace  # noqa: E501

        Creates a new namespace.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_create_namespace_with_http_info(namespace_create_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param NamespaceCreateRequest namespace_create_request: the information needed to create the namespace (required)
        :return: Namespace
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['namespace_create_request']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'namespace_create_request' in local_var_params:
            body_params = local_var_params['namespace_create_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/xml'])  # noqa: E501

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

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/namespaces', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Namespace',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def namespace_delete_namespace(self, namespace_code, **kwargs):  # noqa: E501
        """deleteNamespace  # noqa: E501

        Deletes an existing namespace by namespace code.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_delete_namespace(namespace_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str namespace_code: the namespace code (required)
        :return: Namespace
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.namespace_delete_namespace_with_http_info(namespace_code, **kwargs)  # noqa: E501
        else:
            (data) = self.namespace_delete_namespace_with_http_info(namespace_code, **kwargs)  # noqa: E501
            return data

    def namespace_delete_namespace_with_http_info(self, namespace_code, **kwargs):  # noqa: E501
        """deleteNamespace  # noqa: E501

        Deletes an existing namespace by namespace code.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_delete_namespace_with_http_info(namespace_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str namespace_code: the namespace code (required)
        :return: Namespace
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['namespace_code']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}
        if 'namespace_code' in local_var_params:
            path_params['namespaceCode'] = local_var_params['namespace_code']  # 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', 'application/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/namespaces/{namespaceCode}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Namespace',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def namespace_get_namespace(self, namespace_code, **kwargs):  # noqa: E501
        """getNamespace  # noqa: E501

        Gets an existing namespace by namespace code.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_get_namespace(namespace_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str namespace_code: the namespace code (required)
        :return: Namespace
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.namespace_get_namespace_with_http_info(namespace_code, **kwargs)  # noqa: E501
        else:
            (data) = self.namespace_get_namespace_with_http_info(namespace_code, **kwargs)  # noqa: E501
            return data

    def namespace_get_namespace_with_http_info(self, namespace_code, **kwargs):  # noqa: E501
        """getNamespace  # noqa: E501

        Gets an existing namespace by namespace code.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_get_namespace_with_http_info(namespace_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str namespace_code: the namespace code (required)
        :return: Namespace
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['namespace_code']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}
        if 'namespace_code' in local_var_params:
            path_params['namespaceCode'] = local_var_params['namespace_code']  # 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', 'application/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/namespaces/{namespaceCode}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Namespace',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def namespace_get_namespaces(self, **kwargs):  # noqa: E501
        """getNamespaces  # noqa: E501

        Gets a list of namespace keys for all namespaces defined in the system.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_get_namespaces(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: NamespaceKeys
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.namespace_get_namespaces_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.namespace_get_namespaces_with_http_info(**kwargs)  # noqa: E501
            return data

    def namespace_get_namespaces_with_http_info(self, **kwargs):  # noqa: E501
        """getNamespaces  # noqa: E501

        Gets a list of namespace keys for all namespaces defined in the system.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_get_namespaces_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: NamespaceKeys
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = []  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method namespace_get_namespaces" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']

        collection_formats = {}

        path_params = {}

        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', 'application/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/namespaces', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='NamespaceKeys',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def namespace_search_namespaces(self, namespace_search_request, **kwargs):  # noqa: E501
        """searchNamespaces  # noqa: E501

        Retrieves all namespaces existing in the system per specified search filters and keys.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_search_namespaces(namespace_search_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param NamespaceSearchRequest namespace_search_request: the namespace search request. The request can only accept a single search filter and a single search key (required)
        :param str fields: the field options for the namespace search response. The valid field options are: chargeCode, s3KeyPrefix
        :return: NamespaceSearchResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.namespace_search_namespaces_with_http_info(namespace_search_request, **kwargs)  # noqa: E501
        else:
            (data) = self.namespace_search_namespaces_with_http_info(namespace_search_request, **kwargs)  # noqa: E501
            return data

    def namespace_search_namespaces_with_http_info(self, namespace_search_request, **kwargs):  # noqa: E501
        """searchNamespaces  # noqa: E501

        Retrieves all namespaces existing in the system per specified search filters and keys.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_search_namespaces_with_http_info(namespace_search_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param NamespaceSearchRequest namespace_search_request: the namespace search request. The request can only accept a single search filter and a single search key (required)
        :param str fields: the field options for the namespace search response. The valid field options are: chargeCode, s3KeyPrefix
        :return: NamespaceSearchResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['namespace_search_request', 'fields']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

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

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'namespace_search_request' in local_var_params:
            body_params = local_var_params['namespace_search_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/xml'])  # noqa: E501

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

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/namespaces/search', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='NamespaceSearchResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def namespace_update_namespaces(self, namespace_code, namespace_update_request, **kwargs):  # noqa: E501
        """updateNamespaces  # noqa: E501

        Updates an existing namespace.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_update_namespaces(namespace_code, namespace_update_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str namespace_code: (required)
        :param NamespaceUpdateRequest namespace_update_request: (required)
        :return: Namespace
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.namespace_update_namespaces_with_http_info(namespace_code, namespace_update_request, **kwargs)  # noqa: E501
        else:
            (data) = self.namespace_update_namespaces_with_http_info(namespace_code, namespace_update_request, **kwargs)  # noqa: E501
            return data

    def namespace_update_namespaces_with_http_info(self, namespace_code, namespace_update_request, **kwargs):  # noqa: E501
        """updateNamespaces  # noqa: E501

        Updates an existing namespace.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.namespace_update_namespaces_with_http_info(namespace_code, namespace_update_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str namespace_code: (required)
        :param NamespaceUpdateRequest namespace_update_request: (required)
        :return: Namespace
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['namespace_code', 'namespace_update_request']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method namespace_update_namespaces" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'namespace_code' is set
        if ('namespace_code' not in local_var_params or
                local_var_params['namespace_code'] is None):
            raise ValueError("Missing the required parameter `namespace_code` when calling `namespace_update_namespaces`")  # noqa: E501
        # verify the required parameter 'namespace_update_request' is set
        if ('namespace_update_request' not in local_var_params or
                local_var_params['namespace_update_request'] is None):
            raise ValueError("Missing the required parameter `namespace_update_request` when calling `namespace_update_namespaces`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'namespace_code' in local_var_params:
            path_params['namespaceCode'] = local_var_params['namespace_code']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'namespace_update_request' in local_var_params:
            body_params = local_var_params['namespace_update_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/xml'])  # noqa: E501

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

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/namespaces/{namespaceCode}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Namespace',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)
