def set_device_resource_value(self, device_id, resource_path, resource_data, headers=None, expected_status_code=None): """ Write to a Resource :param device_id: Device id :param resource_path: Resource path :param resource_data: Resource data value :param headers: Override default header fields :param expected_status_code: Asserts the result's status code :return: PUT /v2/endpoints/{device_id}/{resourcePath} response """ api_url = '/{}/endpoints/{}/{}'.format( self.api_version, device_id, remove_first_slash_from(resource_path)) # Set text/plain to be default content type for this request - content type from parameters will override this _headers = {'Content-type': 'text/plain'} if headers: _headers.update(headers) r = self.cloud_api.put(api_url, resource_data, _headers, expected_status_code) return r
def get_subscription_status(self, device_id, resource_path, headers=None, expected_status_code=None): """ Read subscription status :param device_id: Device id :param resource_path: Resource path :param headers: Override default header fields :param expected_status_code: Asserts the result's status code :return: GET /v2/subscriptions/{device_id}/{resource_path} response """ api_url = '/{}/subscriptions/{}/{}'.format( self.api_version, device_id, remove_first_slash_from(resource_path)) r = self.cloud_api.get(api_url, headers, expected_status_code) return r