Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jupyter-jsc-custom
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
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
jupyterjsc
packages
jupyter-jsc-custom
Commits
dbc16574
Commit
dbc16574
authored
1 month ago
by
Tim Kreuzer
Browse files
Options
Downloads
Patches
Plain Diff
add some frontend api endpoints for react development
parent
82f7e5cd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
jsc_custom/apihandler/frontend.py
+166
-0
166 additions, 0 deletions
jsc_custom/apihandler/frontend.py
with
166 additions
and
0 deletions
jsc_custom/apihandler/frontend.py
0 → 100644
+
166
−
0
View file @
dbc16574
import
json
from
jupyterhub.handlers
import
default_handlers
from
tornado
import
web
from
..misc
import
get_custom_config
from
..misc
import
get_incidents
from
..misc
import
get_reservations
from
..spawner
import
jhub_hostname
from
..spawner.utils
import
async_decrypted_user_options
from
.misc
import
NoXSRFCheckAPIHandler
class
FHostnameAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
self
.
write
(
jhub_hostname
)
self
.
set_status
(
200
)
return
class
FSystemConfigAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
self
.
write
(
json
.
dumps
(
get_custom_config
().
get
(
"
systems
"
,
{})))
self
.
set_status
(
200
)
return
class
FMapSystemsAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
not
None
:
self
.
write
(
json
.
dumps
(
get_custom_config
().
get
(
"
mapSystems
"
,
{})))
self
.
set_status
(
200
)
return
class
FMapPartitionsAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
not
None
:
self
.
write
(
json
.
dumps
(
get_custom_config
().
get
(
"
mapPartitions
"
,
{})))
self
.
set_status
(
200
)
return
class
FDefaultPartitionsAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
not
None
:
self
.
write
(
json
.
dumps
(
get_custom_config
().
get
(
"
defaultPartitions
"
,
{})))
self
.
set_status
(
200
)
return
class
FServicesAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
not
None
:
self
.
write
(
json
.
dumps
(
get_custom_config
().
get
(
"
services
"
,
{})))
self
.
set_status
(
200
)
return
class
FResourcesAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
not
None
:
self
.
write
(
json
.
dumps
(
get_custom_config
().
get
(
"
resources
"
,
{})))
self
.
set_status
(
200
)
return
class
FUserModulesAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
not
None
:
self
.
write
(
json
.
dumps
(
get_custom_config
().
get
(
"
userModules
"
,
{})))
self
.
set_status
(
200
)
return
class
FBackendServicesAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
not
None
:
self
.
write
(
json
.
dumps
(
get_custom_config
().
get
(
"
backendServices
"
,
{})))
self
.
set_status
(
200
)
return
class
FIncidentCheckAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
self
.
write
(
json
.
dumps
(
get_incidents
(
user
)))
self
.
set_status
(
200
)
return
class
FReservationsAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
not
None
:
self
.
write
(
json
.
dumps
(
get_reservations
()))
self
.
set_status
(
200
)
return
class
FUserOptionsAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
get_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
not
None
:
user_options
=
await
async_decrypted_user_options
(
user
)
self
.
write
(
json
.
dumps
(
user_options
))
self
.
set_status
(
200
)
return
class
FUserAPIHandler
(
NoXSRFCheckAPIHandler
):
async
def
get
(
self
,
user_name
=
""
):
self
.
set_header
(
"
Cache-Control
"
,
"
no-cache
"
)
user
=
self
.
find_user
(
user_name
)
if
user
is
None
:
raise
web
.
HTTPError
(
404
)
ret
=
{}
custom_config
=
get_custom_config
()
ret
[
"
mapSystems
"
]
=
(
custom_config
.
get
(
"
mapSystems
"
,
{}),)
ret
[
"
mapPartitions
"
]
=
(
custom_config
.
get
(
"
mapPartitions
"
,
{}),)
ret
[
"
defaultPartitions
"
]
=
(
custom_config
.
get
(
"
defaultPartitions
"
,
{}),)
ret
[
"
serviceConfig
"
]
=
(
custom_config
.
get
(
"
services
"
,
{}),)
ret
[
"
userModules
"
]
=
(
custom_config
.
get
(
"
userModules
"
,
{}),)
ret
[
"
resourcesConfig
"
]
=
(
custom_config
.
get
(
"
resources
"
,
{}),)
ret
[
"
backendServices
"
]
=
(
custom_config
.
get
(
"
backendServices
"
,
{}),)
ret
[
"
incidents
"
]
=
get_incidents
(
user
)
ret
[
"
reservations
"
]
=
(
get_reservations
(),)
ret
[
"
decrypted_user_options
"
]
=
await
async_decrypted_user_options
self
.
write
(
json
.
dumps
(
ret
))
self
.
set_status
(
200
)
return
default_handlers
.
append
((
r
"
/api/f/incidents
"
,
FHostnameAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/systemconfig
"
,
FSystemConfigAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/mapsystems
"
,
FMapSystemsAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/mappartitions
"
,
FMapPartitionsAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/defaultpartitions
"
,
FDefaultPartitionsAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/services
"
,
FServicesAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/resources
"
,
FResourcesAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/usermodules
"
,
FUserModulesAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/backendservices
"
,
FBackendServicesAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/incidents
"
,
FIncidentCheckAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/reservations
"
,
FReservationsAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/useroptions
"
,
FUserOptionsAPIHandler
))
default_handlers
.
append
((
r
"
/api/f/users
"
,
FUserAPIHandler
))
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