<commit_before>from .base import Module, extract_value


class User(Module):
    _name = 'user'

    @extract_value('users')
    def init(self):
        return self._request('init')

    def delete(self, *ids):
        """Deletes user

        :param ids: list of user ids

        "return: returns response
        """
        return self._request('delete', {
            'users': [{'id': id} for id in ids]
        })

    def add(self):
        #TODO: user::add
        raise NotImplementedError

    def edit(self):
        #TODO user::edit
        raise NotImplementedError

    def query(self, ids, start=None, sort=None, stop=None,
              tool=None, password=None):
        """Query Users module.

        :param ids: specified user filters IDs
        :param start: startOffset
        :param sort: sortField
        :param stop: endOffset
        :param tool: query tool
        :param password: <PASSWORD>

        :return: return params used
        """

        return self._request('query', {
            'endOffset': stop,
            'startOffset': start,
            'sortField': sort,
            'tool': tool,
            'password': password,
            'filters': [{'id': id} for id in ids]
        })

    def change_password(self,password):
        """Change user's password
<commit_msg>Implemented add function for User<commit_after>from .base import Module, extract_value


class User(Module):
    _name = 'user'

    @extract_value('users')
    def init(self):
        return self._request('init')

    def delete(self, *ids):
        """Deletes user

        :param ids: list of user ids

        "return: returns response
        """
        return self._request('delete', {
            'users': [{'id': id} for id in ids]
        })

    def add(self, username, role_id, first_name, last_name=None, title=None, phone=None, email=None):
        """Add user.

        :param first_name: user first name
        :param last_name: user last name
        :param title: user title
        :param role_id: user role
        :param phone: user phone number
        :param email: user email
        :param username: user username

        :return: returns response
        """
        #TODO: add support for lces, id, fingerprint, repositories, state, city
        #TODO: add support for queries, assets, address, authType, policies
        #TODO: add support for country, credentials
        return self._request('add', {
            'lces': [],
            'firstname': first_name,
            'id': "no_id",
            'lastname': last_name,
            'address': "",
            'authType': "ldap",
            'fingerprint': "",
            'roleID': role_id,
            'title': title,
            'repositories': [],
            'state': "",
            'city': "",
            'policies': [],
            'country': "",
            'phone': phone,
            'parentID': "1",
            'credentials': [],
            'queries': [],
            'email': email,
            'assets': {'isAccessible': [],
                       'definesUser': [{'id': "0"}]},
            'username': username
        })

    def edit(self):
        #TODO user::edit
        raise NotImplementedError

    def query(self, ids, start=None, sort=None, stop=None,
              tool=None, password=<PASSWORD>):
        """Query Users module.

        :param ids: specified user filters IDs
        :param start: startOffset
        :param sort: sortField
        :param stop: endOffset
        :param tool: query tool
        :param password: <PASSWORD>

        :return: return params used
        """

        return self._request('query', {
            'endOffset': stop,
            'startOffset': start,
            'sortField': sort,
            'tool': tool,
            'password': password,
            'filters': [{'id': id} for id in ids]
        })

    def change_password(self,password):
        """Change user's password

{'fraction_non_alphanumeric': 0.12417804754678806, 'fraction_numerical': 0.0005058168942842691, 'mean_word_length': 1.8229835831548893, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2249705', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1057, 'n_words': 325}