forked from x4nth055/pythoncode-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomate.py
35 lines (26 loc) · 1010 Bytes
/
automate.py
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
import requests
from pprint import pprint
# email and password
auth = ("[email protected]", "ffffffff")
# get the HTTP Response
res = requests.get("https://secure.veesp.com/api/details", auth=auth)
# get the account details
account_details = res.json()
pprint(account_details)
# get the bought services
services = requests.get('https://secure.veesp.com/api/service', auth=auth).json()
pprint(services)
# get the upgrade options
upgrade_options = requests.get('https://secure.veesp.com/api/service/32723/upgrade', auth=auth).json()
pprint(upgrade_options)
# list all bought VMs
all_vms = requests.get("https://secure.veesp.com/api/service/32723/vms", auth=auth).json()
pprint(all_vms)
# stop a VM automatically
stopped = requests.post("https://secure.veesp.com/api/service/32723/vms/18867/stop", auth=auth).json()
print(stopped)
# {'status': True}
# start it again
started = requests.post("https://secure.veesp.com/api/service/32723/vms/18867/start", auth=auth).json()
print(started)
# {'status': True}