Subject: |
RE: Need a curl based command to delete a device from group |
Author: |
Michael Rogers |
Posted: |
2021-03-16 18:30 |
Anjan,
Here is a sample payload for removing a device ("server-a") from two groups at the same time ("Group1" & "Group2").
[{"action":"DeviceRouter","method":"removeDevices","data":[{"uids":["/zport/dmd/Devices/Server/Linux/devices/server-a"],"hashcheck":"","uid":"/zport/dmd/Groups/Group1"}],"type":"rpc","tid":20},{"action":"DeviceRouter","method":"removeDevices","data":[{"uids":["/zport/dmd/Devices/Server/Linux/devices/server-a"],"hashcheck":"","uid":"/zport/dmd/Groups/Group2"}],"type":"rpc","tid":21}]
If you ever need to find the syntax for an API call, the easiest thing to do is perform the same step through the GUI and watch the network tab in your browsers dev console.
In practice, it would look something like this:
1. Remove server-a from Group1 and Group2 (click both "Remove" buttons, then click "Save"):
2. Find the relevant device_router call (usually the one that isn't using the getInfo method):
3. Switch from "parsed" to "source" so you can see the raw JSON being sent:
Naturally, all the standard cautions apply:
* Test your API calls in a test/dev environment.
* If no test/dev environment are available, test against a dummy device created for the purposes of the test.
* Make sure you have a known-good backup before automating in your production environment.
------------------------------
Michael J. Rogers
Senior Instructor - Zenoss
Austin TX
------------------------------
Subject: |
RE: Need a curl based command to delete a device from group |
Author: |
Anjan Kumar Tripathy |
Posted: |
2021-03-19 09:12 |
Hi Michel,
Thanks for the reply, I tried it out and it worked.
Your tip really helped me a lot to grab the API from network Tab. didnt knew it before it would be of great help
Regards
Anjan
------------------------------
anjan tripath
Seniour associate
Cognizant
KS
------------------------------
Subject: |
RE: Need a curl based command to delete a device from group |
Author: |
Anjan Kumar Tripathy |
Posted: |
2021-03-19 10:22 |
Thanks