Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
19fa6132
Commit
19fa6132
authored
7 years ago
by
Megan Henning
Browse files
Options
Downloads
Patches
Plain Diff
Add direct access to analysis file dl
parent
9301a8d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/api.py
+11
-9
11 additions, 9 deletions
api/api.py
api/handlers/refererhandler.py
+13
-4
13 additions, 4 deletions
api/handlers/refererhandler.py
with
24 additions
and
13 deletions
api/api.py
+
11
−
9
View file @
19fa6132
...
...
@@ -238,11 +238,11 @@ endpoints = [
]),
# Analysis
route
(
'
/analyses/<_id:{cid}>
'
,
AnalysesHandler
,
m
=
[
'
GET
'
]),
prefix
(
'
/
<:{cname}>/<:{cid}>/<cont_name:
analyses
>
/<
c
id:{cid}>
'
,
[
route
(
'
/<
list_name:not
es
>
'
,
NotesListHandler
,
m
=
[
'
POS
T
'
]),
route
(
'
/<
list_name:not
es
>
/<
_id:{nid}>
'
,
NotesListHandler
,
name
=
'
notes
'
,
m
=
[
'
GET
'
,
'
PUT
'
,
'
DELETE
'
]),
])
,
route
(
'
/analyses/<_id:{cid}>
'
,
AnalysesHandler
,
m
=
[
'
GET
'
]),
prefix
(
'
/analyses/<
_
id:{cid}>
'
,
[
route
(
'
/<
_id:{cid}>/fil
es
'
,
AnalysesHandler
,
h
=
'
download
'
,
m
=
[
'
GE
T
'
]),
route
(
'
/<
_id:{cid}>/fil
es/<
filename:{fname}>
'
,
AnalysesHandler
,
h
=
'
download
'
,
m
=
[
'
GET
'
]),
])
# Containers
...
...
@@ -263,11 +263,13 @@ endpoints = [
route
(
'
/<list_name:files>/<name:{fname}>/info
'
,
FileListHandler
,
h
=
'
get_info
'
,
m
=
[
'
GET
'
]),
route
(
'
/<list_name:files>/<name:{fname}>/info
'
,
FileListHandler
,
h
=
'
modify_info
'
,
m
=
[
'
POST
'
]),
route
(
'
/analyses
'
,
AnalysesHandler
,
m
=
[
'
POST
'
]),
route
(
'
/analyses
'
,
AnalysesHandler
,
m
=
[
'
POST
'
]),
prefix
(
'
/analyses
'
,
[
route
(
'
/<_id:{cid}>
'
,
AnalysesHandler
,
m
=
[
'
GET
'
,
'
PUT
'
,
'
DELETE
'
]),
route
(
'
/<_id:{cid}>/files
'
,
AnalysesHandler
,
h
=
'
download
'
,
m
=
[
'
GET
'
]),
route
(
'
/<_id:{cid}>/files/<filename:{fname}>
'
,
AnalysesHandler
,
h
=
'
download
'
,
m
=
[
'
GET
'
]),
route
(
'
/<_id:{cid}>
'
,
AnalysesHandler
,
m
=
[
'
GET
'
,
'
PUT
'
,
'
DELETE
'
]),
route
(
'
/<_id:{cid}>/files
'
,
AnalysesHandler
,
h
=
'
download
'
,
m
=
[
'
GET
'
]),
route
(
'
/<_id:{cid}>/files/<filename:{fname}>
'
,
AnalysesHandler
,
h
=
'
download
'
,
m
=
[
'
GET
'
]),
route
(
'
/<_id:{cid}>/<list_name:notes>
'
,
NotesListHandler
,
m
=
[
'
POST
'
]),
route
(
'
/<_id:{cid}>/<list_name:notes>/<_id:{nid}>
'
,
NotesListHandler
,
name
=
'
notes
'
,
m
=
[
'
GET
'
,
'
PUT
'
,
'
DELETE
'
]),
]),
route
(
'
/<list_name:notes>
'
,
NotesListHandler
,
m
=
[
'
POST
'
]),
...
...
This diff is collapsed.
Click to expand it.
api/handlers/refererhandler.py
+
13
−
4
View file @
19fa6132
...
...
@@ -153,9 +153,11 @@ class AnalysesHandler(RefererHandler):
self
.
abort
(
404
,
'
Analysis {} not removed from container {} {}
'
.
format
(
_id
,
cont_name
,
cid
))
def
download
(
self
,
cont_name
,
cid
,
_id
,
filename
=
None
):
def
download
(
self
,
**
kwargs
):
"""
.. http:get:: /api/(cont_name)/(cid)/analyses/(analysis_id)/files/(file_name)
.. http:get:: /api/(cont_name)*/(cid)*/analyses/(analysis_id)/files/(file_name)*
* - not required
Download a file from an analysis or download a tar of all files
...
...
@@ -249,7 +251,15 @@ class AnalysesHandler(RefererHandler):
"""
parent
=
self
.
storage
.
get_parent
(
cont_name
,
cid
)
_id
=
kwargs
.
get
(
'
_id
'
)
analysis
=
self
.
storage
.
get_container
(
_id
)
filename
=
kwargs
.
get
(
'
filename
'
)
cid
=
analysis
[
'
parent
'
][
'
id
'
]
cont
=
analysis
[
'
parent
'
][
'
cont
'
]
parent
=
self
.
storage
.
get_parent
(
cont
,
cid
)
permchecker
=
self
.
get_permchecker
(
parent
)
permchecker
=
self
.
get_permchecker
(
parent
)
ticket_id
=
self
.
get_param
(
'
ticket
'
)
ticket
=
None
...
...
@@ -260,7 +270,6 @@ class AnalysesHandler(RefererHandler):
if
not
self
.
origin
.
get
(
'
id
'
):
self
.
origin
=
ticket
.
get
(
'
origin
'
)
analysis
=
self
.
storage
.
get_container
(
_id
)
fileinfo
=
analysis
.
get
(
'
files
'
,
[])
if
filename
:
fileinfo
=
[
fi
for
fi
in
fileinfo
if
fi
[
'
name
'
]
==
filename
]
...
...
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