コード例 #1
0
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)
コード例 #2
0
ファイル: examples.py プロジェクト: sharpie7/iotdm-pyclient
from onem2m_xml_protocols.ae import ae
from onem2m_xml_protocols.container import cnt
from onem2m_xml_protocols.contentinstance import cin
from onem2m_xml_protocols.subscription import sub
from onem2m_xml_protocols.remotecse import csr
from onem2m_xml_protocols.acp import acp
from onem2m_xml_protocols.acp import acr
from onem2m_xml_protocols.group import grp
from onem2m_xml_protocols.node import nod
from onem2m_xml_protocols.firmware import fwr

# RestConf calls require admin access
iotdm_api.restConf('http://localhost', 'InCSE1', 'admin', 'admin')

# Clean-up of resource tree
iotdm_api.cleanup('http://localhost', 'admin', 'admin')

# CoAP Creation of an AE named "myAE" under the CSE base "InCSE1".
AE = ae()
AE.set_api("Nk836-t071-fc022")
AE.set_rr(True)
AE.set_rn("myAE")
payload = AE.to_JSON()
iotdm_api.create("coap://localhost:5683/InCSE1",
                 2,
                 payload,
                 origin="AE-ID",
                 requestID="12345")

# Creation of a Container named "mySubContainer" with a maximum number of instances of 5, under "myContainer".
container = cnt()
コード例 #3
0
from onem2m_xml_protocols.container import cnt
from onem2m_xml_protocols.contentinstance import cin
from onem2m_xml_protocols.subscription import sub
from onem2m_xml_protocols.remotecse import csr
from onem2m_xml_protocols.acp import acp
from onem2m_xml_protocols.acp import acr
from onem2m_xml_protocols.group import grp
from onem2m_xml_protocols.node import nod
from onem2m_xml_protocols.firmware import fwr


# RestConf calls require admin access
iotdm_api.restConf('http://localhost', 'InCSE1', 'admin', 'admin')

# Clean-up of resource tree
iotdm_api.cleanup('http://localhost', 'admin', 'admin')


# CoAP Creation of an AE named "myAE" under the CSE base "InCSE1".
AE = ae()
AE.set_api("Nk836-t071-fc022")
AE.set_rr(True)
AE.set_rn("myAE")
payload = AE.to_JSON()
iotdm_api.create("coap://localhost:5683/InCSE1", 2, payload, origin="AE-ID", requestID="12345")


# Creation of a Container named "mySubContainer" with a maximum number of instances of 5, under "myContainer".
container = cnt()
container.set_rn("mySubContainer")
container.set_mni(5)