oktopus icon indicating copy to clipboard operation
oktopus copied to clipboard

Unable to DELETE using REST API - Community Edition

Open WizzerWorks opened this issue 11 months ago • 5 comments

Why can't I remove a a device via REST API?

msm@ubuntu-22-04-lts-template:~/Projects/oktopus-main$ curl -v --location --request DELETE 'http://localhost:8000/api/device?id=oktopus-0-stomp' --header 'Content-Type: application/json' --header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Ik1hcmsgTWlsbGFyZCIsImVtYWlsIjoibWFyay5zLm1pbGxhcmRAZ21haWwuY29tIiwiaXNzIjoiT2t0b3B1cyIsImV4cCI6MTczODg1NjAyOX0.OatJmxqcYym8HdeTuG9dk8H1fJHQK_K2WmPg_WU6R44'
*   Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> DELETE /api/device?id=oktopus-0-stomp HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Type: application/json
> Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Ik1hcmsgTWlsbGFyZCIsImVtYWlsIjoibWFyay5zLm1pbGxhcmRAZ21haWwuY29tIiwiaXNzIjoiT2t0b3B1cyIsImV4cCI6MTczODg1NjAyOX0.OatJmxqcYym8HdeTuG9dk8H1fJHQK_K2WmPg_WU6R44
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 405 Method Not Allowed
< Vary: Origin
< Date: Wed, 05 Feb 2025 22:35:23 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact

WizzerWorks avatar Feb 05 '25 22:02 WizzerWorks

I can list devices ok:

msm@ubuntu-22-04-lts-template:~/Projects/oktopus-main$ curl -v --location 'http://localhost:8000/api/device?page_number=0&page_size=20' --header 'Content-Type: application/json' --header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Ik1hcmsgTWlsbGFyZCIsImVtYWlsIjoibWFyay5zLm1pbGxhcmRAZ21haWwuY29tIiwiaXNzIjoiT2t0b3B1cyIsImV4cCI6MTczODg1NjAyOX0.OatJmxqcYym8HdeTuG9dk8H1fJHQK_K2WmPg_WU6R44'
*   Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /api/device?page_number=0&page_size=20 HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Type: application/json
> Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Ik1hcmsgTWlsbGFyZCIsImVtYWlsIjoibWFyay5zLm1pbGxhcmRAZ21haWwuY29tIiwiaXNzIjoiT2t0b3B1cyIsImV4cCI6MTczODg1NjAyOX0.OatJmxqcYym8HdeTuG9dk8H1fJHQK_K2WmPg_WU6R44
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json
< Vary: Origin
< Date: Wed, 05 Feb 2025 22:37:57 GMT
< Content-Length: 428
< 
{"devices":[{"SN":"oktopus-0-mqtt","Model":"USP Agent","Customer":"","Vendor":"Manufacturer","Version":"","ProductClass":"USP Agent","Alias":"","Status":0,"Mqtt":0,"Stomp":0,"Websockets":0,"Cwmp":0},{"SN":"oktopus-0-stomp","Model":"USP Agent","Customer":"","Vendor":"Manufacturer","Version":"","ProductClass":"USP Agent","Alias":"","Status":0,"Mqtt":0,"Stomp":0,"Websockets":0,"Cwmp":0}],"page":0,"pages":0,"size":20,"total":2}
* Connection #0 to host localhost left intact

WizzerWorks avatar Feb 05 '25 22:02 WizzerWorks

Hello,

Currently there's no way to delete devices through the API, because they would come back in their next connection to the ACS os USP MTPs.

leandrofars avatar Feb 06 '25 20:02 leandrofars

So if a device goes offline, and will not be available again (i.e. service provider removes it from a customer's premises), how does the USP Controller db get notified and updated?

WizzerWorks avatar Feb 06 '25 22:02 WizzerWorks

So if a device goes offline, and will not be available again (i.e. service provider removes it from a customer's premises), how does the USP Controller db get notified and updated?

Unfortunately there's no way to notify the USP Controller and delete the device, but I see your use case is very common and it would be a great enhancement to develop this feature.

leandrofars avatar Feb 07 '25 11:02 leandrofars

Please label this as an enhancement request. Thank you.

Mark-Millard avatar Feb 10 '25 17:02 Mark-Millard

https://github.com/OktopUSP/oktopus/commit/8cd44440d1cea858d0a2391bfb728275b703f1c2 fix this issue

leandrofars avatar May 15 '25 17:05 leandrofars

Thank you for implementing this feature. It will help me with my RDK-B USP demonstrations by cleaning up some stagnant devices no longer available.

Mark-Millard avatar May 19 '25 18:05 Mark-Millard