Skip to content

Commit a126428

Browse files
committed
Add create tenant method
1 parent 0c02215 commit a126428

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

examples/example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ def make_warrant_requests(api_key):
44
client = Warrant(api_key)
55

66
# Create users and session tokens
7-
print("Created user with provided id: " + client.create_user("custom_id_001"))
7+
print("Created tenant with provided id: " + client.create_tenant("custom_tenant_001"))
8+
print("Created user with provided id: " + client.create_user("custom_user_001"))
89
new_user = client.create_user()
910
print("Created user with generated id: " + new_user)
11+
print(client.create_warrant(object_type="tenant", object_id="custom_tenant_001", relation="member", user=new_user))
1012
print("Created session token: " + client.create_session(new_user))
1113

1214
# Create and check warrants

warrant/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ def create_user(self, user_id=""):
4040
json = self._make_post_request(uri="/users", json=payload)
4141
return json['userId']
4242

43+
def create_tenant(self, tenant_id=""):
44+
if tenant_id == "":
45+
payload = {}
46+
else:
47+
payload = { "tenantId": tenant_id }
48+
json = self._make_post_request(uri="/tenants", json=payload)
49+
return json['tenantId']
50+
4351
def create_session(self, user_id):
4452
if user_id == "":
4553
raise WarrantException(msg="Invalid userId provided")

0 commit comments

Comments
 (0)