Skip to content

Commit

Permalink
SL-xx: Scope Tenants and Servers requests (#958)
Browse files Browse the repository at this point in the history
Co-authored-by: scouillard <couillard.samuel@gmail.com>
  • Loading branch information
scouillard and scouillard authored Jun 1, 2023
1 parent 2875833 commit 9db0ed8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
12 changes: 8 additions & 4 deletions app/controllers/api/tenants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def get_tenant_info
#
# Expected params:
# {
# "name": String, # Required: Name of the tenant
# "secrets": String, # Required: Tenant secret(s)
# "tenant": {
# "name": String, # Required: Name of the tenant
# "secrets": String, # Required: Tenant secret(s)
# }
# }
def add_tenant
if tenant_params[:name].blank? || tenant_params[:secrets].blank?
Expand All @@ -80,8 +82,10 @@ def add_tenant
# Expected params:
# {
# "id": String # Required
# "name": String, # include the parameter you want updated
# "secrets": String
# "tenant": {
# "name": String, # include the parameter you want updated
# "secrets": String
# }
# }
def update_tenant
@tenant.name = tenant_params[:name] if tenant_params[:name].present?
Expand Down
22 changes: 13 additions & 9 deletions docs/api-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ status: ok
#### Example cURL
```bash
curl --header "Content-Type: application/json" --request POST --data '{"url": "https://server1.com/bigbluebutton/api", "secret":"example-secret" }' 'https://scalelite-hostname.com/scalelite/api/addServer?checksum=<checksum>' -v
curl --header "Content-Type: application/json" --request POST --data '{"server": {"url": "https://server1.com/bigbluebutton/api", "secret":"example-secret" } }' 'https://scalelite-hostname.com/scalelite/api/addServer?checksum=<checksum>' -v
```

### Update Server
Expand Down Expand Up @@ -144,7 +144,7 @@ status: ok
#### Example cURL

```bash
curl --header "Content-Type: application/json" --request POST --data '{"id": "<server-id>", "secret":"new-secret" }' 'https://scalelite-hostname.com/scalelite/api/updateServer?checksum=<checksum>' -v
curl --header "Content-Type: application/json" --request POST --data '{"id": "<server-id>", "server": {"secret":"new-secret"} }' 'https://scalelite-hostname.com/scalelite/api/updateServer?checksum=<checksum>' -v
```

### Delete Server
Expand Down Expand Up @@ -279,8 +279,10 @@ POST /scalelite/api/addTenant

```
{
"name": String, # Required: Name of the tenant
"secrets": String, # Required: Tenant secret(s)
"tenant": {
"name": String, # Required: Name of the tenant
"secrets": String, # Required: Tenant secret(s)
}
}
```
#### Successful Response
Expand All @@ -294,7 +296,7 @@ status: created
#### Example cURL
```bash
curl --header "Content-Type: application/json" --request POST --data '{"name": "example-tenant", "secrets":"example-secret" }' 'https://scalelite-hostname.com/scalelite/api/addTenant?id=<tenant-id>&checksum=<checksum>' -v
curl --header "Content-Type: application/json" --request POST --data '{"tenant": {"name": "example-tenant", "secrets":"example-secret" } }' 'https://scalelite-hostname.com/scalelite/api/addTenant?id=<tenant-id>&checksum=<checksum>' -v
```

If you need to add multiple secrets for a tenant, you can provide a colon-separated (`:`) list of secrets when creating the tenant in Scalelite.
Expand All @@ -309,8 +311,10 @@ POST /scalelite/api/updateTenant

```
{
"name": String, # include the parameter you want updated
"secrets": String
"tenant": {
"name": String, # include the parameter you want updated
"secrets": String
}
}
```

Expand All @@ -330,7 +334,7 @@ status: ok
#### Example cURL

```bash
curl --header "Content-Type: application/json" --request POST --data '{"id":"<tenant-id>", "secrets":"new-secret" }' 'https://scalelite-hostname.com/scalelite/api/updateTenant?id=<tenant-id>&checksum=<checksum>'-v
curl --header "Content-Type: application/json" --request POST --data '{"id":"<tenant-id>", "tenant": {"secrets":"new-secret" } }' 'https://scalelite-hostname.com/scalelite/api/updateTenant?id=<tenant-id>&checksum=<checksum>'-v
```

### Remove Tenant
Expand All @@ -356,4 +360,4 @@ status: ok
curl --header "Content-Type: application/json" --request POST --data '{"id":"<tenant-id>"}' 'https://scalelite-hostname.com/scalelite/api/deleteTenant?id=<tenant-id>&checksum=<checksum>'
```

Warning: Removing a tenant with data still in the database may cause some inconsistencies.
Warning: Removing a tenant with data still in the database may cause some inconsistencies.

0 comments on commit 9db0ed8

Please sign in to comment.