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)
def test_TD_M2M_NH_05_Delete_RemoteCSE(self): iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/RemoteCSE", origin="CSE3219", requestID="12345")
def test_TD_M2M_SH_08_Delete_MgmtObj(self): iotdm_api.delete( "coap://localhost:5683/ODL-oneM2M-Cse/TestNode/TestFirmware", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_30_Unauthorized_operation(self): iotdm_api.delete( "coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_29_Delete_AccessControlPolicy(self): iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestACP", origin="admin", requestID="12345")
def test_TD_M2M_NH_25_Delete_Subscription(self): iotdm_api.delete( "coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestSubscription", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_17_Delete_ContentInstance(self): iotdm_api.delete( "coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestContentInstance", origin="CSE3219/C9886", 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") '''Delete''' # iotdm_api.delete("http://127.0.0.1:8282/ODL-oneM2M-Cse/AE4")
def test_TD_M2M_NH_17_Delete_ContentInstance(self): iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestContentInstance", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_09_Delete_AE(self): iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_SH_08_Delete_MgmtObj(self): iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestNode/TestFirmware", origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_30_Unauthorized_operation(self): iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", origin="CSE3219/C9886", requestID="12345")
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", origin="AE-ID", requestID="12345")
def test_TD_M2M_NH_25_Delete_Subscription(self): iotdm_api.delete("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer/TestSubscription", origin="CSE3219/C9886", requestID="12345")