# 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 UserNamespaceAuthorizationApi(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 user_namespace_authorization_create_user_namespace_authorization(self, user_namespace_authorization_create_request, **kwargs):  # noqa: E501
        """createUserNamespaceAuthorization  # noqa: E501

        <p>Creates a new user namespace authorization.</p> <p>The user ID field may be prefixed with a wildcard token character \"*\" to authorize multiple users access to the namespace. The wildcard only works for as a prefix to match the suffix of the user ID. If the wildcard appears anywhere other than the prefix, the user ID must match as-is. For example:</p> <ul> <li>john.doe@domain.com - only authorizes user with ID \"john.doe@domain.com\"</li> <li>*@domain.com - authorizes users that has the suffix \"@domain.com\"</li> <li>* - authorizes all users</li> <li>john.doe* - only authorizes user with ID \"john.doe*\"</li> </ul> <p>Requires GRANT permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_create_user_namespace_authorization(user_namespace_authorization_create_request, async_req=True)
        >>> result = thread.get()

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

    def user_namespace_authorization_create_user_namespace_authorization_with_http_info(self, user_namespace_authorization_create_request, **kwargs):  # noqa: E501
        """createUserNamespaceAuthorization  # noqa: E501

        <p>Creates a new user namespace authorization.</p> <p>The user ID field may be prefixed with a wildcard token character \"*\" to authorize multiple users access to the namespace. The wildcard only works for as a prefix to match the suffix of the user ID. If the wildcard appears anywhere other than the prefix, the user ID must match as-is. For example:</p> <ul> <li>john.doe@domain.com - only authorizes user with ID \"john.doe@domain.com\"</li> <li>*@domain.com - authorizes users that has the suffix \"@domain.com\"</li> <li>* - authorizes all users</li> <li>john.doe* - only authorizes user with ID \"john.doe*\"</li> </ul> <p>Requires GRANT permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_create_user_namespace_authorization_with_http_info(user_namespace_authorization_create_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param UserNamespaceAuthorizationCreateRequest user_namespace_authorization_create_request: the information needed to create the user namespace authorization (required)
        :return: UserNamespaceAuthorization
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['user_namespace_authorization_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 user_namespace_authorization_create_user_namespace_authorization" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'user_namespace_authorization_create_request' is set
        if ('user_namespace_authorization_create_request' not in local_var_params or
                local_var_params['user_namespace_authorization_create_request'] is None):
            raise ValueError("Missing the required parameter `user_namespace_authorization_create_request` when calling `user_namespace_authorization_create_user_namespace_authorization`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'user_namespace_authorization_create_request' in local_var_params:
            body_params = local_var_params['user_namespace_authorization_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(
            '/userNamespaceAuthorizations', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='UserNamespaceAuthorization',  # 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 user_namespace_authorization_delete_user_namespace_authorization(self, user_id, namespace, **kwargs):  # noqa: E501
        """deleteUserNamespaceAuthorization  # noqa: E501

        Deletes an existing user namespace authorization by key. <p>Requires GRANT permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_delete_user_namespace_authorization(user_id, namespace, async_req=True)
        >>> result = thread.get()

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

    def user_namespace_authorization_delete_user_namespace_authorization_with_http_info(self, user_id, namespace, **kwargs):  # noqa: E501
        """deleteUserNamespaceAuthorization  # noqa: E501

        Deletes an existing user namespace authorization by key. <p>Requires GRANT permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_delete_user_namespace_authorization_with_http_info(user_id, namespace, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: the user id (required)
        :param str namespace: the namespace (required)
        :return: UserNamespaceAuthorization
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

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

        collection_formats = {}

        path_params = {}
        if 'user_id' in local_var_params:
            path_params['userId'] = local_var_params['user_id']  # noqa: E501
        if 'namespace' in local_var_params:
            path_params['namespace'] = local_var_params['namespace']  # 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(
            '/userNamespaceAuthorizations/userIds/{userId}/namespaces/{namespace}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='UserNamespaceAuthorization',  # 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 user_namespace_authorization_delete_user_namespace_authorizations_by_user_id(self, user_id, **kwargs):  # noqa: E501
        """deleteUserNamespaceAuthorizationsByUserId  # noqa: E501

        Deletes all existing user namespace authorizations for the specified user.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_delete_user_namespace_authorizations_by_user_id(user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: the user id (required)
        :return: UserNamespaceAuthorizations
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.user_namespace_authorization_delete_user_namespace_authorizations_by_user_id_with_http_info(user_id, **kwargs)  # noqa: E501
        else:
            (data) = self.user_namespace_authorization_delete_user_namespace_authorizations_by_user_id_with_http_info(user_id, **kwargs)  # noqa: E501
            return data

    def user_namespace_authorization_delete_user_namespace_authorizations_by_user_id_with_http_info(self, user_id, **kwargs):  # noqa: E501
        """deleteUserNamespaceAuthorizationsByUserId  # noqa: E501

        Deletes all existing user namespace authorizations for the specified user.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_delete_user_namespace_authorizations_by_user_id_with_http_info(user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: the user id (required)
        :return: UserNamespaceAuthorizations
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['user_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')

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

        collection_formats = {}

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

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

        return self.api_client.call_api(
            '/userNamespaceAuthorizations/userIds/{userId}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='UserNamespaceAuthorizations',  # 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 user_namespace_authorization_get_user_namespace_authorization(self, user_id, namespace, **kwargs):  # noqa: E501
        """getUserNamespaceAuthorization  # noqa: E501

        Gets an existing user namespace authorization by key. <p>Requires READ permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_get_user_namespace_authorization(user_id, namespace, async_req=True)
        >>> result = thread.get()

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

    def user_namespace_authorization_get_user_namespace_authorization_with_http_info(self, user_id, namespace, **kwargs):  # noqa: E501
        """getUserNamespaceAuthorization  # noqa: E501

        Gets an existing user namespace authorization by key. <p>Requires READ permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_get_user_namespace_authorization_with_http_info(user_id, namespace, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: the user id (required)
        :param str namespace: the namespace (required)
        :return: UserNamespaceAuthorization
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

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

        collection_formats = {}

        path_params = {}
        if 'user_id' in local_var_params:
            path_params['userId'] = local_var_params['user_id']  # noqa: E501
        if 'namespace' in local_var_params:
            path_params['namespace'] = local_var_params['namespace']  # 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(
            '/userNamespaceAuthorizations/userIds/{userId}/namespaces/{namespace}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='UserNamespaceAuthorization',  # 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 user_namespace_authorization_get_user_namespace_authorizations_by_namespace(self, namespace, **kwargs):  # noqa: E501
        """getUserNamespaceAuthorizationsByNamespace  # noqa: E501

        Gets a list of user namespace authorizations for the specified 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.user_namespace_authorization_get_user_namespace_authorizations_by_namespace(namespace, async_req=True)
        >>> result = thread.get()

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

    def user_namespace_authorization_get_user_namespace_authorizations_by_namespace_with_http_info(self, namespace, **kwargs):  # noqa: E501
        """getUserNamespaceAuthorizationsByNamespace  # noqa: E501

        Gets a list of user namespace authorizations for the specified 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.user_namespace_authorization_get_user_namespace_authorizations_by_namespace_with_http_info(namespace, async_req=True)
        >>> result = thread.get()

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

        local_var_params = locals()

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

        collection_formats = {}

        path_params = {}
        if 'namespace' in local_var_params:
            path_params['namespace'] = local_var_params['namespace']  # 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(
            '/userNamespaceAuthorizations/namespaces/{namespace}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='UserNamespaceAuthorizations',  # 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 user_namespace_authorization_get_user_namespace_authorizations_by_user_id(self, user_id, **kwargs):  # noqa: E501
        """getUserNamespaceAuthorizationsByUserId  # noqa: E501

        Gets a list of user namespace authorizations for the specified user.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_get_user_namespace_authorizations_by_user_id(user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: the user id (required)
        :return: UserNamespaceAuthorizations
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.user_namespace_authorization_get_user_namespace_authorizations_by_user_id_with_http_info(user_id, **kwargs)  # noqa: E501
        else:
            (data) = self.user_namespace_authorization_get_user_namespace_authorizations_by_user_id_with_http_info(user_id, **kwargs)  # noqa: E501
            return data

    def user_namespace_authorization_get_user_namespace_authorizations_by_user_id_with_http_info(self, user_id, **kwargs):  # noqa: E501
        """getUserNamespaceAuthorizationsByUserId  # noqa: E501

        Gets a list of user namespace authorizations for the specified user.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_get_user_namespace_authorizations_by_user_id_with_http_info(user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: the user id (required)
        :return: UserNamespaceAuthorizations
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['user_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')

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

        collection_formats = {}

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

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

        return self.api_client.call_api(
            '/userNamespaceAuthorizations/userIds/{userId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='UserNamespaceAuthorizations',  # 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 user_namespace_authorization_update_user_namespace_authorization(self, user_id, namespace, user_namespace_authorization_update_request, **kwargs):  # noqa: E501
        """updateUserNamespaceAuthorization  # noqa: E501

        Updates an existing user namespace authorization by key. <p>Requires GRANT permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_update_user_namespace_authorization(user_id, namespace, user_namespace_authorization_update_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: the user id (required)
        :param str namespace: the namespace (required)
        :param UserNamespaceAuthorizationUpdateRequest user_namespace_authorization_update_request: the information needed to update the user namespace authorization (required)
        :return: UserNamespaceAuthorization
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.user_namespace_authorization_update_user_namespace_authorization_with_http_info(user_id, namespace, user_namespace_authorization_update_request, **kwargs)  # noqa: E501
        else:
            (data) = self.user_namespace_authorization_update_user_namespace_authorization_with_http_info(user_id, namespace, user_namespace_authorization_update_request, **kwargs)  # noqa: E501
            return data

    def user_namespace_authorization_update_user_namespace_authorization_with_http_info(self, user_id, namespace, user_namespace_authorization_update_request, **kwargs):  # noqa: E501
        """updateUserNamespaceAuthorization  # noqa: E501

        Updates an existing user namespace authorization by key. <p>Requires GRANT permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.user_namespace_authorization_update_user_namespace_authorization_with_http_info(user_id, namespace, user_namespace_authorization_update_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: the user id (required)
        :param str namespace: the namespace (required)
        :param UserNamespaceAuthorizationUpdateRequest user_namespace_authorization_update_request: the information needed to update the user namespace authorization (required)
        :return: UserNamespaceAuthorization
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['user_id', 'namespace', 'user_namespace_authorization_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 user_namespace_authorization_update_user_namespace_authorization" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in local_var_params or
                local_var_params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `user_namespace_authorization_update_user_namespace_authorization`")  # noqa: E501
        # verify the required parameter 'namespace' is set
        if ('namespace' not in local_var_params or
                local_var_params['namespace'] is None):
            raise ValueError("Missing the required parameter `namespace` when calling `user_namespace_authorization_update_user_namespace_authorization`")  # noqa: E501
        # verify the required parameter 'user_namespace_authorization_update_request' is set
        if ('user_namespace_authorization_update_request' not in local_var_params or
                local_var_params['user_namespace_authorization_update_request'] is None):
            raise ValueError("Missing the required parameter `user_namespace_authorization_update_request` when calling `user_namespace_authorization_update_user_namespace_authorization`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'user_id' in local_var_params:
            path_params['userId'] = local_var_params['user_id']  # noqa: E501
        if 'namespace' in local_var_params:
            path_params['namespace'] = local_var_params['namespace']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'user_namespace_authorization_update_request' in local_var_params:
            body_params = local_var_params['user_namespace_authorization_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(
            '/userNamespaceAuthorizations/userIds/{userId}/namespaces/{namespace}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='UserNamespaceAuthorization',  # 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)
