def range(href, dataSourceID, startTimestamp, endTimestamp): if endTimestamp: href += '/' + dataSourceID else: endTimestamp = startTimestamp startTimestamp = dataSourceID utils.makeStoreRequest(method='GET', jsonData={startTimestamp,endTimestamp}, url=href + '/ts/range')
def registerDatasource(href, metadata): rurl = urllib3.util.parse_url(href) newurl = rurl.scheme + ':' + '//' + rurl.host + ':' + str(rurl.port) metadata = json.loads(metadata) cat = { "item-metadata": [{ "rel": "urn:X-hypercat:rels:hasDescription:en", "val": metadata['description'] }, { "rel": "urn:X-hypercat:rels:isContentType", "val": metadata['contentType'] }, { "rel": "urn:X-databox:rels:hasVendor", "val": metadata['vendor'] }, { "rel": "urn:X-databox:rels:hasType", "val": metadata['type'] }, { "rel": "urn:X-databox:rels:hasDatasourceid", "val": metadata['datasourceid'] }, { "rel": "urn:X-databox:rels:hasStoreType", "val": metadata['storeType'] }], "href": newurl+ '/' + metadata['datasourceid'] } return utils.makeStoreRequest(method='POST', jsonData=cat, url=newurl+'/cat')
def write(href, key, data): print("write called") if (data): newurl = href + '/' + key + '/kv' else: newurl = href data = key return utils.makeStoreRequest(method='POST', jsonData=data, url=newurl)
def write(href, dataSourceID, data): if data: href += '/' + dataSourceID else: data = dataSourceID return utils.makeStoreRequest(method='POST', jsonData={'data': data}, url=href + '/ts')
def since(href, dataSourceID, startTimestamp): if startTimestamp: href += '/' + dataSourceID else: startTimestamp = dataSourceID return utils.makeStoreRequest(method='GET', jsonData={"startTimestamp": startTimestamp}, url=href + '/ts/since')
def longpoll(destination, payload): newurl = exportServiceURL + '/lp/export' return utils.makeStoreRequest(method='POST', jsonData={ 'id': '', 'uri': destination, 'data': json.dump(payload) }, url=newurl)
def unsubscribe(href, dataSourceID, type): if (type1 is None or not type1): type1 = dataSourceID dURL = urllib3.util.parse_url(href) href = dURL.scheme + ':' + '//' + dURL.host dataSourceID = dURL.path.replace('/', '') return utils.makeStoreRequest(method='GET', jsonData={'True': True}, url=href + '/sub/' + dataSourceID + '/' + type1)
def read(href, key): print("read called") newurl = href + '/' + key + '/kv' return utils.makeStoreRequest(method='GET', jsonData={'True': True}, url=newurl)
def latest(href, dataSourceID): href += '/' + dataSourceID return utils.makeStoreRequest(method='GET',jsonData={"True":True}, url= href +'/ts/latest')
def getStoreCatalog(href): rurl = urllib3.util.parse_url(href) newurl = rurl.scheme + ':' + '//' + rurl.host + ':' + str(rurl.port) + '/cat' return utils.makeStoreRequest(method = 'GET', jsonData={'True': True}, url=newurl)