Update a tenant with the Java SDK
permit.api.tenants.update() changes the fields you set on an existing tenant and leaves the other fields unchanged. A tenant is an isolated group of users and resources, such as one customer organization in a multi-tenant application. This reference is for Java developers who manage tenants from code. The examples assume an initialized Permit client named permit, as set up in Check permissions with the Java SDK.
Signature
TenantRead update(String tenantKey, TenantUpdate tenantData) throws IOException, PermitApiError, PermitContextError
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tenantKey | String | Yes | The key or the ID (UUID) of the tenant. The Permit API accepts either value. |
tenantData | TenantUpdate | Yes | The fields to change. The fields are listed in TenantUpdate fields. |
TenantUpdate fields
Create a TenantUpdate with the no-argument constructor and set only the fields you want to change. Every field is optional. TenantUpdate has no key field, so update() cannot change the tenant key.
| Field | Builder method | Type | Description |
|---|---|---|---|
name | withName() | String | A descriptive name for the tenant. |
description | withDescription() | String | A longer description of the tenant. |
attributes | withAttributes() | HashMap<String, Object> | Tenant attributes for attribute-based access control (ABAC) policies. |
Example
The example changes the description of the awesome-inc tenant.
import io.permit.sdk.openapi.models.TenantUpdate;
permit.api.tenants.update("awesome-inc", new TenantUpdate().withDescription("new description"));
Return value
update() returns a TenantRead object (io.permit.sdk.openapi.models.TenantRead) with the updated tenant.
Exceptions
All exception classes except IOException are in the io.permit.sdk.api package.
| Exception | Thrown when |
|---|---|
IOException | The HTTP request to the Permit API fails, for example because of a network error. |
PermitApiError | The Permit API returns an error status code. getResponseCode() returns the HTTP status code and getRawResponse() returns the response body. |
PermitContextError | The SDK context does not include an environment, for example because the API key is scoped to an organization or project. |