def query_put_tags(classifier, classifier_id, new_value): data = json.loads(json.dumps(query_get_tags(classifier, classifier_id))) data[0]['values'].append(new_value) payload = json.dumps(data) queryURL = connection.read_cred( )['env']['PREDIX_DATA_ASSET_URI'] + "/" + classifier + "/" + classifier_id response_data = requests.put(queryURL, data=payload, headers=connection.create_asset_header()) return response_data
def query_get_timeseries_tags(): queryURL = connection.read_cred( )['env']['PREDIX_DATA_TIMESERIES_QUERY_TAGS'] response_data = requests.get(queryURL, headers=connection.create_header()) return response_data.json()
def query_get_tags(classifier, classifier_id): queryURL = connection.read_cred( )['env']['PREDIX_DATA_ASSET_URI'] + "/" + classifier + "/" + classifier_id response_data = requests.get(queryURL, headers=connection.create_asset_header()) return response_data.json()
import json import requests from flask import abort, make_response, jsonify import _connect as connection import queries as query # -------------------------- CONSTANT --------------------------------- QUERY_URL = connection.read_cred()['env']['PREDIX_DATA_TIMESERIES_QUERY_URI'] def query_getLatestValue(tag_id): response_data = requests.post( QUERY_URL + '/latest', data=bytes(json.dumps(query.createLatestValues(tag_id))), headers=connection.create_header()) print(response_data) if response_data.raise_for_status() is None: return response_data.json() abort( make_response( jsonify({ 'response': { 'message': ' Forwarding data from predix response.' } }), response_data.raise_for_status)) # Query for aggragation requests def query_agg_data(tag_id, req_agg_func, start_time, end_time):