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);
}
}
Aggregations