-
Notifications
You must be signed in to change notification settings - Fork 8
/
tenants.py
57 lines (42 loc) · 1.87 KB
/
tenants.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
from app.models.tenants import CreateTenantRequest, CreateTenantResponse
from app.routes.admin.tenants import router
from app.util.string import random_string
from shared import RichAsyncClient
TENANT_BASE_PATH = router.prefix
def append_random_string(name):
return f"{name}_{random_string(5)}"
async def post_tenant_request(
admin_client: RichAsyncClient, request: CreateTenantRequest
) -> CreateTenantResponse:
response = await admin_client.post(TENANT_BASE_PATH, json=request.model_dump())
return CreateTenantResponse.model_validate_json(response.text)
async def create_issuer_tenant(admin_client: RichAsyncClient, name: str):
request = CreateTenantRequest(
wallet_label=append_random_string(name),
roles=["issuer"],
group_id="IssuerGroup",
)
return await post_tenant_request(admin_client, request)
async def create_verifier_tenant(admin_client: RichAsyncClient, name: str):
request = CreateTenantRequest(
wallet_label=append_random_string(name),
roles=["verifier"],
group_id="VerifierGroup",
)
return await post_tenant_request(admin_client, request)
async def create_issuer_and_verifier_tenant(admin_client: RichAsyncClient, name: str):
request = CreateTenantRequest(
wallet_label=append_random_string(name),
roles=["issuer", "verifier"],
group_id="IssuerAndVerifierGroup",
)
return await post_tenant_request(admin_client, request)
async def create_tenant(admin_client: RichAsyncClient, name: str):
request = CreateTenantRequest(
image_url="https://aries.ca/images/sample.png",
wallet_label=append_random_string(name),
group_id="TenantGroup",
)
return await post_tenant_request(admin_client, request)
async def delete_tenant(admin_client: RichAsyncClient, wallet_id: str):
await admin_client.delete(f"{TENANT_BASE_PATH}/{wallet_id}")