Skip to main content

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

ParameterTypeRequiredDescription
tenantKeyStringYesThe key or the ID (UUID) of the tenant. The Permit API accepts either value.
tenantDataTenantUpdateYesThe 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.

FieldBuilder methodTypeDescription
namewithName()StringA descriptive name for the tenant.
descriptionwithDescription()StringA longer description of the tenant.
attributeswithAttributes()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.

ExceptionThrown when
IOExceptionThe HTTP request to the Permit API fails, for example because of a network error.
PermitApiErrorThe Permit API returns an error status code. getResponseCode() returns the HTTP status code and getRawResponse() returns the response body.
PermitContextErrorThe SDK context does not include an environment, for example because the API key is scoped to an organization or project.