Skip to content

Commit 89647de

Browse files
authored
feat(ns-plug): added ability to update description (#1374)
1 parent 656a5f5 commit 89647de

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

packages/ns-api/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
include $(TOPDIR)/rules.mk
77

88
PKG_NAME:=ns-api
9-
PKG_VERSION:=3.3.1
9+
PKG_VERSION:=3.3.2
1010
PKG_RELEASE:=1
1111

1212
PKG_BUILD_DIR:=$(BUILD_DIR)/ns-api-$(PKG_VERSION)

packages/ns-api/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6920,6 +6920,20 @@ Response example:
69206920
69216921
If the restart fails return a `restart_failed` error.
69226922
6923+
6924+
### update
6925+
6926+
You can update the field `description` that is being sent to the controller.
6927+
```
6928+
api-cli ns.plug update --data '{"description": "My new description"}'
6929+
```
6930+
6931+
Response example:
6932+
```json
6933+
{"result": "success"}
6934+
```
6935+
6936+
69236937
## ns.netifyd
69246938
69256939
Manage netifyd sink configuration.

packages/ns-api/files/ns.plug

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,28 @@ def unregister():
157157
return utils.generic_error("failed_to_reload_firewall")
158158
return {"result": "success"}
159159

160+
161+
def update(args):
162+
if 'description' not in args:
163+
return utils.validation_error("description", "required")
164+
165+
e_uci = EUci()
166+
e_uci.set("ns-plug", "config", "description", args["description"])
167+
e_uci.save("ns-plug")
168+
e_uci.commit("ns-plug")
169+
170+
return {"result": "success"}
171+
172+
160173
cmd = sys.argv[1]
161174

162175
if cmd == 'list':
163176
print(json.dumps({
164177
"register": {"join_code": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "tls_verify": False, "unit_name": "fw.test.local", "description": "my unit"},
165178
"unregister": {},
166179
"status":{},
167-
"restart": {}
180+
"restart": {},
181+
"update": {"description": "my new description"}
168182
}))
169183
else:
170184
action = sys.argv[2]
@@ -175,6 +189,9 @@ else:
175189
ret = status()
176190
elif action == "unregister":
177191
ret = unregister()
192+
elif action == "update":
193+
args = json.load(sys.stdin)
194+
ret = update(args)
178195
elif action == "restart":
179196
ret = {"result": "success"}
180197
try:

0 commit comments

Comments
 (0)