use of com.sequenceiq.cloudbreak.cloud.model.resourcegroup.CloudResourceGroups in project cloudbreak by hortonworks.
the class EnvironmentPlatformResourceController method getResourceGroups.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformResourceGroupsResponse getResourceGroups(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone) {
String accountId = getAccountId();
validateEnvironmentCrnPattern(environmentCrn);
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null);
LOGGER.info("Get /platform_resources/resource_groups, request: {}", request);
CloudResourceGroups resourceGroups = platformParameterService.getResourceGroups(request);
List<PlatformResourceGroupResponse> platformResourceGroups = resourceGroups.getResourceGroups().stream().map(rg -> new PlatformResourceGroupResponse(rg.getName())).collect(Collectors.toList());
PlatformResourceGroupsResponse response = new PlatformResourceGroupsResponse(platformResourceGroups);
LOGGER.info("Resp /platform_resources/resource_groups, request: {}, resourceGroups: {}, response: {}", request, resourceGroups, response);
return response;
}
use of com.sequenceiq.cloudbreak.cloud.model.resourcegroup.CloudResourceGroups in project cloudbreak by hortonworks.
the class CredentialPlatformResourceController method getResourceGroups.
@Override
@CustomPermissionCheck
public PlatformResourceGroupsResponse getResourceGroups(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone) {
customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
String accountId = getAccountId();
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone, CdpResourceType.DEFAULT);
LOGGER.info("Get /platform_resources/resource_groups, request: {}", request);
CloudResourceGroups resourceGroups = platformParameterService.getResourceGroups(request);
List<PlatformResourceGroupResponse> platformResourceGroups = resourceGroups.getResourceGroups().stream().map(rg -> new PlatformResourceGroupResponse(rg.getName())).collect(Collectors.toList());
PlatformResourceGroupsResponse response = new PlatformResourceGroupsResponse(platformResourceGroups);
LOGGER.info("Resp /platform_resources/resource_groups, request: {}, resourceGroups: {}, response: {}", request, resourceGroups, response);
return response;
}
use of com.sequenceiq.cloudbreak.cloud.model.resourcegroup.CloudResourceGroups in project cloudbreak by hortonworks.
the class GetPlatformResourceGroupsHandler method accept.
@Override
public void accept(Event<GetPlatformResourceGroupsRequest> event) {
LOGGER.debug("Received event: {}", event);
GetPlatformResourceGroupsRequest request = event.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudResourceGroups resourceGroups = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().resourceGroups(request.getExtendedCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformResourceGroupsResult result = new GetPlatformResourceGroupsResult(request.getResourceId(), resourceGroups);
request.getResult().onNext(result);
LOGGER.debug("Query platform Resource groups finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new GetPlatformResourceGroupsResult(e.getMessage(), e, request.getResourceId()));
}
}
Aggregations