def _on_register(self): # start endless loop eds_base = os.environ["ET_EDS_EDS_BASE_API"] eds_base = eds_base[:-8] client = OneM2MHTTPClient(eds_base, False) base_path = "onem2m/EDSOrch/testapplication/" sensors_path = base_path + "sensors/" onem2m_request = OneM2MRequest("retrieve", to=sensors_path) promise = client.send_onem2m_request(onem2m_request) onem2m_response = promise.get() children = onem2m_response.content.childResource sensor_path = children[0].path sensor_data = sensors_path + sensor_path + "/data" actuators_path = base_path + "actuators/" onem2m_request = OneM2MRequest("retrieve", to=actuators_path) promise = client.send_onem2m_request(onem2m_request) onem2m_response = promise.get() children = onem2m_response.content.childResource actuator_path = children[0].path actuator_data_out = actuators_path + actuator_path + "/data_out" self.add_container_subscription(sensor_data, self.handle_sensor_data) self.add_container_subscription(actuator_data_out, self.handle_actuator_out) gevent.sleep(0) gevent.spawn_later(60, self.app_shutdown)
def _create_own_remote_cse_remotely(): endpoints = self.api.get_onem2m_endpoints() from openmtc.util import datetime_the_future # init RemoteCSE object cse = RemoteCSE(resourceName=self.cse_id[1:], labels=self.labels, cseType=self.cse_type, pointOfAccess=endpoints, CSEBase=self.cse_base, CSE_ID=self.cse_id, requestReachability=bool(len(endpoints)), expirationTime=datetime_the_future( self.get_offset)) if remote_cse.get('own_poa'): cse.pointOfAccess = remote_cse.get('own_poa') request = OneM2MRequest(OneM2MOperation.create, remote_cse_uri, self.originator, ty=RemoteCSE, pc=cse) return self.api.send_onem2m_request(request)
def _update_own_remote_cse_remotely(): cse = RemoteCSE(expirationTime=instance.expirationTime) # todo: need to check format here? to = remote_cse_id + "/" + instance.resourceID request = OneM2MRequest(OneM2MOperation.update, to, fr=self.originator, ty=RemoteCSE, pc=cse) return self.api.send_onem2m_request(request)
def _do_delete_children(self): child_promises = [] for child in self.resource.childResource: request = OneM2MRequest(OneM2MOperation.delete, child.path, fr=None, rqi=self.request.rqi) request.cascading = True child_promises.append(self.handle_onem2m_request(request)) async_all(child_promises, fulfill_with_none=True).get()
def update_announce_to(): # update_req_ind = UpdateRequestIndication(resource.path + # '/announceTo', resource, # fields=['announceTo'], # do_announce=False) # self.api.handle_request_indication(update_req_ind) # TODO_oneM2M: Update the resource by sending the request cse_req = OneM2MRequest(OneM2MOperation.update, resource.path, str(self), MetaInformation(None), cn=resource, ty=resource)
def send_verification(notify_uri): notification = Notification( verificationRequest=True, creator=self.request.originator ) send_notify_request = OneM2MRequest(OneM2MOperation.notify, notify_uri, None, MetaInformation(None), notification) return self.api.send_onem2m_request(send_notify_request)
def __subscribe(remote_cse): try: remote_cse_id = "/" + remote_cse["cse_id"] except KeyError: raise ConfigurationError('Missing parameter (cse_id) in %s' % remote_cse) subs = Subscription(notificationURI=self.api.get_onem2m_endpoints()) to = remote_cse_id + "/" + remote_cse.get("cse_base", "onem2m") request = OneM2MRequest(OneM2MOperation.create, to, self.originator, ty=Subscription, pc=subs) return self.api.send_onem2m_request(request)
def _create_remote_cse_locally(cse_base): cse = RemoteCSE(resourceName=remote_cse_id[1:], CSEBase=remote_cse_base, CSE_ID=remote_cse_id, cseType=remote_cse_type, pointOfAccess=cse_base.pointOfAccess) cse.pointOfAccess = remote_cse.get('poa') request = OneM2MRequest(OneM2MOperation.create, self.cse_base, self.originator, ty=RemoteCSE, pc=cse) return self.api.handle_onem2m_request(request)
def translate_write_request(self, node_to_write, value_to_write): if self.nodeid_uri_dict.get(node_to_write, None) is not None: #take uri from nodeid resource_uri = self.nodeid_uri_dict.get(node_to_write) #take resource from uri res = self.xae.uri_resource_dict.get(resource_uri) #take attr from node id attr_to_write = self.nodeid_attr_dict.get(node_to_write) update_instance = self.decode_request(res, attr_to_write, value_to_write) onem2m_request = OneM2MRequest( "update", to=self.nodeid_uri_dict.get(node_to_write), pc=update_instance) self.xae.client.send_onem2m_request(onem2m_request)
def _handle_http_request(self, request): onem2m_request = OneM2MRequest(None, None) try: onem2m_request = self.map_http_request_to_onem2m_request(request) onem2m_response = self.request_handler(onem2m_request).get() except OneM2MErrorResponse as error_response: response = self.map_onem2m_error_to_http_error(error_response) except CSEError as error: error_response = OneM2MErrorResponse(error.response_status_code, onem2m_request) response = self.map_onem2m_error_to_http_error(error_response) else: response = self.map_onem2m_response_to_http_response( request, onem2m_response) return response
def _handle_http_request(self, request, subject_alt_name): onem2m_request = OneM2MRequest(None, None) remote_ip_addr = request.environ.get("REMOTE_ADDR", None) # check for impersonation error # the from parameter of the onem2m request is verified against the # association info of the cert # subjectAltName of certificate vs. from parameter of onem2m request impersonation_error = False try: onem2m_request = self.map_http_request_to_onem2m_request(request) setattr(onem2m_request, "_remote_ip_addr", remote_ip_addr) setattr(onem2m_request, "_authenticated", False) if subject_alt_name is not None: setattr(onem2m_request, "_authenticated", True) impersonation_error = not bool( len( filter( lambda x: x[0] == 'URI' and x[1] == onem2m_request. fr, subject_alt_name))) if impersonation_error: onem2m_response = OneM2MResponse(STATUS_IMPERSONATION_ERROR, request=onem2m_request) response = self.map_onem2m_response_to_http_response( request, onem2m_response) return response onem2m_response = self.request_handler(onem2m_request).get() except OneM2MErrorResponse as error_response: response = self.map_onem2m_error_to_http_error(error_response) except CSEError as error: error_response = OneM2MErrorResponse(error.response_status_code, onem2m_request) response = self.map_onem2m_error_to_http_error(error_response) except (ModelTypeError, ValueError): error_response = OneM2MErrorResponse( CSEBadRequest.response_status_code, onem2m_request) response = self.map_onem2m_error_to_http_error(error_response) else: response = self.map_onem2m_response_to_http_response( request, onem2m_response) return response
def translate_read_request(self, node_to_read, old_value): if self.nodeid_uri_dict.get(node_to_read, None) is not None: onem2m_request = OneM2MRequest( "retrieve", to=self.nodeid_uri_dict.get(node_to_read)) promise = self.xae.client.send_onem2m_request(onem2m_request) onem2m_response = promise.get() response = onem2m_response.content attr_to_read = self.opc_openmtc_attrname_dict[ self.nodeid_attr_dict[node_to_read]] new_value = self.decode_response(attr_to_read, getattr(response, attr_to_read)) print(" HTTP-Read_Value: " + str(new_value)) if old_value != new_value: #this type of write not support uncertain response self.server.iserver.isession.initialization_cache = True self.server.get_node(node_to_read).set_value(new_value) self.server.iserver.isession.initialization_cache = False
def send_delete_annc(cse_uri): # * requestingEntity is set to the application; # req_ent from from outer scope # * issuer is set to its own CSE ID (the local CSE performing the # action); # rst: not needed probably # * targetID is set to the resource URI of the previously # announced-resource on the remote CSE. The local CSE received and # stored the URI of the announced resource after it was created. self.logger.debug("announcements %s" % self._announcements) annc_path = self._announcements[resource.path]['uris'][cse_uri] target_id = urljoin(cse_uri, '/onem2m/' + annc_path) cse_req = OneM2MRequest(OneM2MOperation.delete, target_id, None, MetaInformation(None)) self.logger.debug('Deleting Announcement %s' % cse_req) return self.api.send_onem2m_request(cse_req)
# Example 7: Update OneM2MRequest from openmtc_onem2m.transport import OneM2MRequest from openmtc_onem2m.model import AE my_app = AE(App_ID="myApp", labels=["keyword1", "keyword2"]) request = OneM2MRequest("update", to="onem2m", pc=my_app.labels) print request.to #>>> onem2m print request.pc #>>> [u'keyword1', u'keyword2']
# Example 6b: Notify OneM2MRequest with data from openmtc_onem2m.transport import OneM2MRequest import json sensor_data = {"type": "temperature", "value": 15} data_string = json.dumps(sensor_data) request = OneM2MRequest("create", to="onem2m", pc=data_string, ty="application/json") print request.to #>>> onem2m print request.pc #>>> {"type": "temperature", "value": 15}
# Example 12a: Making Requests with error handling from openmtc_onem2m.client.http import OneM2MHTTPClient from openmtc_onem2m.transport import OneM2MRequest, OneM2MErrorResponse from openmtc.exc import OpenMTCError client = OneM2MHTTPClient("http://localhost:8000", False) try: onem2m_request = OneM2MRequest("retrieve", to="onem2m") promise = client.send_onem2m_request(onem2m_request) onem2m_response = promise.get() except OneM2MErrorResponse as e: print("CSE reported an error:", e) raise except OpenMTCError as e: print("Failed to reach the CSE:", e) raise else: pass # no exception was raised, the method returned normally. print(onem2m_response.to) #>>> onem2m print(onem2m_response.response_status_code) #>>> STATUS(numeric_code=2000, description='OK', http_status_code=200) print(onem2m_response.content) #>>> CSEBase(path='None', id='cb0')
# Example 5a: Create OneM2MRequest from openmtc_onem2m.transport import OneM2MRequest from openmtc_onem2m.model import AE my_app = AE(App_ID="myApp") request = OneM2MRequest("create", to="onem2m", pc="my_app") print request.to #>>> onem2m print request.pc #>>> myApp
#!/usr/bin/env python from openmtc_onem2m.client.http import OneM2MHTTPClient from openmtc_onem2m.transport import OneM2MRequest print "setting up http client" client = OneM2MHTTPClient("http://eds-base:8000", False) print "testing reachability of gateway" request = OneM2MRequest("retrieve", to="onem2m") promise = client.send_onem2m_request(request) response = promise.get() if response.response_status_code.http_status_code == 200: print "onem2m gateway found" else: print "onem2m gateway not found" exit - 1 print "testing reachability of EDSOrch" request = OneM2MRequest("retrieve", to="onem2m/EDSOrch") promise = client.send_onem2m_request(request) response = promise.get() if response.response_status_code.http_status_code == 200: print "EDSOrch found" else: print "EDSOrch not found" exit - 1 print "testing reachability of SuT" request = OneM2MRequest("retrieve", to="onem2m/EDSOrch/testapplication")
def _retrieve_remote_cse_base(): request = OneM2MRequest(OneM2MOperation.retrieve, remote_cse_uri, self.originator, ty=CSEBase) return self.api.send_onem2m_request(request)
# create a OneM2MHTTPClient object client = OneM2MHTTPClient("http://localhost:8000", False) # create a resource to be created on the CSE # resourceName: (optional) for easy check in browser # requestReachability: (mandatory) for servercapability of the AE my_app = AE(App_ID="myApp", labels=["keyword1", "keyword2"], resourceName="MYAPP", requestReachability=False) # create a OneM2MRequest object of type 'create' # ty: resource_type of the created resource # pc: Resource content to be transferred onem2m_request = OneM2MRequest("create", to="onem2m", ty=AE, pc=my_app) # send the 'create' OneM2MRequest to the CSE promise = client.send_onem2m_request(onem2m_request) # reteive the OneM2MResponse from the returned promise onem2m_response = promise.get() print(onem2m_response.to) #>>> onem2m print(onem2m_response.response_status_code) #>>> STATUS(numeric_code=2001, description='CREATED', http_status_code=201) print(onem2m_response.content) #>>> AE(path='None', id='ae0') print(onem2m_response.content.App_ID) #>>> myApp
def request(): tmp_app = AE(labels=["foo", "bar", "coffee"]) my_app = AE(App_ID="myApp", labels=["keyword1", "keyword3"], resourceName="MYAPP3", requestReachability=False) memberList = [] memberList.append("onem2m/MYAPP1") memberList.append("onem2m/MYAPP2") memberList.append("onem2m/MYAPP2") memberList.append("onem2m/MYAPP3") memberList.append("onem2m/MYAPP3") memGroup = [] memGroup.append("onem2m/grp1") my_group2 = Group(labels=["keyword1", "keyword2"], resourceName="grp2", memberType=9, maxNrOfMembers=3, memberIDs=memGroup, consistencyStrategy=3) my_group = Group(labels=["keyword1", "keyword2"], memberType=2, resourceName="grp1", maxNrOfMembers=4, memberIDs=memberList, consistencyStrategy=3) try: print my_group.memberIDs #onem2m_request = OneM2MRequest("create", to="onem2m", ty=AE, pc=my_app) onem2m_request = OneM2MRequest("create", to="onem2m", ty=Group, pc=my_group) #onem2m_request = OneM2MRequest("create", to="onem2m", ty=Group, pc=my_group2) #onem2m_request = OneM2MRequest("retrieve", to="onem2m/group-EhiWIDf6h4CpsUTv") #onem2m/group-sTJ25bw8fyGNLkoY #onem2m_request = OneM2MRequest("update", to="onem2m/MYAPP2", ty=AE, pc=tmp_app) promise = client.send_onem2m_request(onem2m_request) onem2m_response = promise.get() print onem2m_response.content ''' onem2m_request = OneM2MRequest("retrieve", to="onem2m") onem2m_request = OneM2MRequest("create", to="onem2m", ty=AE, pc=my_app) onem2m_request3 = OneM2MRequest("create", to="onem2m", ty=Group, pc=my_group) ''' except OneM2MErrorResponse as e: print "CSE reported an error:", e raise except OpenMTCError as e: print "Failed to reach the CSE:", e raise else: pass # no exception was raised, the method returned normally. print onem2m_response #>>> onem2m print onem2m_response.response_status_code #>>> STATUS(numeric_code=2000, description='OK', http_status_code=200) print onem2m_response.content #>>> CSEBase(path='None', id='cb0') '''
def get_cse(cse): cse_req = OneM2MRequest(OneM2MOperation.retrieve, cse, None, MetaInformation(None)) return (self.api.handle_onem2m_request(cse_req) .then(lambda r: r.resource))
def send_create_annc(cse_uri, local_ar=None): annc = annc_model() # endpoint = self.api.get_endpoint('mid', urlparse(cse_uri).scheme) endpoint = self.config.get('endpoint', '') # * labels from the original resource; annc.labels = resource.labels # * accessRightID from the original resource; if local_ar: annc.accessRightID = urljoin(endpoint, urlparse( resource.accessRightID).path) elif local_ar is None: annc.accessRightID = local_ar else: annc.accessRightID = resource.accessRightID # * link is set to the URI of the original resource; annc.link = urljoin(endpoint, resource.path) # annc.link = self._cse_base + resource.path # * requestingEntity is set to the application; # req_ent from from outer scope # * issuer is set to its own CSE ID (the local CSE performing the # action); # rst: not needed probably # * id of the resource shall be set to the id of the original # resource postfixed with Annc. I.e. if the original resource has id # "myApp", the announced resource shall have the id "myAppAnnc"; annc.AE_ID = annc_id annc.name = annc_id # * expirationTime handling is to the discretion of the CSE # implementation. It is the responsibility of the local CSE to keep # the announced resource in sync with the lifetime of the original # resource, as long as the announcement is active. One strategy to # minimize signalling would be to request the same expiration from # the original resource. If this is accepted by the remote CSE, then # no explicit de-announce is needed in case of expiration of the # original resource; annc.expirationTime = resource.expirationTime # * targetID is set as follow. # RODO: inline def get_target_id(): cse_path = cse_uri # + '/cses/' + self.config['global']['cse_id'] apps_path = self._cse_base # + '/applications/' if resource.typename == 'AE': # 'application': # is appAnnc return cse_path # + '/applications/' else: # TODO_oneM2M: Translate to onem2m parent = sub(r'^locationC', 'c', resource.typename) + 's/' if resource.path.find(apps_path) == 0: # is under appAnnc # todo: lookup appAnnc in self._announcements return cse_path + '/applications/' + \ sub(apps_path, '', resource.path).split('/')[0] + \ 'Annc/' + parent else: # is other Annc return cse_path + '/' + parent target_id = get_target_id() # try: # req_ent_mid = urljoin(endpoint, urlparse(req_ent).path) # except AttributeError: # self.logger.exception("Could not midify") # req_ent_mid = None req_ent_mid = None # create_annc_req_ind =\ # CreateRequestIndication(target_id, annc, # requestingEntity=req_ent_mid) # # return self.api.send_request_indication(create_annc_req_ind) cse_req = OneM2MRequest(OneM2MOperation.create, target_id, req_ent_mid, MetaInformation(None), cn=annc, ty=annc_id) self.logger.debug('Sending Announcement %s' % cse_req) return self.api.send_onem2m_request(cse_req)
def _delete_remote_cse_base(): to = remote_cse_id + '/' + remote_cse_base + self.cse_id request = OneM2MRequest(OneM2MOperation.delete, to, self.originator) return self.api.send_onem2m_request(request)
# Example 6a: Notify OneM2MRequest from openmtc_onem2m.transport import OneM2MRequest from openmtc_onem2m.model import AE my_app = AE(App_ID="myApp") request = OneM2MRequest("notify", to="onem2m", pc=my_app) print request.to #>>> onem2m print request.pc.App_ID #>>> myApp
# Example 4: Delete OneM2MRequest from openmtc_onem2m.transport import OneM2MRequest request = OneM2MRequest("delete", to="onem2m") print(request.to) #>>> onem2m
def _on_register(self): print "setting up http client" client = OneM2MHTTPClient("http://eds-base:8000", False) print "testing reachability of gateway" request = OneM2MRequest("retrieve", to="onem2m") promise = client.send_onem2m_request(request) response = promise.get() if response.response_status_code.http_status_code == 200: print "onem2m gateway found" else: print "onem2m gateway not found" exit -1 print "testing reachability of EDSOrch" request = OneM2MRequest("retrieve", to="onem2m/EDSOrch") promise = client.send_onem2m_request(request) response = promise.get() if response.response_status_code.http_status_code == 200: print "EDSOrch found" else: print "EDSOrch not found" exit -1 print "testing reachability of SuT" request = OneM2MRequest("retrieve", to="onem2m/EDSOrch/testapplication") promise = client.send_onem2m_request(request) response = promise.get() if response.response_status_code.http_status_code == 200: print "SuT found" else: print "SuT not found" exit -1 print "testing reachability of sensors in SuT" request = OneM2MRequest("retrieve", to="onem2m/EDSOrch/testapplication/sensors") promise = client.send_onem2m_request(request) response = promise.get() if response.response_status_code.http_status_code == 200: print "SuT sensors found" else: print "SuT sensors not found" exit -1 print "testing reachability actuators in SuT" request = OneM2MRequest("retrieve", to="onem2m") promise = client.send_onem2m_request(request) response = promise.get() if response.response_status_code.http_status_code == 200: print "SuT actuators found" else: print "SuT actuators not found" exit -1 gevent.sleep(0) gevent.spawn_later(10, self.app_shutdown)
def map_http_request_to_onem2m_request(self, http_request): """Maps a HTTP request to a OneM2M request. :param http_request: the HTTP Request object to be mapped :returns: OneM2MRequest -- the resulting OneM2M request object :raises: OpenMTCError """ self.logger.debug("Mapping HTTP request '%s' to OneM2M request", http_request) op = _method_map_from_http[http_request.method] to = http_request.path[1:].lstrip('/') if to.startswith('~/'): to = to[1:] elif to.startswith('_/'): to = '/' + to[1:] get_header = http_request.headers.get # The X-M2M-Origin header shall be mapped to the From parameter of # request and response primitives and vice versa, if applicable. fr = get_header("x-m2m-origin") # The X-M2M-RI header shall be mapped to the Request Identifier # parameter of request and response primitives and vice versa. rqi = get_header("x-m2m-ri") # primitive content pc = decode_onem2m_content(http_request.input_stream.read(), http_request.content_type) # resource type # get out of content-type or from resource ty = type(pc) if pc else None if ty is Notification: op = OneM2MOperation.notify # The X-M2M-GID header shall be mapped to the Group Request Identifier # parameter of request primitives and vice versa, if applicable. gid = get_header("x-m2m-gid") # The X-M2M-RTU header shall be mapped to the notificationURI element of # the Response Type parameter of request primitives and vice versa, if # applicable. If there are more than one value in the element, then the # values shall be combined with "&" character. rt = get_header("x-m2m-rtu") # The X-M2M-OT header shall be mapped to the Originating Timestamp # parameter of request and response primitives, and vice versa, if # applicable. ot = get_header("x-m2m-ot") # The X-M2M-RST header shall be mapped to the Result Expiration # Timestamp parameter of request and response primitives, and vice # versa, if applicable. rset = get_header("x-m2m-rst") # The X-M2M-RET header shall be mapped to the Request Expiration # Timestamp parameter of request primitives and vice versa, if # applicable. rqet = get_header("x-m2m-ret") # The X-M2M-OET header shall be mapped to the Operation Execution Time # parameter of request primitives and vice versa, if applicable oet = get_header("x-m2m-oet") # The X-M2M-EC header shall be mapped to the Event Category parameter of # request and response primitives, and vice versa, if applicable. ec = get_header("x-m2m-ec") onem2m_request = OneM2MRequest(op=op, to=to, fr=fr, rqi=rqi, ty=ty, pc=pc, ot=ot, rqet=rqet, rset=rset, oet=oet, rt=rt, ec=ec, gid=gid) not_filter_params = ('rt', 'rp', 'rcn', 'da', 'drt') multiple_params = ('lbl', 'ty', 'cty', 'atr') if http_request.query_string: from openmtc_cse.methoddomain.filtercriteria import filters params = urlparse.parse_qs(http_request.query_string) get_param = params.get f_c = {} for param in params: self.logger.debug("checking '%s'", param) values = get_param(param) if param not in multiple_params and len(values) > 1: raise CSEBadRequest("Multiple field names not permitted " "for parameter %s" % param) param_long_name = get_long_member_name(param) # TODO(rst): handle attributes with get_long_attribute_name if param in not_filter_params: setattr(onem2m_request, param, values[0]) elif param_long_name == 'attributeList': onem2m_request.pc = AttributeList( map(get_long_attribute_name, values[0].split(' '))) elif param_long_name and hasattr(filters, param_long_name): self.logger.debug("got values for '%s' ('%s'): %s", param_long_name, param, values) if param in multiple_params: f_c[param_long_name] = values else: f_c[param_long_name] = values[0] else: raise CSEBadRequest("Unknown parameter: %s" % param) onem2m_request.filter_criteria = parse_filter_criteria(f_c) return onem2m_request
# Example 12b: Forwarding from openmtc_onem2m.client.http import OneM2MHTTPClient from openmtc_onem2m.transport import OneM2MRequest client = OneM2MHTTPClient("http://localhost:8000", False) onem2m_request = OneM2MRequest("retrieve", to="onem2m") onem2m_response = client.send_onem2m_request(onem2m_request).get() print("---> Request to: http://localhost:8000" + "/" + onem2m_request.to) print(onem2m_response.to) #>>> onem2m print(onem2m_response.response_status_code) #>>> STATUS(numeric_code=2000, description='OK', http_status_code=200) print(onem2m_response.content) #>>> CSEBase(path='None', id='cb0') onem2m_request = OneM2MRequest("retrieve", to="~/mn-cse-1/onem2m") onem2m_response = client.send_onem2m_request(onem2m_request).get() print("---> Request to: http://localhost:8000" + "/" + onem2m_request.to) print(onem2m_response.to) #>>> ~/mn-cse-1/onem2m print(onem2m_response.response_status_code) #>>> STATUS(numeric_code=2000, description='OK', http_status_code=200) print(onem2m_response.content) #>>> CSEBase(path='None', id='cb0') client.port = 18000 onem2m_request = OneM2MRequest("retrieve", to="~/mn-cse-1/onem2m") onem2m_response = client.send_onem2m_request(onem2m_request).get() print("---> Request to: http://localhost:18000" + "/" + onem2m_request.to)
# Example 11b: Updating a resource using OneM2MRequest Update 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="MYAPP2", requestReachability=False) # Create the AE 'my_app' at the CSE 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.content.labels #>>> [u'keyword1', u'keyword2'] # Retrieve the AE from the CSE and check the labels path = "onem2m/" + onem2m_response.content.resourceName onem2m_request = OneM2MRequest("retrieve", to=path) promise = client.send_onem2m_request(onem2m_request) onem2m_response = promise.get() print onem2m_response.content.labels #>>> [u'keyword1', u'keyword2'] # Update the changes labels in the remote resource # Therefore a temporay AE object is needed # This temporary AE object should ONLY contian the fields that need to be updated