def test_TD_M2M_NH_33_Update_Group(self): group = grp() payload = group.to_JSON() iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestGroup", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_37_Update_Node(self): node = nod() payload = node.to_JSON() iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestNode", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_04_Update_RemoteCSE(self): remoteCSE = csr() payload = remoteCSE.to_JSON() iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse", payload, origin="CSE3219", requestID="12345")
def test_TD_M2M_NH_08_Update_AE(self): AE = ae() AE.set_acpi(["ODL-oneM2M-Cse/TestAE/TestACP"]) payload = AE.to_JSON() iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", payload, origin="admin", requestID="12345")
def test_TD_M2M_NH_12_Update_Container(self): container = cnt() payload = container.to_JSON() iotdm_api.update( "coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_24_Update_Subscription(self): subscription = sub() payload = subscription.to_JSON() iotdm_api.update( "coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestSubscription", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_SH_06_Update_MgmtObj(self): firmware = fwr() firmware.set_mgd("1001") firmware.set_ud(False) payload = firmware.to_JSON() iotdm_api.update( "coap://localhost:5683/ODL-oneM2M-Cse/TestNode/TestFirmware", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_28_Update_AccessControlPolicy(self): accessControlRule1 = acr() accessControlRule1.set_acor(["admin"]) accessControlRule1.set_acop(63) pv_payload = accessControlRule1.to_JSON() accessControlRule2 = acr() accessControlRule2.set_acor(["admin"]) accessControlRule2.set_acop(63) pvs_payload = accessControlRule2.to_JSON() accessControlPolicy = acp() accessControlPolicy.set_pv(pv_payload) accessControlPolicy.set_pvs(pvs_payload) accessControlPolicy.set_rn("TestACP") payload = accessControlPolicy.to_JSON() iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestACP", payload, origin="admin", requestID="12345")
def __main__(): parser = argparse.ArgumentParser(description="Command-line Interface for IoTDM Python Client") parser.add_argument('protocol', help='Protocol for Requests', choices=['http', 'coap'], type=str) parser.add_argument('--from', '-fr', dest='from', help='From Which IP Address', type=str) parser.add_argument('--to', '-t', dest='host', help='To Which IP Address', type=str) parser.add_argument('--path', '-pa', dest='path', help='path', type=str, default='') parser.add_argument('--name', '-nm', dest='name', help='Resource Name', type=str) parser.add_argument('--op', '-o', dest='operation', help='Operation', choices=['restconf', 'kill', 'create', 'retrieve', 'update', 'delete'], type=str, required=True) parser.add_argument('--port', '-p', dest='port', help='Port Number', type=str) parser.add_argument('--primitiveContent', '-pc', dest='payload', help='payload', type=str) parser.add_argument('--requestIdentifier', '-rqi', dest='rqi', help='Request ID', type=str) parser.add_argument('--resourceType', '-ty', dest='ty', help='Resource Type', type=str) args = parser.parse_args() url = '%s://%s' %(args.protocol, args.host) if args.operation == 'restconf': iotdm_api.restConf(url, args.name, 'admin', 'admin') if args.operation == 'kill': iotdm_api.cleanup(url, 'admin', 'admin') if args.operation == 'create': url = url + ':%s/%s' %(args.port, args.path) iotdm_api.create(url, args.ty, args.name, args.payload) if args.operation == 'retrieve': url = url + ':%s/%s' %(args.port, args.path) iotdm_api.retrieve(url) if args.operation == 'update': url = url + ':%s/%s' %(args.port, args.path) iotdm_api.update(url, args.ty, args.payload) if args.operation == 'delete': url = url + ':%s/%s' %(args.port, args.path) iotdm_api.delete(url)
iotdm_api.create("http://localhost:8282/InCSE1/myAE/myContainer", 3, payload, origin="AE-ID", requestID="12345") # Creation of a Content Instance named "myOtherContentInstance" under "mySubContainer", with "world" as its content. con_instance = cin() con_instance.set_con("world") con_instance.set_rn("myOtherContentInstance") payload = con_instance.to_JSON() iotdm_api.create("http://localhost:8282/InCSE1/myAE/myContainer/mySubContainer", 4, payload, origin="AE-ID", requestID="12345") # Update of the Container "mySubContainer", with its attribute "label" being set to "submarine" container = cnt() container.set_lbl(["submarine"]) payload = container.to_JSON() iotdm_api.update("http://localhost:8282/InCSE1/myAE/myContainer/mySubContainer", payload, origin="AE-ID", requestID="12345") # Deletion of the ContentInstance "myContentInstance" iotdm_api.delete("http://localhost:8282/InCSE1/myAE/myContainer/myContentInstance", origin="AE-ID", requestID="12345") '''Subscription creation''' # subscription = sub() # subscription.set_nu(["10.195.131.12"]) # payload = subscription.to_JSON() # iotdm_api.create("coap://127.0.0.1:5683/ODL-oneM2M-Cse/AE/Container", 23, "sub1", payload) '''Get''' # iotdm_api.retrieve("http://localhost:8282/ODL-oneM2M-Cse?fu=1")
def test_TD_M2M_SH_06_Update_MgmtObj(self): firmware = fwr() firmware.set_mgd("1001") firmware.set_ud(False) payload = firmware.to_JSON() iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestNode/TestFirmware", payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_12_Update_Container(self): container = cnt() payload = container.to_JSON() iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", payload, origin="CSE3219/C9886", requestID="12345")
con_instance.set_con("world") con_instance.set_rn("myOtherContentInstance") payload = con_instance.to_JSON() iotdm_api.create( "http://localhost:8282/InCSE1/myAE/myContainer/mySubContainer", 4, payload, origin="AE-ID", requestID="12345") # Update of the Container "myContainer", with its attribute "Ontology Reference" being set to "http://info" container = cnt() container.set_or("http://info") payload = container.to_JSON() iotdm_api.update("http://localhost:8282/InCSE1/myAE/myContainer", payload, origin="AE-ID", requestID="12345") # Update of the Container "mySubContainer", with its attribute "label" being set to "submarine" container = cnt() container.set_lbl(["submarine"]) payload = container.to_JSON() iotdm_api.update( "http://localhost:8282/InCSE1/myAE/myContainer/mySubContainer", payload, origin="AE-ID", requestID="12345") # Deletion of the ContentInstance "myContentInstance" iotdm_api.delete( "http://localhost:8282/InCSE1/myAE/myContainer/myContentInstance",
def test_TD_M2M_NH_24_Update_Subscription(self): subscription = sub() payload = subscription.to_JSON() iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestSubscription", payload, origin="CSE3219/C9886", requestID="12345")