def _delete_property(evrythng_id, evrythng_type, property_name, timestamp_from=None, timestamp_to=None, **request_kwargs): """Helper for deleting properties.""" assertions.datatype_str('property_name', property_name) query_params = {} if timestamp_from: assertions.datatype_time('timestamp', timestamp_from) query_params['from'] = timestamp_from if timestamp_to: assertions.datatype_time('timestamp', timestamp_to) query_params['to'] = timestamp_to url = '/{}/{}/properties/{}'.format(evrythng_type, evrythng_id, property_name) return utils.request('DELETE', url, query_params=query_params, **request_kwargs)
def _read_property(evrythng_id, evrythng_type, property_name, timestamp_to=None, timestamp_from=None, **request_kwargs): """Helper for reading properties.""" assertions.datatype_str('property_name', property_name) url = '/{}/{}/properties/{}'.format(evrythng_type, evrythng_id, property_name) query_params = request_kwargs.get('query_params', {}) if timestamp_from: assertions.datatype_time('timestamp', timestamp_from) query_params['from'] = timestamp_from if timestamp_to: assertions.datatype_time('timestamp', timestamp_to) query_params['to'] = timestamp_to request_kwargs.update(query_params=query_params) return utils.request('GET', url, **request_kwargs)
def _delete_property(evrythng_id, evrythng_type, property_name, timestamp_from=None, timestamp_to=None, api_key=None): assertions.datatype_str('product_id', property_name) if timestamp_from: assertions.datatype_time('timestamp', timestamp_from) if timestamp_to: assertions.datatype_time('timestamp', timestamp_to) url = '/{}/{}/properties/{}'.format(evrythng_type, evrythng_id, property_name) if timestamp_from and timestamp_to: url += '?from={}&to={}'.format(timestamp_from, timestamp_to) elif timestamp_from: url += '?from={}'.format(timestamp_from) elif timestamp_to: url += '?to={}'.format(timestamp_to) return utils.request('DELETE', url, api_key=api_key)