-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsampleqry.py
More file actions
executable file
·40 lines (30 loc) · 1.1 KB
/
sampleqry.py
File metadata and controls
executable file
·40 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import sys, json, requests, datetime, time, os, logging, yaml
import pprint
from pycppm import auth
import pycppm.session as session
import pycppm.endpoints as endpoints
with open("config.yml", 'r') as ymlfile:
cfg = yaml.load(ymlfile)
grant_type = cfg['grant_type']
cppmip = cfg['cppmip']
username = cfg['username']
password = cfg['password']
client_id = cfg['client_id']
client_secret = cfg['client_secret']
login=0
if login == 1:
tempauth = auth.CPPMAuth(cppmip, username, password, client_id, client_secret)
#print(tempauth.access_token)
tempsession = {}
tempsession['access_token'] = tempauth.access_token
tempsession['expires_in'] = tempauth.expires_in
tempsession['refresh_token'] = tempauth.refresh_token
with open("cppmtoken.json", "w") as f:
json.dump(tempsession, f)
with open("cppmtoken.json") as tokenfile:
token = json.load(tokenfile)
#print("access_token", token['access_token'])
#print(json.dumps(session.get_session))
# print(json.dumps((session.get_session(token))))
print(json.dumps((endpoints.get_insight_endpoints(token))))