Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions pymetis/clients/charts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import requests


def get(hostname, port, did):
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = "http://" + hostname + ":" + port + "/api/widgets/" + did + "/data"
return requests.post(url, headers=headers).json()
def get(hostname, port, did, limit):
loginHeaders = {'Authorization': 'Basic cG9sYXJpc19jbGllbnQ6cG9sYXJpcw==', 'Content-Type' : 'application/x-www-form-urlencoded'}
loginData = {'grant_type':'password', 'scope':'write', 'username':'polaris', 'password':'polaris'}
loginUrl = "http://" + hostname + ":" + port + "/oauth/token"
res = requests.post(loginUrl, loginData, headers=loginHeaders).json()

# login check
#print(res)

token_type = res["token_type"]
token = res["access_token"]
auth = token_type + ' ' + token

#auth value check
#print('auth:' + auth)

headers = {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': auth}
url = "http://" + hostname + ":" + port + "/api/widgets/" + did + "/data?limit=" + limit
return requests.post(url, headers=headers).json()
23 changes: 19 additions & 4 deletions pymetis/clients/dashboards.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import requests


def get(hostname, port, did):
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = "http://" + hostname + ":" + port + "/api/dashboards/" + did + "/data"
return requests.post(url, headers=headers).json()
def get(hostname, port, did, limit):
loginHeaders = {'Authorization': 'Basic cG9sYXJpc19jbGllbnQ6cG9sYXJpcw==', 'Content-Type' : 'application/x-www-form-urlencoded'}
loginData = {'grant_type':'password', 'scope':'write', 'username':'polaris', 'password':'polaris'}
loginUrl = "http://" + hostname + ":" + port + "/oauth/token"
res = requests.post(loginUrl, loginData, headers=loginHeaders).json()

# login check
#print(res)

token_type = res["token_type"]
token = res["access_token"]
auth = token_type + ' ' + token

#auth value check
#print('auth:' + auth)

headers = {'Accept': 'application/json', 'Content-Type': 'application/json','Authorization': auth}
url = "http://" + hostname + ":" + port + "/api/dashboards/" + did + "/data?limit=" + limit
return requests.post(url, headers=headers).json()
28 changes: 24 additions & 4 deletions pymetis/clients/datasources.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
import requests


def get(hostname, port, did):
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
url = "http://" + hostname + ":" + port + "/api/datasources/" + did + "/data"
return requests.post(url, headers=headers).json()
def get(hostname, port, did, limit):

loginHeaders = {'Authorization': 'Basic cG9sYXJpc19jbGllbnQ6cG9sYXJpcw==', 'Content-Type' : 'application/x-www-form-urlencoded'}
loginData = {'grant_type':'password', 'scope':'write', 'username':'polaris', 'password':'polaris'}
loginUrl = "http://" + hostname + ":" + port + "/oauth/token"
res = requests.post(loginUrl, loginData, headers=loginHeaders).json()

# login check
#print(res)

token_type = res["token_type"]
token = res["access_token"]
auth = token_type + ' ' + token

#auth value check
#print('auth:' + auth)

headers = {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': auth}
url = "http://" + hostname + ":" + port + "/api/datasources/" + did + "/data?limit=" + limit

# url value check
#print('url:' + url)

return requests.post(url, headers=headers).json()