Search in sources :

Example 1 with VpcOfferingResponse

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");
    }
}
Also used : VpcOfferingResponse(com.cloud.api.response.VpcOfferingResponse) ServerApiException(com.cloud.api.ServerApiException) VpcOffering(com.cloud.network.vpc.VpcOffering)

Example 2 with VpcOfferingResponse

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");
    }
}
Also used : VpcOfferingResponse(com.cloud.api.response.VpcOfferingResponse) ServerApiException(com.cloud.api.ServerApiException) VpcOffering(com.cloud.network.vpc.VpcOffering)

Example 3 with VpcOfferingResponse

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);
}
Also used : VpcOfferingResponse(com.cloud.api.response.VpcOfferingResponse) ListResponse(com.cloud.api.response.ListResponse) VpcOffering(com.cloud.network.vpc.VpcOffering) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with VpcOfferingResponse

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;
}
Also used : VpcOfferingResponse(com.cloud.api.response.VpcOfferingResponse) ServiceResponse(com.cloud.api.response.ServiceResponse) EnumSet(java.util.EnumSet) HashSet(java.util.HashSet) Set(java.util.Set) ServiceOffering(com.cloud.offering.ServiceOffering) Service(com.cloud.network.Network.Service)

Aggregations

VpcOfferingResponse (com.cloud.api.response.VpcOfferingResponse)4 VpcOffering (com.cloud.network.vpc.VpcOffering)3 ServerApiException (com.cloud.api.ServerApiException)2 ListResponse (com.cloud.api.response.ListResponse)1 ServiceResponse (com.cloud.api.response.ServiceResponse)1 Service (com.cloud.network.Network.Service)1 ServiceOffering (com.cloud.offering.ServiceOffering)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1