Add creation date information to robots API and UI

Fixes https://jira.coreos.com/browse/QUAY-846
This commit is contained in:
Joseph Schorr 2018-03-09 13:55:19 -05:00
parent c4a6273e00
commit a693771345
5 changed files with 28 additions and 10 deletions

View file

@ -23,6 +23,7 @@ class RobotPreOCIModel(RobotInterface):
robot_dict = {
'name': robot_name,
'token': robot_tuple.get(FederatedLogin.service_ident),
'created': robot_tuple.get(User.creation_date),
}
if include_permissions:
@ -30,7 +31,7 @@ class RobotPreOCIModel(RobotInterface):
'teams': [],
'repositories': []
})
robots[robot_name] = Robot(robot_dict['name'], robot_dict['token'])
robots[robot_name] = Robot(robot_dict['name'], robot_dict['token'], robot_dict['created'])
if include_permissions:
team_name = robot_tuple.get(TeamTable.name)
repository_name = robot_tuple.get(Repository.name)
@ -48,40 +49,41 @@ class RobotPreOCIModel(RobotInterface):
if repository_name is not None:
if repository_name not in robot_dict['repositories']:
robot_dict['repositories'].append(repository_name)
robots[robot_name] = RobotWithPermissions(robot_dict['name'], robot_dict['token'], robot_dict['teams'],
robots[robot_name] = RobotWithPermissions(robot_dict['name'], robot_dict['token'],
robot_dict['created'], robot_dict['teams'],
robot_dict['repositories'])
return robots.values()
def regenerate_user_robot_token(self, robot_shortname, owning_user):
robot, password = model.user.regenerate_robot_token(robot_shortname, owning_user)
return Robot(robot.username, password)
return Robot(robot.username, password, robot.creation_date)
def regenerate_org_robot_token(self, robot_shortname, orgname):
parent = model.organization.get_organization(orgname)
robot, password = model.user.regenerate_robot_token(robot_shortname, parent)
return Robot(robot.username, password)
return Robot(robot.username, password, robot.creation_date)
def delete_robot(self, robot_username):
model.user.delete_robot(robot_username)
def create_user_robot(self, robot_shortname, owning_user):
robot, password = model.user.create_robot(robot_shortname, owning_user)
return Robot(robot.username, password)
return Robot(robot.username, password, robot.creation_date)
def create_org_robot(self, robot_shortname, orgname):
parent = model.organization.get_organization(orgname)
robot, password = model.user.create_robot(robot_shortname, parent)
return Robot(robot.username, password)
return Robot(robot.username, password, robot.creation_date)
def get_org_robot(self, robot_shortname, orgname):
parent = model.organization.get_organization(orgname)
robot, password = model.user.get_robot(robot_shortname, parent)
return Robot(robot.username, password)
return Robot(robot.username, password, robot.creation_date)
def get_user_robot(self, robot_shortname, owning_user):
robot, password = model.user.get_robot(robot_shortname, owning_user)
return Robot(robot.username, password)
return Robot(robot.username, password, robot.creation_date)
pre_oci_model = RobotPreOCIModel()