use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.
the class PlatformResourceRequestJsonToPlatformResourceRequest method convert.
@Override
public PlatformResourceRequest convert(PlatformResourceRequestJson source) {
PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest();
if (!Strings.isNullOrEmpty(source.getCredentialName())) {
platformResourceRequest.setCredential(credentialService.get(source.getCredentialName(), source.getAccount()));
} else if (source.getCredentialId() != null) {
platformResourceRequest.setCredential(credentialService.get(source.getCredentialId()));
} else {
throw new BadRequestException("The credentialId or the credentialName must be specified in the request");
}
if (!Strings.isNullOrEmpty(source.getPlatformVariant())) {
platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().cloudPlatform());
} else {
platformResourceRequest.setPlatformVariant(Strings.isNullOrEmpty(source.getPlatformVariant()) ? platformResourceRequest.getCredential().cloudPlatform() : source.getPlatformVariant());
}
platformResourceRequest.setFilters(source.getFilters());
platformResourceRequest.setRegion(source.getRegion());
platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().cloudPlatform());
if (!Strings.isNullOrEmpty(source.getAvailabilityZone())) {
platformResourceRequest.setAvailabilityZone(source.getAvailabilityZone());
}
return platformResourceRequest;
}
use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.
the class PlatformParameterV1Controller method getCloudSshKeys.
@Override
public PlatformSshKeysResponse getCloudSshKeys(PlatformResourceRequestJson resourceRequestJson) {
resourceRequestJson = prepareAccountAndOwner(resourceRequestJson, authenticatedUserService.getCbUser());
PlatformResourceRequest convert = conversionService.convert(resourceRequestJson, PlatformResourceRequest.class);
CloudSshKeys cloudSshKeys = cloudParameterService.getCloudSshKeys(convert.getCredential(), convert.getRegion(), convert.getPlatformVariant(), convert.getFilters());
return conversionService.convert(cloudSshKeys, PlatformSshKeysResponse.class);
}
use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.
the class PlatformParameterV1Controller method getGatewaysCredentialId.
@Override
public PlatformGatewaysResponse getGatewaysCredentialId(PlatformResourceRequestJson resourceRequestJson) {
resourceRequestJson = prepareAccountAndOwner(resourceRequestJson, authenticatedUserService.getCbUser());
PlatformResourceRequest convert = conversionService.convert(resourceRequestJson, PlatformResourceRequest.class);
CloudGateWays cloudGateWays = cloudParameterService.getGateways(convert.getCredential(), convert.getRegion(), convert.getPlatformVariant(), convert.getFilters());
return conversionService.convert(cloudGateWays, PlatformGatewaysResponse.class);
}
use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.
the class PlatformParameterV1Controller method getCloudNetworks.
@Override
public PlatformNetworksResponse getCloudNetworks(PlatformResourceRequestJson resourceRequestJson) {
resourceRequestJson = prepareAccountAndOwner(resourceRequestJson, authenticatedUserService.getCbUser());
PlatformResourceRequest convert = conversionService.convert(resourceRequestJson, PlatformResourceRequest.class);
CloudNetworks cloudNetworks = cloudParameterService.getCloudNetworks(convert.getCredential(), convert.getRegion(), convert.getPlatformVariant(), convert.getFilters());
return conversionService.convert(cloudNetworks, PlatformNetworksResponse.class);
}
use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.
the class PlatformParameterV1Controller method createRecommendation.
@Override
public RecommendationResponse createRecommendation(RecommendationRequestJson recommendationRequestJson) {
IdentityUser cbUser = authenticatedUserService.getCbUser();
PlatformResourceRequest resourceRequest = conversionService.convert(recommendationRequestJson, PlatformResourceRequest.class);
if (recommendationRequestJson.getBlueprintId() == null && Strings.isNullOrEmpty(recommendationRequestJson.getBlueprintName())) {
fieldIsNotEmpty(recommendationRequestJson.getBlueprintId(), "blueprintId");
}
fieldIsNotEmpty(resourceRequest.getRegion(), "region");
fieldIsNotEmpty(resourceRequest.getAvailabilityZone(), "availabilityZone");
PlatformRecommendation recommendedVms = cloudResourceAdvisor.createForBlueprint(recommendationRequestJson.getBlueprintName(), recommendationRequestJson.getBlueprintId(), resourceRequest, cbUser);
return conversionService.convert(recommendedVms, RecommendationResponse.class);
}
Aggregations