use of org.bf2.srs.fleetmanager.spi.ams.impl.model.response.QuotaCostList in project srs-fleet-manager by bf2fc6cc711aee1a0c2a.
the class AccountManagementServiceImpl method determineAllowedResourceType.
@Timed(value = Constants.AMS_DETERMINE_ALLOWED_INSTANCE_TIMER, description = Constants.AMS_TIMER_DESCRIPTION)
@Audited
@Timeout(FaultToleranceConstants.TIMEOUT_MS)
@RetryUnwrap
// 3 retries, 200ms jitter
@Retry(retryOn = { RetryWrapperException.class })
@RetryWrap
@Override
public ResourceType determineAllowedResourceType(AccountInfo accountInfo) throws AccountManagementServiceException {
try {
Organization organization = restClient.getOrganizationByExternalId(accountInfo.getOrganizationId());
String orgId = organization.getId();
// Check QuotaCostList for a RHOSR entry with "allowed" quota > 0. If found, then
// return "Standard" as the resource type to create.
QuotaCostList quotaCostList = restClient.getQuotaCostList(orgId, true);
if (quotaCostList.getSize() > 0) {
for (QuotaCost quotaCost : quotaCostList.getItems()) {
// We only care about QuotaCost with "allowed" > 0 and with at least one related resource.
if (quotaCost.getAllowed() != null && quotaCost.getAllowed() > 0 && quotaCost.getRelated_resources() != null && !quotaCost.getRelated_resources().isEmpty() && isRhosrStandardQuota(quotaCost)) {
return ResourceType.REGISTRY_INSTANCE_STANDARD;
}
}
}
// Default to only allow eval.
return ResourceType.REGISTRY_INSTANCE_EVAL;
} catch (AccountManagementSystemClientException ex) {
ExceptionConvert.convert(ex);
// Never returns
return null;
}
}
use of org.bf2.srs.fleetmanager.spi.ams.impl.model.response.QuotaCostList in project srs-fleet-manager by bf2fc6cc711aee1a0c2a.
the class AccountManagementSystemRestClient method getQuotaCostList.
public QuotaCostList getQuotaCostList(String orgId, boolean fetchRelatedResources) {
Map<String, List<String>> queryParams = new HashMap<>();
queryParams.put("fetchRelatedResources", Collections.singletonList(String.valueOf(fetchRelatedResources)));
QuotaCostList rval = this.client.sendRequest(new Request.RequestBuilder<QuotaCostList>().operation(Operation.GET).path(Paths.QUOTA_COST_PATH).pathParams(Collections.singletonList(orgId)).queryParams(queryParams).responseType(new TypeReference<QuotaCostList>() {
}).build());
return rval;
}
use of org.bf2.srs.fleetmanager.spi.ams.impl.model.response.QuotaCostList in project srs-fleet-manager by bf2fc6cc711aee1a0c2a.
the class AccountManagementSystemRestClientTest method getQuotaCostList.
@Test
public void getQuotaCostList() {
final QuotaCostList quotaCostList = accountManagementSystemRestClient.getQuotaCostList("1pcZDw72EPhdanw4pJEnrudOnyj", true);
Assertions.assertNotNull(quotaCostList);
Assertions.assertEquals(20, quotaCostList.getTotal());
Assertions.assertNotNull(quotaCostList.getItems());
Assertions.assertFalse(quotaCostList.getItems().isEmpty());
Assertions.assertEquals(20, quotaCostList.getItems().size());
Assertions.assertEquals("add-on|addon-cluster-logging-operator", quotaCostList.getItems().get(0).getQuota_id());
}
Aggregations