mirror of
https://github.com/OpenMTC/OpenMTC.git
synced 2025-02-11 12:55:17 +00:00
* Test debian stretch+python3 (#18) * changes starting with python3 explicit * removes python modules which are not available for python3 * exchanges fyzz query parsing with rdflib functionality * fixes interop tests * replaces reduce with for loop in nodb driver * simple python2 -> python3 conversions * adds changes for handling different string handling in python3 * test stretch building with travis * installing python-setuptools in docker * installing python-setuptools in docker * changing python2 to python3 in docker makefiles * changing python2 to python3 and some other test changes * push docker only in master branche * running version of openmtc * fix some port problems * porting path library completly now * restoring travis.yml * testing new travis.yml * add sudo * updating travis OS from trusty to xenial * upgrade pip before * show running docker logs * show more logs * for debugging * showlogs of docker after failure * testing new travis.yml * finish travis.yml * Adding roadmap (#26) * adding roadmap * adding a nicer view for some documents * creating contributions.md (#27) * travis only building on master branch (#25) * deleting some typo * another typo * adding a contributer * bump version to 1.3.0 * better link for contributions * Port and fix simple apps * add version tag
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
# Example 11a: Create a resource (continued)
|
|
|
|
from openmtc_onem2m.model import AE
|
|
from openmtc_onem2m.client.http import OneM2MHTTPClient
|
|
from openmtc_onem2m.transport import OneM2MRequest
|
|
|
|
client = OneM2MHTTPClient("http://localhost:8000", False)
|
|
|
|
my_app = AE(App_ID="myApp",
|
|
labels=["keyword1", "keyword2"],
|
|
resourceName="MYAPP1",
|
|
requestReachability=False)
|
|
|
|
onem2m_request = OneM2MRequest("create", to="onem2m", ty=AE, pc=my_app)
|
|
|
|
promise = client.send_onem2m_request(onem2m_request)
|
|
|
|
onem2m_response = promise.get()
|
|
|
|
print(onem2m_response.response_status_code)
|
|
#>>> STATUS(numeric_code=2001, description='CREATED', http_status_code=201)
|
|
|
|
# Build path to retieve from
|
|
path = "onem2m/" + onem2m_response.content.resourceName
|
|
print(path)
|
|
#>>> onem2m/MYAPP
|
|
|
|
# Retrieve the AE from the CSE
|
|
onem2m_request = OneM2MRequest("retrieve", to=path)
|
|
promise = client.send_onem2m_request(onem2m_request)
|
|
onem2m_response = promise.get()
|
|
|
|
print(onem2m_response.response_status_code)
|
|
#>>> STATUS(numeric_code=2000, description='OK', http_status_code=200)
|
|
print(onem2m_response.content)
|
|
#>>> AE(path='None', id='ae0')
|
|
|
|
# Set the local AE to the retrieved content
|
|
my_app = None
|
|
my_app = onem2m_response.content
|
|
|
|
print(my_app.App_ID)
|
|
#>>> myApp
|
|
print(my_app.resourceName)
|
|
#>>> MYAPP
|
|
print(my_app.labels)
|
|
#>>> [u'keyword1', u'keyword2']
|