Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-web
Commits
2dc5c2a9
Commit
2dc5c2a9
authored
1 month ago
by
Renaud Boyer
Browse files
Options
Downloads
Patches
Plain Diff
api/revision: Query parameters serializer
parent
a0d8372d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1383
api: Query parameters serializers
Pipeline
#13743
canceled
1 month ago
Stage: external
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/web/api/views/revision.py
+16
-5
16 additions, 5 deletions
swh/web/api/views/revision.py
with
16 additions
and
5 deletions
swh/web/api/views/revision.py
+
16
−
5
View file @
2dc5c2a9
# Copyright (C) 2015-202
2
The Software Heritage developers
# Copyright (C) 2015-202
5
The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
...
...
@@ -6,11 +6,13 @@
from
typing
import
Optional
from
django.http
import
HttpResponse
from
rest_framework
import
serializers
from
rest_framework.request
import
Request
from
swh.web.api
import
utils
from
swh.web.api.apidoc
import
api_doc
,
format_docstring
from
swh.web.api.apiurls
import
api_route
from
swh.web.api.serializers
import
SoftLimitsIntegerField
from
swh.web.api.views.utils
import
api_lookup
from
swh.web.utils
import
archive
...
...
@@ -157,14 +159,25 @@ def api_revision_directory(
return
result
class
RevisionLogQuerySerializer
(
serializers
.
Serializer
):
"""
Revision Log query parameters serializer.
"""
limit
=
SoftLimitsIntegerField
(
required
=
False
,
default
=
10
,
min_value
=
1
,
max_value
=
10000
)
@api_route
(
r
"
/revision/(?P<sha1_git>[0-9a-f]+)/log/
"
,
"
api-1-revision-log
"
,
checksum_args
=
[
"
sha1_git
"
],
query_params_serializer
=
RevisionLogQuerySerializer
,
)
@api_doc
(
"
/revision/log/
"
,
category
=
"
Archive
"
)
@format_docstring
(
return_revision_array
=
DOC_RETURN_REVISION_ARRAY
)
def
api_revision_log
(
request
:
Request
,
sha1_git
:
str
):
def
api_revision_log
(
request
:
Request
,
sha1_git
:
str
,
validated_query_params
:
dict
[
str
,
int
]
):
"""
.. http:get:: /api/1/revision/(sha1_git)/log/
...
...
@@ -202,14 +215,12 @@ def api_revision_log(request: Request, sha1_git: str):
:swh_web_api:`revision/e1a315fa3fa734e2a6154ed7b5b9ae0eb8987aad/log/`
"""
limit
=
int
(
request
.
query_params
.
get
(
"
limit
"
,
"
10
"
))
limit
=
min
(
limit
,
1000
)
error_msg
=
"
Revision with sha1_git %s not found.
"
%
sha1_git
revisions
=
api_lookup
(
archive
.
lookup_revision_log
,
sha1_git
,
limit
,
validated_query_params
[
"
limit
"
]
,
notfound_msg
=
error_msg
,
enrich_fn
=
utils
.
enrich_revision
,
request
=
request
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment