Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IIIF
backend
Commits
a5456ebb
Verified
Commit
a5456ebb
authored
Jan 26, 2023
by
David Beniamine
Browse files
Options
Downloads
Patches
Plain Diff
Generic donc and marshal
parent
a68f361d
No related branches found
No related tags found
1 merge request
!2
Draft:Generic api v1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Mirador_backend/resources/base.py
+21
-1
21 additions, 1 deletion
Mirador_backend/resources/base.py
Mirador_backend/resources/mirador_resource.py
+6
-7
6 additions, 7 deletions
Mirador_backend/resources/mirador_resource.py
with
27 additions
and
8 deletions
Mirador_backend/resources/base.py
+
21
−
1
View file @
a5456ebb
...
@@ -6,10 +6,15 @@ from apispec import APISpec
...
@@ -6,10 +6,15 @@ from apispec import APISpec
from
flask_restful
import
Resource
from
flask_restful
import
Resource
from
flask_restful_swagger
import
swagger
from
flask_restful_swagger
import
swagger
from
flask_apispec.views
import
MethodResource
from
flask_apispec.views
import
MethodResource
from
flask_apispec
import
marshal_with
,
doc
,
use_kwargs
class
ResourceGroup
(
MethodResource
,
Resource
):
class
SimpleResponse
(
Schema
):
message
=
fields
.
Str
(
default
=
'
Success
'
)
# TODO add notion of model
class
ResourceGroup
(
MethodResource
,
Resource
):
def
get
(
self
):
def
get
(
self
):
# TODO
# TODO
return
{
'
method
'
:
'
get
'
,
'
mode
'
:
'
group
'
}
return
{
'
method
'
:
'
get
'
,
'
mode
'
:
'
group
'
}
...
@@ -18,6 +23,13 @@ class ResourceGroup(MethodResource, Resource):
...
@@ -18,6 +23,13 @@ class ResourceGroup(MethodResource, Resource):
# TODO
# TODO
return
{
'
method
'
:
'
post
'
,
'
mode
'
:
'
group
'
}
return
{
'
method
'
:
'
post
'
,
'
mode
'
:
'
group
'
}
def
genDoc
(
descr
,
tags
):
doc
(
description
=
f
'
Get all
{
descr
}
'
,
tags
=
tags
)(
ResourceGroup
.
get
)
doc
(
description
=
f
'
Create a
{
descr
}
'
,
tags
=
tags
)(
ResourceGroup
.
post
)
# TODO response on JSON object given in param
marshal_with
(
SimpleResponse
)(
ResourceGroup
.
post
)
# TODO marshal collection get response using given object
class
ResourceItem
(
MethodResource
,
Resource
):
class
ResourceItem
(
MethodResource
,
Resource
):
def
get
(
self
,
id
):
def
get
(
self
,
id
):
...
@@ -39,3 +51,11 @@ class ResourceItem(MethodResource, Resource):
...
@@ -39,3 +51,11 @@ class ResourceItem(MethodResource, Resource):
def
delete
(
self
,
id
):
def
delete
(
self
,
id
):
# TODO
# TODO
return
{
'
method
'
:
'
delete
'
,
'
id
'
:
id
,
'
mode
'
:
'
item
'
}
return
{
'
method
'
:
'
delete
'
,
'
id
'
:
id
,
'
mode
'
:
'
item
'
}
def
genDoc
(
descr
,
tags
):
doc
(
description
=
f
'
Get
{
descr
}
by id
'
,
tags
=
tags
)(
ResourceItem
.
get
)
doc
(
description
=
f
'
Create or update a
{
descr
}
by id
'
,
tags
=
tags
)(
ResourceItem
.
post
)
doc
(
description
=
f
'
Updates a
{
descr
}
by id
'
,
tags
=
tags
)(
ResourceItem
.
put
)
doc
(
description
=
f
'
Updates partially a
{
descr
}
by id
'
,
tags
=
tags
)(
ResourceItem
.
patch
)
doc
(
description
=
f
'
deletes a
{
descr
}
by id
'
,
tags
=
tags
)(
ResourceItem
.
delete
)
# TODO marshal
This diff is collapsed.
Click to expand it.
Mirador_backend/resources/mirador_resource.py
+
6
−
7
View file @
a5456ebb
from
Mirador_backend.resources.base
import
ResourceGroup
,
ResourceItem
from
Mirador_backend.resources.base
import
ResourceGroup
,
ResourceItem
from
flask_apispec
import
marshal_with
,
doc
,
use_kwargs
class
MiradorResourceGroup
(
ResourceGroup
):
resourceDescription
=
'
Mirador resource i e, manifest and collection of IIIF resource
'
resourceDescription
=
'
Mirador resource i e, manifest and collection of IIIF resource
'
tags
=
[
'
Mirador resource
'
]
tags
=
[
'
Mirador resource
'
]
doc
(
description
=
f
'
Get all
{
resourceDescription
}
'
,
tags
=
tags
)(
ResourceGroup
.
get
)
doc
(
description
=
f
'
Create a
{
resourceDescription
}
'
,
tags
=
tags
)(
ResourceGroup
.
post
)
class
MiradorResourceGroup
(
ResourceGroup
):
ResourceGroup
.
genDoc
(
resourceDescription
,
tags
)
class
MiradorResourceItem
(
ResourceItem
):
class
MiradorResourceItem
(
ResourceItem
):
pass
ResourceItem
.
genDoc
(
resourceDescription
,
tags
)
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