add api to delete subscriber device
diff --git a/xos/api/examples/cord/delete_subscriber_device.sh b/xos/api/examples/cord/delete_subscriber_device.sh
new file mode 100755
index 0000000..13c357f
--- /dev/null
+++ b/xos/api/examples/cord/delete_subscriber_device.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+source ./config.sh
+source ./util.sh
+
+ACCOUNT_NUM=1238
+MAC="19:28:37:46:55"
+
+SUBSCRIBER_ID=$(lookup_account_num $ACCOUNT_NUM)
+if [[ $? != 0 ]]; then
+ exit -1
+fi
+
+curl -H "Accept: application/json; indent=4" -H "Content-Type: application/json" -u $AUTH -X DELETE $HOST/api/tenant/cord/subscriber/$SUBSCRIBER_ID/devices/$MAC/
diff --git a/xos/api/tenant/cord/subscriber.py b/xos/api/tenant/cord/subscriber.py
index 5238034..eab6cb3 100644
--- a/xos/api/tenant/cord/subscriber.py
+++ b/xos/api/tenant/cord/subscriber.py
@@ -211,7 +211,7 @@
patterns.append( self.detail_url("identity/(?P<identity>[a-zA-Z0-9\-_]+)/$", {"get": "get_identity", "put": "set_identity"}, "get_identity") )
patterns.append( self.detail_url("devices/$", {"get": "get_devices", "post": "add_device"}, "devicees") )
- patterns.append( self.detail_url("devices/(?P<mac>[a-zA-Z0-9\-_:]+)/$", {"get": "get_device"}, "getset_device") )
+ patterns.append( self.detail_url("devices/(?P<mac>[a-zA-Z0-9\-_:]+)/$", {"get": "get_device", "delete": "delete_device"}, "getset_device") )
patterns.append( self.detail_url("devices/(?P<mac>[a-zA-Z0-9\-_:]+)/features/(?P<feature>[a-zA-Z0-9\-_]+)/$", {"get": "get_device_feature", "put": "set_device_feature"}, "getset_device_feature") )
patterns.append( self.detail_url("devices/(?P<mac>[a-zA-Z0-9\-_:]+)/identity/(?P<identity>[a-zA-Z0-9\-_]+)/$", {"get": "get_device_identity", "put": "set_device_identity"}, "getset_device_identity") )
@@ -304,6 +304,15 @@
return Response("Failed to find device %s" % mac, status=status.HTTP_404_NOT_FOUND)
return Response(DeviceSerializer(CordDevice(device, subscriber)).data)
+ def delete_device(self, request, pk=None, mac=None):
+ subscriber = self.get_object()
+ device = subscriber.find_device(mac)
+ if not device:
+ return Response("Failed to find device %s" % mac, status=status.HTTP_404_NOT_FOUND)
+ subscriber.delete_device(mac)
+ subscriber.save()
+ return Response("Okay")
+
def get_device_feature(self, request, pk=None, mac=None, feature=None):
subscriber = self.get_object()
device = subscriber.find_device(mac)