-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrest_API_client.py
More file actions
25 lines (23 loc) · 880 Bytes
/
rest_API_client.py
File metadata and controls
25 lines (23 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests
import time
import json
service_json = {
"name": "test",
"device_id": "092b7908-69ee-46ee-b2c7-2d9ae23ee298", #optional. No device filtering applied if this value is not provided. Invalid device will return 404 error.
'sort_order': ['memory', 'cpu'], #optional, default - [cpu]
'telemetry_filter': False, #optional, default - False
"description": "test",
"project": "mf2c" #optional. Required if device_id is provided for filtering
}
headers = {'Content-type': 'application/json', 'Accept': 'text/json'}
# data=json.dumps(payload)
url = 'http://localhost:46020/mf2c/optimal'
print time.time()
res = requests.post(url, json=service_json, headers=headers)
if res.ok:
print time.time()
print 'Optimal hosts'
json_data = json.loads(res.text)
print json_data
else:
print 'Error ' + str(res.status_code) + ":" + res.content