-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_tenant.py
More file actions
44 lines (23 loc) · 888 Bytes
/
create_tenant.py
File metadata and controls
44 lines (23 loc) · 888 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from sgwsapi import *
import json
import os
import getpass
# SSO username and password with admin rights
api_url = ''
api_user = os.getenv('USER')
api_passwd= ""
api_passwd = getpass.getpass(api_user+" Enter your password:")
#Get auth token:
resp = get_auth_token(api_user,api_passwd)
if resp.status_code != 200:
raise Exception('POST /authorize/ {}'.format(resp.status_code) + " Error: "+resp.json()["message"]["text"] )
print('Auth Token {}'.format(resp.json()["data"]))
auth_token=resp.json()["data"]
response = get_tenants_accounts(auth_token)
#Let's create a new test tenant.
respo= create_new_tenant(auth_token,'Mariano_test3',100000000,'qwerty123456')
if respo.status_code == 201:
print (json.dumps(respo.json(), indent=1))
else:
print (json.dumps(respo.json(), indent=1))
raise Exception('POST /create new tenant {}'.format(respo.status_code))