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()
def setUp(self): if not hasattr(sys.stdout, 'getvalue'): self.fail('This test needs to be run in buffered mode') # Create a connection to check the contents of the registry self.db = Database(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST, DB_PORT) # Import predefined dataset for testing self._load_test_dataset() # Create command self.kwargs = { 'user': DB_USER, 'password': DB_PASSWORD, 'database': DB_NAME, 'host': DB_HOST, 'port': DB_PORT } self.cmd = Show(**self.kwargs)