def add_or_update(self, username, password=None, name=None, admin_channels=None, admin_roles=None, email=None, disabled=None): query_url = urls.user_url(self.database_url, username) body = self._user_body( username, password, name, admin_channels, admin_roles, email, disabled ) response = self.session.put(query_url, data=json.dumps(body)) if response.status_code >= 400: raise errors.ResponseError( "Error creating user", response.status_code, response.text )
def delete(self, username): query_url = urls.user_url(self.database_url, username) response = self.session.delete(query_url) if response.status_code > 200: raise errors.UnexpectedResponseError( response.status_code, response.text )
def exists(self, username): query_url = urls.user_url(self.database_url, username) response = self.session.get(query_url) if response.status_code == 200: return True elif response.status_code == 404: return False else: raise errors.UnexpectedResponseError( response.status_code, response.text )