Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-deposit
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine R. Dumont
swh-deposit
Commits
13f3821b
Verified
Commit
13f3821b
authored
7 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
Add service document endpoint
parent
dc9849cc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
debian/control
+4
-1
4 additions, 1 deletion
debian/control
requirements.txt
+2
-0
2 additions, 0 deletions
requirements.txt
swh/deposit/server.py
+27
-27
27 additions, 27 deletions
swh/deposit/server.py
swh/deposit/templates/service_document.xml
+8
-11
8 additions, 11 deletions
swh/deposit/templates/service_document.xml
with
41 additions
and
39 deletions
debian/control
+
4
−
1
View file @
13f3821b
...
...
@@ -6,7 +6,10 @@ Build-Depends: debhelper (>= 9),
dh-python,
python3-all,
python3-aiohttp,
python3-swh.core,
python3-swh.core (>= ~0.0.14),
python3-defusedxml,
python3-jinja2,
python3-click,
python3-vcversioner
Standards-Version: 3.9.6
Homepage: https://forge.softwareheritage.org/diffusion/<PHABRICATOR_CALLSIGN>/
...
...
This diff is collapsed.
Click to expand it.
requirements.txt
+
2
−
0
View file @
13f3821b
...
...
@@ -4,5 +4,7 @@
vcversioner
aiohttp
defusedxml
jinja
retrying
click
This diff is collapsed.
Click to expand it.
swh/
sword
/server.py
→
swh/
deposit
/server.py
+
27
−
27
View file @
13f3821b
...
...
@@ -6,73 +6,73 @@
import
asyncio
import
aiohttp.web
import
click
import
json
import
multidict
import
jinja2
from
swh.core
import
config
from
swh.core.api_async
import
(
SWHRemoteAPI
,
decode_request
)
from
swh.core.api_async
import
SWHRemoteAPI
DEFAULT_CONFIG
=
{
'
host
'
:
(
'
str
'
,
'
0.0.0.0
'
),
'
port
'
:
(
'
int
'
,
5012
),
'
max_upload_size
'
:
(
'
int
'
,
200
*
1024
*
1024
)
}
def
encode_data
(
data
,
**
kwargs
):
template_loader
=
jinja2
.
FileSystemLoader
(
searchpath
=
[
"
swh/deposit/templates
"
])
template_env
=
jinja2
.
Environment
(
loader
=
template_loader
)
def
encode_data
(
data
,
template_name
=
None
,
**
kwargs
):
return
aiohttp
.
web
.
Response
(
body
=
json
.
dumps
(
data
)
,
headers
=
multidict
.
MultiDict
(
{
'
Content-Type
'
:
'
application/
json
'
}
)
,
body
=
data
,
headers
=
{
'
Content-Type
'
:
'
application/
xml
'
},
**
kwargs
)
@asyncio.coroutine
def
index
(
request
):
return
aiohttp
.
web
.
Response
(
text
=
'
SWH SWORD Server
'
)
@asyncio.coroutine
def
hello
(
request
):
name
=
request
.
match_info
.
get
(
'
name
'
,
"
Anonymous
"
)
text
=
"
Hello, %s
\n
"
%
name
return
aiohttp
.
web
.
Response
(
text
=
text
)
return
aiohttp
.
web
.
Response
(
text
=
'
SWH Deposit Server
'
)
@asyncio.coroutine
def
service_document
():
pass
def
service_document
(
request
):
tpl
=
template_env
.
get_template
(
'
service_document.xml
'
)
output
=
tpl
.
render
(
noop
=
True
,
verbose
=
False
,
max_upload_size
=
200
*
1024
*
1024
)
return
encode_data
(
data
=
output
)
@asyncio.coroutine
def
create_document
():
def
create_document
(
request
):
pass
@asyncio.coroutine
def
update_document
():
def
update_document
(
request
):
pass
@asyncio.coroutine
def
status_operation
():
def
status_operation
(
request
):
pass
@asyncio.coroutine
def
delete_document
():
def
delete_document
(
request
):
raise
ValueError
(
'
Not implemented
'
)
def
make_app
(
config
,
**
kwargs
):
app
=
SWHRemoteAPI
(
**
kwargs
)
app
.
router
.
add_route
(
'
GET
'
,
'
/
'
,
index
)
app
.
router
.
add_route
(
'
GET
'
,
'
/{name}
'
,
hello
)
app
.
router
.
add_route
(
'
GET
'
,
'
/v1/software/
'
,
service_document
)
app
.
router
.
add_route
(
'
GET
'
,
'
/v1/status/
'
,
status_operation
)
app
.
router
.
add_route
(
'
POST
'
,
'
/v1/software/
'
,
create_document
)
app
.
router
.
add_route
(
'
PUT
'
,
'
/v1/software/
'
,
update_document
)
app
.
router
.
add_route
(
'
DELETE
'
,
'
/v1/software/
'
,
delete_document
)
app
.
router
.
add_route
(
'
GET
'
,
'
/
'
,
index
)
app
.
router
.
add_route
(
'
GET
'
,
'
/api/1/deposit/
'
,
service_document
)
app
.
router
.
add_route
(
'
GET
'
,
'
/api/1/status/
'
,
status_operation
)
app
.
router
.
add_route
(
'
POST
'
,
'
/api/1/deposit/
'
,
create_document
)
app
.
router
.
add_route
(
'
PUT
'
,
'
/api/1/deposit/
'
,
update_document
)
app
.
router
.
add_route
(
'
DELETE
'
,
'
/api/1/deposit/
'
,
delete_document
)
app
.
update
(
config
)
return
app
...
...
This diff is collapsed.
Click to expand it.
swh/
sword
/templates/service_document.xml
→
swh/
deposit
/templates/service_document.xml
+
8
−
11
View file @
13f3821b
...
...
@@ -5,25 +5,22 @@
xmlns=
"http://www.w3.org/2007/app"
>
<sword:version>
2.0
</sword:version>
<sword:maxUploadSize>
$
{max_upload_size}
</sword:maxUploadSize>
<!--
<sword:verbose>
true
</sword:verbose>
-->
<!--
<sword:noOp>
true
</sword:noOp>
-->
<sword:maxUploadSize>
{
{
max_upload_size
}
}
</sword:maxUploadSize>
<sword:verbose>
{{ verbose }}
</sword:verbose>
<sword:noOp>
{{ noop }}
</sword:noOp>
<workspace>
<atom:title>
The Software Heritage (SWH) archive
</atom:title>
<collection
href=
"https://sword.softwareherigage.org/v1/software/"
>
<atom:title>
SWH Software Collection
</atom:title>
<accept>
application/zip
</accept>
<collection
href=
"https://sword.softwareherigage.org/v1/deposit/"
>
<atom:title>
SWH Software Archive
</atom:title>
<accept>
application/gzip
</accept>
<accept
alternate=
"multipart-related"
>
application/zip
</accept>
<accept
alternate=
"multipart-related"
>
application/gzip
</accept>
<sword:collectionPolicy>
Collection Policy
</sword:collectionPolicy>
<dcterms:abstract>
Software Heritage's software collection
</dcterms:abstract>
<sword:mediation>
true
</sword:mediation>
<sword:treatment>
Treatment description
</sword:treatment>
<dcterms:abstract>
Software Heritage Archive
</dcterms:abstract>
<sword:mediation>
false
</sword:mediation>
<sword:acceptPackaging>
http://purl.org/net/sword/package/SimpleZip
</sword:acceptPackaging>
<sword:service>
https://sword.softwareheritage.org/v1/
software
/
</sword:service>
<sword:service>
https://sword.softwareheritage.org/v1/
deposit
/
</sword:service>
</collection>
</workspace>
</service>
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