-
Notifications
You must be signed in to change notification settings - Fork 1
/
trino_api.py
19 lines (15 loc) · 989 Bytes
/
trino_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import requests
def new_session(trino_user, trino_password):
session = requests.Session()
if trino_password:
session.auth = (trino_user, trino_password)
return session
def current_queries(session, verify_certs, coordinator_uri, trino_user):
queries_url = coordinator_uri + '/v1/queryState'
return session.get(queries_url, verify=verify_certs, headers = {'X-Trino-User' : trino_user}).json()
def get_query_json(session, verify_certs, coordinator_uri, trino_user, query_id):
query_json_url = coordinator_uri + '/v1/query/' + query_id
return session.get(query_json_url, verify=verify_certs, headers = {'X-Trino-User' : trino_user}).json()
def get_resource_group_state(session, verify_certs, coordinator_uri, trino_user, resource_group_id):
resource_group_state_url = coordinator_uri + '/v1/resourceGroupState/' + resource_group_id
return session.get(resource_group_state_url, verify=verify_certs, headers = {'X-Trino-User' : trino_user}).json()