Search in sources :

Example 6 with TenantManagerServiceException

use of org.bf2.srs.fleetmanager.spi.tenants.TenantManagerServiceException in project srs-fleet-manager by bf2fc6cc711aee1a0c2a.

the class RestClientTenantManagerServiceImpl method createTenant.

@Timed(value = Constants.TENANT_MANAGER_CREATE_TENANT_TIMER, description = Constants.TENANT_MANAGER_DESCRIPTION)
@Audited
// 3 retries, 200ms jitter
@Retry(retryOn = { TenantManagerServiceException.class })
@Override
public Tenant createTenant(TenantManagerConfig tm, CreateTenantRequest tenantRequest) throws TenantManagerServiceException {
    try {
        var client = getClient(tm);
        NewRegistryTenantRequest req = new NewRegistryTenantRequest();
        req.setOrganizationId(tenantRequest.getOrganizationId());
        req.setTenantId(tenantRequest.getTenantId());
        req.setCreatedBy(tenantRequest.getCreatedBy());
        req.setResources(Optional.ofNullable(tenantRequest.getResources()).stream().flatMap(Collection::stream).map(r -> {
            TenantResource tr = new TenantResource();
            tr.setType(ResourceType.fromValue(r.getType()));
            tr.setLimit(r.getLimit());
            return tr;
        }).collect(Collectors.toList()));
        RegistryTenant tenant = client.createTenant(req);
        return convert(tenant);
    } catch (TenantManagerClientException ex) {
        throw ExceptionConvert.convert(ex);
    }
}
Also used : TenantResource(io.apicurio.multitenant.api.datamodel.TenantResource) RegistryTenant(io.apicurio.multitenant.api.datamodel.RegistryTenant) TenantManagerClientException(io.apicurio.multitenant.client.exception.TenantManagerClientException) NewRegistryTenantRequest(io.apicurio.multitenant.api.datamodel.NewRegistryTenantRequest) Audited(org.bf2.srs.fleetmanager.common.operation.auditing.Audited) Timed(io.micrometer.core.annotation.Timed) Retry(org.eclipse.microprofile.faulttolerance.Retry)

Aggregations

TenantNotFoundServiceException (org.bf2.srs.fleetmanager.spi.tenants.TenantNotFoundServiceException)4 Transactional (javax.transaction.Transactional)3 TenantManagerConfig (org.bf2.srs.fleetmanager.spi.tenants.model.TenantManagerConfig)3 RegistryData (org.bf2.srs.fleetmanager.storage.sqlPanacheImpl.model.RegistryData)3 RegistryDeploymentData (org.bf2.srs.fleetmanager.storage.sqlPanacheImpl.model.RegistryDeploymentData)3 ProvisionRegistryTenantTask (org.bf2.srs.fleetmanager.execution.impl.tasks.ProvisionRegistryTenantTask)2 NewRegistryTenantRequest (io.apicurio.multitenant.api.datamodel.NewRegistryTenantRequest)1 RegistryTenant (io.apicurio.multitenant.api.datamodel.RegistryTenant)1 TenantResource (io.apicurio.multitenant.api.datamodel.TenantResource)1 TenantManagerClientException (io.apicurio.multitenant.client.exception.TenantManagerClientException)1 Timed (io.micrometer.core.annotation.Timed)1 HashMap (java.util.HashMap)1 NoSuchElementException (java.util.NoSuchElementException)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Audited (org.bf2.srs.fleetmanager.common.operation.auditing.Audited)1 DeprovisionRegistryTask (org.bf2.srs.fleetmanager.execution.impl.tasks.deprovision.DeprovisionRegistryTask)1 SubscriptionNotFoundServiceException (org.bf2.srs.fleetmanager.spi.ams.SubscriptionNotFoundServiceException)1 TenantManagerServiceException (org.bf2.srs.fleetmanager.spi.tenants.TenantManagerServiceException)1 CreateTenantRequest (org.bf2.srs.fleetmanager.spi.tenants.model.CreateTenantRequest)1 Tenant (org.bf2.srs.fleetmanager.spi.tenants.model.Tenant)1