draftSchemaIds = api.getSchemas(draft=True)[0] activeSchemaIds = api.getSchemas()[0] global draftEventTypes, activeEventTypes draftEventTypes = api.getEventTypes(draft=True)[0] activeEventTypes = api.getEventTypes()[0] global draftPhysicalInterfaces, activePhysicalInterfaces draftPhysicalInterfaces = api.getPhysicalInterfaces(draft=True)[0] activePhysicalInterfaces = api.getPhysicalInterfaces()[0] global draftLogicalInterfaces, activeLogicalInterfaces draftLogicalInterfaces = api.getLogicalInterfaces(draft=True)[0] activeLogicalInterfaces = api.getLogicalInterfaces()[0] result = api.getDeviceTypes() for devicetype in result["results"]: logger.info("Processing device type %s" % (devicetype["id"], )) mm.insert('/' + "Device type: " + devicetype["id"]) mm.push() # device type mm.insert("active") mm.push() # active getPhysicalInterface(api, mm, devicetype) mm.pop() # active getLogicalInterfaces(api, mm, devicetype) mm.pop() mm.push() # device type mm.insert("draft") mm.push() # draft getPhysicalInterface(api, mm, devicetype, draft=True) mm.pop() # draft
result = api.deleteEventType(eventTypeId) result = api.deleteSchema(schemaId) count += 2 schemaIds.append(schemaId) print("Event types and event type schemas deleted:", count, schemaIds) if __name__ == "__main__": from properties import orgid, key, token, devicetype, deviceid import ibmiotf.api api = ibmiotf.api.ApiClient({"auth-key": key, "auth-token": token}) # find all the device types devicetypes = [x["id"] for x in api.getDeviceTypes()["results"]] print("Device types", devicetypes) # find all application interfaces appintids, result = api.getApplicationInterfaces() if len(appintids) > 0: print("Application interface ids", appintids) # try and delete the application interfaces for appintid in appintids: try: result = api.deleteApplicationInterface(appintid) except Exception as exc: print(exc) #if it fails, remove the app interface from the device type for devicetype in devicetypes:
# Ian Craggs # ***************************************************************************** from __future__ import print_function import time, ibmiotf.api if __name__ == "__main__": domain = None verify = True from properties import orgid, key, token, devicetype, deviceid try: from properties import domain except: pass try: from properties import verify except: pass params = {"auth-key": key, "auth-token": token} if domain: params["domain"] = domain api = ibmiotf.api.ApiClient(params) api.verify = verify print( [x for x in api.getDeviceTypes()["results"] if x['id'] == devicetype])
for eventTypeId in eventTypeIds: schemaId = api.getEventType(eventTypeId)["schemaId"] result = api.deleteEventType(eventTypeId) result = api.deleteSchema(schemaId) count += 2; schemaIds.append(schemaId) print("Event types and event type schemas deleted:", count, schemaIds) if __name__ == "__main__": from properties import orgid, key, token, devicetype, deviceid import ibmiotf.api api = ibmiotf.api.ApiClient({"auth-key": key, "auth-token": token}) # find all the device types devicetypes = [x["id"] for x in api.getDeviceTypes()["results"]] print("Device types", devicetypes) # find all application interfaces appintids, result = api.getApplicationInterfaces() if len(appintids) > 0: print("Application interface ids", appintids) # try and delete the application interfaces for appintid in appintids: try: result = api.deleteApplicationInterface(appintid) except Exception as exc: print(exc) #if it fails, remove the app interface from the device type for devicetype in devicetypes: