# coding: utf-8

"""
    Alteryx Server API V3

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

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

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from src.server_client.api_client import ApiClient


class CredentialsApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def credentials_delete_credential(self, credential_id, **kwargs):  # noqa: E501
        """Delete an existing credential.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_delete_credential(credential_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param bool force: cleans up any shares
        :return: list[CredentialsView]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.credentials_delete_credential_with_http_info(credential_id, **kwargs)  # noqa: E501
        else:
            (data) = self.credentials_delete_credential_with_http_info(credential_id, **kwargs)  # noqa: E501
            return data

    def credentials_delete_credential_with_http_info(self, credential_id, **kwargs):  # noqa: E501
        """Delete an existing credential.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_delete_credential_with_http_info(credential_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param bool force: cleans up any shares
        :return: list[CredentialsView]
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'credential_id' in params:
            path_params['credentialId'] = params['credential_id']  # noqa: E501

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

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

        # Authentication setting
        auth_settings = ['oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/v3/credentials/{credentialId}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[CredentialsView]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def credentials_get_credential(self, credential_id, **kwargs):  # noqa: E501
        """Retrieve details about an existing credential.  # noqa: E501

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

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.credentials_get_credential_with_http_info(credential_id, **kwargs)  # noqa: E501
        else:
            (data) = self.credentials_get_credential_with_http_info(credential_id, **kwargs)  # noqa: E501
            return data

    def credentials_get_credential_with_http_info(self, credential_id, **kwargs):  # noqa: E501
        """Retrieve details about an existing credential.  # noqa: E501

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

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'credential_id' in params:
            path_params['credentialId'] = params['credential_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', 'text/json', 'application/xml', 'text/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['oauth2']  # noqa: E501

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

    def credentials_get_credentials(self, **kwargs):  # noqa: E501
        """Retrieve all accessible credential records.  # noqa: E501

        If you are not a Curator, then results will be limited to credentials that you have access to and the following arguments will be disregarded: view, userId, and userGroupId.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_get_credentials(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str view: Determines the amount of information about each credential being returned.
        :param str user_id: Filter results for a specific user.
        :param str user_group_id: Filter results for a specific user group.
        :return: list[ReducedCredentialsView]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.credentials_get_credentials_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.credentials_get_credentials_with_http_info(**kwargs)  # noqa: E501
            return data

    def credentials_get_credentials_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve all accessible credential records.  # noqa: E501

        If you are not a Curator, then results will be limited to credentials that you have access to and the following arguments will be disregarded: view, userId, and userGroupId.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_get_credentials_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str view: Determines the amount of information about each credential being returned.
        :param str user_id: Filter results for a specific user.
        :param str user_group_id: Filter results for a specific user group.
        :return: list[ReducedCredentialsView]
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'view' in params:
            query_params.append(('view', params['view']))  # noqa: E501
        if 'user_id' in params:
            query_params.append(('userId', params['user_id']))  # noqa: E501
        if 'user_group_id' in params:
            query_params.append(('userGroupId', params['user_group_id']))  # noqa: E501

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

        # Authentication setting
        auth_settings = ['oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/v3/credentials', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[ReducedCredentialsView]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def credentials_remove_user_from_credential(self, credential_id, user_id, **kwargs):  # noqa: E501
        """Remove a user's permissions to use an existing credential.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_remove_user_from_credential(credential_id, user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param str user_id: Identifier for an existing user. (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.credentials_remove_user_from_credential_with_http_info(credential_id, user_id, **kwargs)  # noqa: E501
        else:
            (data) = self.credentials_remove_user_from_credential_with_http_info(credential_id, user_id, **kwargs)  # noqa: E501
            return data

    def credentials_remove_user_from_credential_with_http_info(self, credential_id, user_id, **kwargs):  # noqa: E501
        """Remove a user's permissions to use an existing credential.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_remove_user_from_credential_with_http_info(credential_id, user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param str user_id: Identifier for an existing user. (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

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

        # Authentication setting
        auth_settings = ['oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/v3/credentials/{credentialId}/users/{userId}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CredentialsView',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def credentials_remove_user_group_from_credential(self, credential_id, user_group_id, **kwargs):  # noqa: E501
        """Remove a user group's permission to use an existing credential.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_remove_user_group_from_credential(credential_id, user_group_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param str user_group_id: Identifier for an existing user group. (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.credentials_remove_user_group_from_credential_with_http_info(credential_id, user_group_id, **kwargs)  # noqa: E501
        else:
            (data) = self.credentials_remove_user_group_from_credential_with_http_info(credential_id, user_group_id, **kwargs)  # noqa: E501
            return data

    def credentials_remove_user_group_from_credential_with_http_info(self, credential_id, user_group_id, **kwargs):  # noqa: E501
        """Remove a user group's permission to use an existing credential.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_remove_user_group_from_credential_with_http_info(credential_id, user_group_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param str user_group_id: Identifier for an existing user group. (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'credential_id' in params:
            path_params['credentialId'] = params['credential_id']  # noqa: E501
        if 'user_group_id' in params:
            path_params['userGroupId'] = params['user_group_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', 'text/json', 'application/xml', 'text/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/v3/credentials/{credentialId}/userGroups/{userGroupId}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CredentialsView',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def credentials_share_credential_with_user(self, credential_id, contract, **kwargs):  # noqa: E501
        """Share an existing credential with an existing user.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_share_credential_with_user(credential_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param AddCredentialsUserContract contract:  (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.credentials_share_credential_with_user_with_http_info(credential_id, contract, **kwargs)  # noqa: E501
        else:
            (data) = self.credentials_share_credential_with_user_with_http_info(credential_id, contract, **kwargs)  # noqa: E501
            return data

    def credentials_share_credential_with_user_with_http_info(self, credential_id, contract, **kwargs):  # noqa: E501
        """Share an existing credential with an existing user.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_share_credential_with_user_with_http_info(credential_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param AddCredentialsUserContract contract:  (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'credential_id' in params:
            path_params['credentialId'] = params['credential_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        # Authentication setting
        auth_settings = ['oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/v3/credentials/{credentialId}/users', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CredentialsView',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def credentials_share_credential_with_user_group(self, credential_id, contract, **kwargs):  # noqa: E501
        """Share an existing credential with an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_share_credential_with_user_group(credential_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param AddCredentialsUserGroupContract contract:  (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.credentials_share_credential_with_user_group_with_http_info(credential_id, contract, **kwargs)  # noqa: E501
        else:
            (data) = self.credentials_share_credential_with_user_group_with_http_info(credential_id, contract, **kwargs)  # noqa: E501
            return data

    def credentials_share_credential_with_user_group_with_http_info(self, credential_id, contract, **kwargs):  # noqa: E501
        """Share an existing credential with an existing user group.  # noqa: E501

        Only Curators can use this API endpoint.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.credentials_share_credential_with_user_group_with_http_info(credential_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str credential_id: Identifier for an existing credential. (required)
        :param AddCredentialsUserGroupContract contract:  (required)
        :return: CredentialsView
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'credential_id' in params:
            path_params['credentialId'] = params['credential_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        # Authentication setting
        auth_settings = ['oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/v3/credentials/{credentialId}/userGroups', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CredentialsView',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)
