Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mock-cheops
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
chephren
mock-cheops
Commits
b36f4a59
Unverified
Commit
b36f4a59
authored
1 year ago
by
REIG Julien
Browse files
Options
Downloads
Patches
Plain Diff
add presences controller
parent
fcbc9e7c
Branches
Branches containing commit
No related tags found
1 merge request
!16
Node knowledge
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/presences_controller.py
+19
-0
19 additions, 0 deletions
controllers/presences_controller.py
main.py
+2
-0
2 additions, 0 deletions
main.py
with
21 additions
and
0 deletions
controllers/presences_controller.py
0 → 100644
+
19
−
0
View file @
b36f4a59
from
flask
import
Blueprint
,
jsonify
from
flask_restful
import
Api
,
Resource
from
consts.status
import
Status
,
response_offline
from
utils.database_utils
import
get_presence
,
get_state
presences_controller
=
Blueprint
(
'
presences_controller
'
,
__name__
)
api
=
Api
(
presences_controller
)
class
PresencesResource
(
Resource
):
def
get
(
self
,
resource_id
:
str
):
if
get_state
()
==
Status
.
OFFLINE
:
return
response_offline
,
403
presences
=
get_presence
(
resource_id
)
return
jsonify
(
presences
)
api
.
add_resource
(
PresencesResource
,
'
/resources/<string:resource_id>/presences
'
)
This diff is collapsed.
Click to expand it.
main.py
+
2
−
0
View file @
b36f4a59
...
...
@@ -9,6 +9,7 @@ from consts.status import Status
from
controllers.duplicate_controller
import
duplicate_controller
from
controllers.node_controller
import
node_controller
from
controllers.ping_controller
import
ping_controller
from
controllers.presences_controller
import
presences_controller
from
controllers.resource_controller
import
resource_controller
from
controllers.resources_controller
import
resources_controller
from
controllers.state_controller
import
state_controller
...
...
@@ -26,6 +27,7 @@ app.register_blueprint(resources_controller, url_prefix='/api')
app
.
register_blueprint
(
state_controller
,
url_prefix
=
'
/api
'
)
app
.
register_blueprint
(
duplicate_controller
,
url_prefix
=
'
/api
'
)
app
.
register_blueprint
(
ping_controller
,
url_prefix
=
'
/api
'
)
app
.
register_blueprint
(
presences_controller
,
url_prefix
=
'
/api
'
)
@app.route
(
'
/api/subscribe
'
,
methods
=
[
'
GET
'
])
...
...
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