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
7280e504
Commit
7280e504
authored
8 years ago
by
Nathaniel Kofalt
Browse files
Options
Downloads
Patches
Plain Diff
Add route to return a gear's invocation schema
parent
097b3234
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
api/api.py
+2
-1
2 additions, 1 deletion
api/api.py
api/jobs/gears.py
+5
-0
5 additions, 0 deletions
api/jobs/gears.py
api/jobs/handlers.py
+9
-1
9 additions, 1 deletion
api/jobs/handlers.py
with
16 additions
and
2 deletions
api/api.py
+
2
−
1
View file @
7280e504
...
@@ -123,7 +123,8 @@ routes = [
...
@@ -123,7 +123,8 @@ routes = [
]),
]),
webapp2
.
Route
(
r
'
/api/gears
'
,
GearsHandler
),
webapp2
.
Route
(
r
'
/api/gears
'
,
GearsHandler
),
webapp2_extras
.
routes
.
PathPrefixRoute
(
r
'
/api/gears
'
,
[
webapp2_extras
.
routes
.
PathPrefixRoute
(
r
'
/api/gears
'
,
[
webapp2
.
Route
(
r
'
/<:[^/]+>
'
,
GearHandler
,
name
=
'
job
'
),
webapp2
.
Route
(
r
'
/<:[^/]+>
'
,
GearHandler
),
webapp2
.
Route
(
r
'
/<:[^/]+>/invocation
'
,
GearHandler
,
handler_method
=
'
get_invocation
'
),
]),
]),
webapp2
.
Route
(
r
'
/api/rules
'
,
RulesHandler
),
webapp2
.
Route
(
r
'
/api/rules
'
,
RulesHandler
),
webapp2
.
Route
(
r
'
/api/groups
'
,
grouphandler
.
GroupHandler
,
handler_method
=
'
get_all
'
,
methods
=
[
'
GET
'
]),
webapp2
.
Route
(
r
'
/api/groups
'
,
grouphandler
.
GroupHandler
,
handler_method
=
'
get_all
'
,
methods
=
[
'
GET
'
]),
...
...
This diff is collapsed.
Click to expand it.
api/jobs/gears.py
+
5
−
0
View file @
7280e504
...
@@ -5,6 +5,8 @@ Gears
...
@@ -5,6 +5,8 @@ Gears
from
..
import
config
from
..
import
config
from
.jobs
import
Job
from
.jobs
import
Job
import
gear_tools
log
=
config
.
log
log
=
config
.
log
# For now, gears are in a singleton, prefixed by a key
# For now, gears are in a singleton, prefixed by a key
...
@@ -49,6 +51,9 @@ def get_gear_by_name(name):
...
@@ -49,6 +51,9 @@ def get_gear_by_name(name):
# Mongo returns the full document: { '_id' : 'gears', 'gear_list' : [ { .. } ] }, so strip that out
# Mongo returns the full document: { '_id' : 'gears', 'gear_list' : [ { .. } ] }, so strip that out
return
gear_doc
[
SINGLETON_KEY
][
0
]
return
gear_doc
[
SINGLETON_KEY
][
0
]
def
get_invocation
(
gear
):
return
gear_tools
.
derive_invocation_schema
(
gear
[
'
manifest
'
])
def
insert_gear
(
doc
):
def
insert_gear
(
doc
):
config
.
db
.
singletons
.
update
(
config
.
db
.
singletons
.
update
(
{
"
_id
"
:
"
gears
"
},
{
"
_id
"
:
"
gears
"
},
...
...
This diff is collapsed.
Click to expand it.
api/jobs/handlers.py
+
9
−
1
View file @
7280e504
...
@@ -9,7 +9,7 @@ from ..dao.containerutil import create_filereference_from_dictionary, create_con
...
@@ -9,7 +9,7 @@ from ..dao.containerutil import create_filereference_from_dictionary, create_con
from
..
import
base
from
..
import
base
from
..
import
config
from
..
import
config
from
.gears
import
get_gears
,
get_gear_by_name
,
remove_gear
,
upsert_gear
from
.gears
import
get_gears
,
get_gear_by_name
,
get_invocation
,
remove_gear
,
upsert_gear
from
.jobs
import
Job
from
.jobs
import
Job
from
.queue
import
Queue
from
.queue
import
Queue
...
@@ -41,6 +41,14 @@ class GearHandler(base.RequestHandler):
...
@@ -41,6 +41,14 @@ class GearHandler(base.RequestHandler):
return
get_gear_by_name
(
_id
)
return
get_gear_by_name
(
_id
)
def
get_invocation
(
self
,
_id
):
if
self
.
public_request
:
self
.
abort
(
403
,
'
Request requires login
'
)
gear
=
get_gear_by_name
(
_id
)
return
get_invocation
(
gear
)
def
post
(
self
,
_id
):
def
post
(
self
,
_id
):
"""
Upsert an entire gear document.
"""
"""
Upsert an entire gear document.
"""
...
...
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