fix(endpoints/api): return empty 204 resp
Return an empty body on API requests with status code 204, which means "No content". Incorrect 'Deleted' responses were being returned after successful DELETE operations despite the "No Content" definition of 204.
This commit is contained in:
parent
fde81c1b58
commit
43aed7c6f4
11 changed files with 22 additions and 22 deletions
|
@ -154,5 +154,5 @@ class ManageRepositoryManifestLabel(RepositoryParamResource):
|
|||
}
|
||||
|
||||
log_action('manifest_label_delete', namespace, metadata, repo=tag_manifest.tag.repository)
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ class Organization(ApiResource):
|
|||
raise NotFound()
|
||||
|
||||
model.user.delete_user(org, all_queues)
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
|
@ -380,7 +380,7 @@ class OrganizationMember(ApiResource):
|
|||
|
||||
# Remove the user from the organization.
|
||||
model.organization.remove_organization_member(org, user)
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
|
@ -616,7 +616,7 @@ class OrganizationApplicationResource(ApiResource):
|
|||
log_action('delete_application', orgname,
|
||||
{'application_name': application.name, 'client_id': client_id})
|
||||
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
raise Unauthorized()
|
||||
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ class RepositoryUserPermission(RepositoryParamResource):
|
|||
{'username': username, 'repo': repository},
|
||||
repo=model.repository.get_repository(namespace, repository))
|
||||
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
|
||||
@resource('/v1/repository/<apirepopath:repository>/permissions/team/<teamname>')
|
||||
|
@ -278,4 +278,4 @@ class RepositoryTeamPermission(RepositoryParamResource):
|
|||
{'team': teamname, 'repo': repository},
|
||||
repo=model.repository.get_repository(namespace, repository))
|
||||
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
|
|
@ -229,7 +229,7 @@ class PermissionPrototype(ApiResource):
|
|||
|
||||
log_prototype_action('delete_prototype_permission', orgname, prototype)
|
||||
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ class Repository(RepositoryParamResource):
|
|||
|
||||
log_action('delete_repo', namespace,
|
||||
{'repo': repository, 'namespace': namespace})
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
|
||||
@resource('/v1/repository/<apirepopath:repository>/changevisibility')
|
||||
|
|
|
@ -134,4 +134,4 @@ class RepositoryToken(RepositoryParamResource):
|
|||
'code': code},
|
||||
repo=model.repository.get_repository(namespace, repository))
|
||||
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
|
|
@ -115,7 +115,7 @@ class UserRobot(ApiResource):
|
|||
parent = get_authenticated_user()
|
||||
model.user.delete_robot(format_robot_username(parent.username, robot_shortname))
|
||||
log_action('delete_robot', parent.username, {'robot': robot_shortname})
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
|
||||
@resource('/v1/organization/<orgname>/robots')
|
||||
|
@ -178,7 +178,7 @@ class OrgRobot(ApiResource):
|
|||
if permission.can():
|
||||
model.user.delete_robot(format_robot_username(orgname, robot_shortname))
|
||||
log_action('delete_robot', orgname, {'robot': robot_shortname})
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
|
|
|
@ -369,7 +369,7 @@ class SuperUserManagement(ApiResource):
|
|||
abort(403)
|
||||
|
||||
model.user.delete_user(user, all_queues, force=True)
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
abort(403)
|
||||
|
||||
|
@ -503,7 +503,7 @@ class SuperUserOrganizationManagement(ApiResource):
|
|||
org = model.organization.get_organization(name)
|
||||
|
||||
model.user.delete_user(org, all_queues)
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
abort(403)
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ class RepositoryTag(RepositoryParamResource):
|
|||
{'username': username, 'repo': repository, 'tag': tag},
|
||||
repo=model.repository.get_repository(namespace, repository))
|
||||
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
|
||||
@resource('/v1/repository/<apirepopath:repository>/tag/<tag>/images')
|
||||
|
|
|
@ -175,7 +175,7 @@ class OrganizationTeam(ApiResource):
|
|||
if permission.can():
|
||||
model.team.remove_team(orgname, teamname, get_authenticated_user().username)
|
||||
log_action('org_delete_team', orgname, {'team': teamname})
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
|
@ -293,11 +293,11 @@ class TeamMember(ApiResource):
|
|||
'team': teamname,
|
||||
'member': membername
|
||||
})
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
model.team.remove_user_from_team(orgname, teamname, membername, invoking_user)
|
||||
log_action('org_remove_team_member', orgname, {'member': membername, 'team': teamname})
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
|
@ -353,7 +353,7 @@ class InviteTeamMember(ApiResource):
|
|||
'team': teamname,
|
||||
'member': email
|
||||
})
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
|
@ -418,4 +418,4 @@ class TeamMemberInvite(ApiResource):
|
|||
'inviter': inviter.username
|
||||
})
|
||||
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
|
|
@ -421,7 +421,7 @@ class User(ApiResource):
|
|||
abort(404)
|
||||
|
||||
model.user.delete_user(get_authenticated_user(), all_queues)
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
|
||||
@resource('/v1/user/private')
|
||||
|
@ -873,7 +873,7 @@ class UserAuthorization(ApiResource):
|
|||
raise NotFound()
|
||||
|
||||
access_token.delete_instance(recursive=True, delete_nullable=True)
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
@resource('/v1/user/starred')
|
||||
class StarredRepositoryList(ApiResource):
|
||||
|
@ -956,7 +956,7 @@ class StarredRepository(RepositoryParamResource):
|
|||
|
||||
if repo:
|
||||
model.repository.unstar_repository(user, repo)
|
||||
return 'Deleted', 204
|
||||
return '', 204
|
||||
|
||||
|
||||
@resource('/v1/users/<username>')
|
||||
|
|
Reference in a new issue