You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@warble.apache.org by hu...@apache.org on 2018/06/26 23:10:06 UTC
[incubator-warble-server] 02/03: add function for removing a node
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-warble-server.git
commit 2b1655c9ebb76e37a113e6d0d6d95f48dcf5c00c
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Jun 26 18:09:46 2018 -0500
add function for removing a node
---
api/pages/node/modify.py | 43 ++++++++++++++++++++++++++++++++++-
ui/js/coffee/warble_clientlist.coffee | 3 +++
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/api/pages/node/modify.py b/api/pages/node/modify.py
index de321a6..03e70df 100644
--- a/api/pages/node/modify.py
+++ b/api/pages/node/modify.py
@@ -39,6 +39,28 @@
# $ref: '#/components/schemas/Error'
# description: unexpected error
# summary: Modifies base data of a node in the registry
+# delete:
+# requestBody:
+# content:
+# application/json:
+# schema:
+# $ref: '#/components/schemas/NodeDetails'
+# description: Node to remove
+# required: true
+# responses:
+# '200':
+# content:
+# application/json:
+# schema:
+# $ref: '#/components/schemas/ActionCompleted'
+# description: Node successfully removed from registry
+# default:
+# content:
+# application/json:
+# schema:
+# $ref: '#/components/schemas/Error'
+# description: unexpected error
+# summary: Deletes a registered node from the server
#
########################################################################
@@ -101,7 +123,26 @@ def run(API, environ, indata, session):
yield json.dumps({"okay": True, "message": "Changes saved"}, indent = 2)
return
-
+
+ # Deleting a node?
+ if method == "DELETE":
+ # Super users only!
+ if not session.user or session.user['userlevel'] != 'superuser':
+ raise API.exception(403, "You need to be logged in as super user to perform this action")
+
+ # Try finding the node in the registry
+ nodeid = indata['id']
+ node = None
+ try:
+ node = plugins.registry.node(session, nodeid)
+ except:
+ raise API.exception(404, "Could not find a node by this ID to modify.")
+
+ # Remove node, say cheese!
+ node.remove()
+ yield json.dumps({"okay": True, "message": "Node removed from registry"}, indent = 2)
+ return
+
# Finally, if we hit a method we don't know, balk!
yield API.exception(400, "I don't know this request method!!")
diff --git a/ui/js/coffee/warble_clientlist.coffee b/ui/js/coffee/warble_clientlist.coffee
index cf55261..2b0ecee 100644
--- a/ui/js/coffee/warble_clientlist.coffee
+++ b/ui/js/coffee/warble_clientlist.coffee
@@ -45,6 +45,9 @@ makeClientType = (main, t) ->
modifyNode = (id, stats) ->
stats['id'] = id
post('node/modify', stats, {}, location.reload())
+
+deleteNode = (id, stats) ->
+ xdelete('node/modify', {id: id}, {}, location.reload())
clientlist = (json, state) ->
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@warble.apache.org
For additional commands, e-mail: commits-help@warble.apache.org