Skip to content

Commit

Permalink
Add list_releases endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Mattia Verga <[email protected]>
  • Loading branch information
mattiaverga committed Jan 20, 2024
1 parent b6f07a0 commit 30ffe50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bodhi-server/bodhi/server/services/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
# Note, this 'rw' is not a typo. The @releases service has
# a ``post`` section at the bottom.
cors_origins=bodhi.server.security.cors_origins_rw)
list_releases = Service(name='list_releases', path='/list_releases/',
description='Fedora Releases',
cors_origins=bodhi.server.security.cors_origins_ro)


@release.get(accept="text/html", renderer="release.html",
Expand Down Expand Up @@ -281,6 +284,10 @@ def get_update_counts(releaseid, stable_only: bool = False):
"active": active}


@list_releases.get(accept=('application/json', 'text/json'),
schema=bodhi.server.schemas.ListReleaseSchema(), renderer='json',
error_handler=bodhi.server.services.errors.json_handler,
validators=releases_get_validators)
@releases.get(accept=('application/json', 'text/json'),
schema=bodhi.server.schemas.ListReleaseSchema(), renderer='json',
error_handler=bodhi.server.services.errors.json_handler,
Expand Down
3 changes: 3 additions & 0 deletions bodhi-server/tests/services/test_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def test_list_releases(self):
assert body['releases'][0]['name'] == 'F17'
assert body['releases'][1]['name'] == 'F22'

res_list = self.app.get('/list_releases/')
assert res_list.json_body == body

def test_list_releases_with_pagination(self):
res = self.app.get('/releases/')
body = res.json_body
Expand Down
1 change: 1 addition & 0 deletions news/5587.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A new `/list_releases/` GET endpoint is available to allow retrieving JSON data through ajax calls.

0 comments on commit 30ffe50

Please sign in to comment.