def get(self): """ sortinghat command: show Show information about a unique identity REST command: GET http://[hostname]/identities Retrieve identities """ # Request arguments parser = reqparse.RequestParser() parser.add_argument('term', default=None, location='args') args = parser.parse_args() # Sortinghat action c = self.config cmd = Show(user=c['user'], password=c['password'], database=c['database'], host=c['host'], port=c['port']) code = cmd.show(None, term=args.term) # In failure case if code == CODE_NOT_FOUND_ERROR: v = cmd.get_error_vars() abort(NOT_FOUND, message=v) # If everything went well v = cmd.get_display_vars() identities = [i.to_dict() for i in v['uidentities']] return {"identities": identities}
def get(self, uuid): """ sortinghat command: show Show information about a unique identity REST command: GET http://[hostname]/identity/[uuid] Retrieve an identity """ # Sortinghat action c = self.config cmd = Show(user=c['user'], password=c['password'], database=c['database'], host=c['host'], port=c['port']) code = cmd.show(uuid, None) # In failure case if code == CODE_NOT_FOUND_ERROR: v = cmd.get_error_vars() abort(NOT_FOUND, message=v) # If everything went well v = cmd.get_display_vars() identity = v['uidentities'][0] return identity.to_dict()