Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
4b218154
Commit
4b218154
authored
4 years ago
by
Eva Bardou
Committed by
Bastien Abadie
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add an endpoint to retrieve a WorkerVersion by its ID
parent
a580b42d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arkindex/dataimport/api.py
+16
-0
16 additions, 0 deletions
arkindex/dataimport/api.py
arkindex/dataimport/tests/test_workers_api.py
+20
-0
20 additions, 0 deletions
arkindex/dataimport/tests/test_workers_api.py
arkindex/project/api_v1.py
+2
-1
2 additions, 1 deletion
arkindex/project/api_v1.py
with
38 additions
and
1 deletion
arkindex/dataimport/api.py
+
16
−
0
View file @
4b218154
...
...
@@ -649,3 +649,19 @@ class WorkerVersionList(ListCreateAPIView):
reponse_status
=
status
.
HTTP_201_CREATED
if
created
else
status
.
HTTP_200_OK
return
Response
(
WorkerVersionSerializer
(
version
).
data
,
status
=
reponse_status
)
class
WorkerVersionRetrieve
(
CorpusACLMixin
,
RetrieveAPIView
):
"""
Retrieve a specific worker version
"""
permission_classes
=
(
IsVerified
,
)
serializer_class
=
WorkerVersionSerializer
openapi_overrides
=
{
'
tags
'
:
[
'
repos
'
],
}
def
get_queryset
(
self
):
return
WorkerVersion
.
objects
.
filter
(
revision__repo__corpus__in
=
Corpus
.
objects
.
readable
(
self
.
request
.
user
),
)
This diff is collapsed.
Click to expand it.
arkindex/dataimport/tests/test_workers_api.py
+
20
−
0
View file @
4b218154
...
...
@@ -220,3 +220,23 @@ class TestWorkersWorkerVersions(FixtureAPITestCase):
'
revision
'
:
[
'
This field is required.
'
],
'
configuration
'
:
[
'
This field is required.
'
]
})
def
test_retrieve_version_requires_login
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'
api:version-retrieve
'
,
kwargs
=
{
'
pk
'
:
str
(
self
.
version_1
.
id
)}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_retrieve_version_invalid_id
(
self
):
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
get
(
reverse
(
'
api:version-retrieve
'
,
kwargs
=
{
'
pk
'
:
'
12341234-1234-1234-1234-123412341234
'
})
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_404_NOT_FOUND
)
def
test_retrieve_version
(
self
):
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
get
(
reverse
(
'
api:version-retrieve
'
,
kwargs
=
{
'
pk
'
:
str
(
self
.
version_1
.
id
)}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
response
.
json
()
self
.
assertEqual
(
data
[
'
id
'
],
str
(
self
.
version_1
.
id
))
self
.
assertEqual
(
data
[
'
configuration
'
],
{
"
test
"
:
"
test1
"
})
self
.
assertEqual
(
data
[
'
revision
'
][
'
id
'
],
str
(
self
.
rev
.
id
))
This diff is collapsed.
Click to expand it.
arkindex/project/api_v1.py
+
2
−
1
View file @
4b218154
...
...
@@ -27,7 +27,7 @@ from arkindex.dataimport.api import (
DataFileList
,
DataFileRetrieve
,
DataFileUpload
,
DataImportFromFiles
,
RepositoryList
,
RepositoryRetrieve
,
RepositoryStartImport
,
DataFileCreate
,
GitRepositoryImportHook
,
AvailableRepositoriesList
,
RevisionRetrieve
,
MLToolList
,
CorpusWorkflow
,
WorkerList
,
WorkerVersionList
MLToolList
,
CorpusWorkflow
,
WorkerList
,
WorkerVersionList
,
WorkerVersionRetrieve
)
from
arkindex.images.api
import
ImageCreate
,
IIIFURLCreate
,
IIIFInformationCreate
,
ImageRetrieve
,
ImageElements
from
arkindex.users.api
import
(
...
...
@@ -129,6 +129,7 @@ api = [
# Workers
path
(
'
imports/repos/<uuid:pk>/workers/
'
,
WorkerList
.
as_view
(),
name
=
'
repository-workers
'
),
path
(
'
workers/<uuid:pk>/versions/
'
,
WorkerVersionList
.
as_view
(),
name
=
'
worker-versions
'
),
path
(
'
workers/versions/<uuid:pk>/
'
,
WorkerVersionRetrieve
.
as_view
(),
name
=
'
version-retrieve
'
),
# Import workflows
path
(
'
imports/
'
,
DataImportsList
.
as_view
(),
name
=
'
import-list
'
),
...
...
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