use of com.cloud.api.response.VpcOfferingResponse in project cosmic by MissionCriticalCloud.
the class CreateVPCOfferingCmd method execute.
@Override
public void execute() {
final VpcOffering vpc = _vpcProvSvc.getVpcOffering(getEntityId());
if (vpc != null) {
final VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(vpc);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC offering");
}
}
use of com.cloud.api.response.VpcOfferingResponse in project cosmic by MissionCriticalCloud.
the class UpdateVPCOfferingCmd method execute.
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final VpcOffering result = _vpcProvSvc.updateVpcOffering(getId(), getVpcOfferingName(), getDisplayText(), getState());
if (result != null) {
final VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update VPC offering");
}
}
use of com.cloud.api.response.VpcOfferingResponse in project cosmic by MissionCriticalCloud.
the class ListVPCOfferingsCmd method execute.
@Override
public void execute() {
final Pair<List<? extends VpcOffering>, Integer> offerings = _vpcProvSvc.listVpcOfferings(getId(), getVpcOffName(), getDisplayText(), getSupportedServices(), isDefault, this.getKeyword(), getState(), this.getStartIndex(), this.getPageSizeVal());
final ListResponse<VpcOfferingResponse> response = new ListResponse<>();
final List<VpcOfferingResponse> offeringResponses = new ArrayList<>();
for (final VpcOffering offering : offerings.first()) {
final VpcOfferingResponse offeringResponse = _responseGenerator.createVpcOfferingResponse(offering);
offeringResponses.add(offeringResponse);
}
response.setResponses(offeringResponses, offerings.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.VpcOfferingResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createVpcOfferingResponse.
@Override
public VpcOfferingResponse createVpcOfferingResponse(final VpcOffering offering) {
final VpcOfferingResponse response = new VpcOfferingResponse();
response.setId(offering.getUuid());
response.setName(offering.getName());
response.setDisplayText(offering.getDisplayText());
response.setIsDefault(offering.isDefault());
response.setState(offering.getState().name());
final ServiceOffering serviceOffering = _serviceOfferingDao.findById(offering.getServiceOfferingId());
if (serviceOffering != null) {
response.setServiceOfferingId(serviceOffering.getUuid());
response.setServiceOfferingName(serviceOffering.getName());
}
final ServiceOffering secondaryServiceOffering = _serviceOfferingDao.findById(offering.getSecondaryServiceOfferingId());
if (secondaryServiceOffering != null) {
response.setSecondaryServiceOfferingId(secondaryServiceOffering.getUuid());
response.setSecondaryServiceOfferingName(secondaryServiceOffering.getName());
}
final Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
final List<ServiceResponse> serviceResponses = getServiceResponses(serviceProviderMap);
response.setServices(serviceResponses);
response.setObjectName("vpcoffering");
return response;
}
Aggregations