Ejemplo n.º 1
0
    def create(self,
               username,
               password=None,
               name=None,
               admin_channels=None,
               admin_roles=None,
               email=None,
               disabled=None):
        query_url = urls.users_url(self.database_url)

        body = self._user_body(
            username,
            password,
            name,
            admin_channels,
            admin_roles,
            email,
            disabled
        )

        response = self.session.post(query_url, data=json.dumps(body))
        if response.status_code == 201:
            return True
        elif response.status_code == 409:
            return False
        else:
            raise errors.UnexpectedResponseError(
                response.status_code,
                response.text
            )
Ejemplo n.º 2
0
    def get_list(self):
        query_url = urls.users_url(self.database_url)
        response = self.session.get(query_url)

        if response.status_code == 200:
            return response.json()
        else:
            raise errors.UnexpectedResponseError(
                response.status_code,
                response.text
            )