-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathme.py
61 lines (49 loc) · 1.55 KB
/
me.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import configparser
import os
from obtentoken import *
from snapshots import *
config = configparser.ConfigParser()
a = config.read("config.ini")
#for i in os.environ:
# print (i,os.environ[i])
if "APPID" in os.environ:
APP_ID = os.environ['APPID']
print ("APP_ID:Ok")
if "SECRET" in os.environ:
SECRET = os.environ['SECRET']
print("SECRET:Ok" )
CUSTOMER_ID = config.get("AMX", "CUSTOMER_ID")
LOCATION = config.get("AMX", "LOCATION")
TOKEN = config.get("AMX", "TOKEN")
#URL = config.get("LOCATIONS", "URL")
URL = config.get("AMX", "URL")
#URL3 = config.get("LOCATIONS", "URL3")
#token = get_token(APP_ID, SECRET, IYO_URL)
jH = get_headers_js(TOKEN)
oH = get_headers_os(TOKEN)
#print(snapshotcloudspaces(jH,URL))
print (jH)
def get_me(headers, URL):
data = {}
api_get = 'api/1/me'
cloudspace = requests.get(URL + api_get, headers=headers)
return (cloudspace)
def get_locations(headers, URL):
data = {}
api_get = 'api/1/locations'
cloudspace = requests.get(URL + api_get, headers=headers)
return (cloudspace)
def get_customers(headers, URL):
data = {}
api_get = 'api/1/customers'
cloudspace = requests.get(URL + api_get, headers=headers)
return (cloudspace)
def get_customers_cloudspaces(headers, URL,customer_id):
data = {
'include_deleted': True,
'location':""
}
api_get = 'api/1/customers/%s/cloudspaces'%(customer_id)
cloudspace = requests.get(URL + api_get, headers=headers,params=data)
return (cloudspace)
print(get_customers_cloudspaces(jH,URL,CUSTOMER_ID).text)