use of org.apache.cloudstack.api.response.VpcOfferingResponse in project cloudstack by apache.
the class ApiResponseHelper method createVpcOfferingResponse.
@Override
public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering) {
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());
response.setSupportsDistributedRouter(offering.supportsDistributedRouter());
response.setSupportsRegionLevelVpc(offering.offersRegionLevelVPC());
Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
for (Map.Entry<Service, Set<Provider>> entry : serviceProviderMap.entrySet()) {
Service service = entry.getKey();
Set<Provider> srvc_providers = entry.getValue();
ServiceResponse svcRsp = new ServiceResponse();
// skip gateway service
if (service == Service.Gateway) {
continue;
}
svcRsp.setName(service.getName());
List<ProviderResponse> providers = new ArrayList<ProviderResponse>();
for (Provider provider : srvc_providers) {
if (provider != null) {
ProviderResponse providerRsp = new ProviderResponse();
providerRsp.setName(provider.getName());
providers.add(providerRsp);
}
}
svcRsp.setProviders(providers);
serviceResponses.add(svcRsp);
}
response.setServices(serviceResponses);
response.setObjectName("vpcoffering");
return response;
}
use of org.apache.cloudstack.api.response.VpcOfferingResponse in project cloudstack by apache.
the class CreateVPCOfferingCmd method execute.
@Override
public void execute() {
VpcOffering vpc = _vpcProvSvc.getVpcOffering(getEntityId());
if (vpc != null) {
VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(vpc);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC offering");
}
}
use of org.apache.cloudstack.api.response.VpcOfferingResponse in project cloudstack by apache.
the class UpdateVPCOfferingCmd method execute.
@Override
public void execute() {
VpcOffering result = _vpcProvSvc.updateVpcOffering(getId(), getVpcOfferingName(), getDisplayText(), getState());
if (result != null) {
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 org.apache.cloudstack.api.response.VpcOfferingResponse in project cloudstack by apache.
the class ListVPCOfferingsCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
Pair<List<? extends VpcOffering>, Integer> offerings = _vpcProvSvc.listVpcOfferings(getId(), getVpcOffName(), getDisplayText(), getSupportedServices(), isDefault, this.getKeyword(), getState(), this.getStartIndex(), this.getPageSizeVal());
ListResponse<VpcOfferingResponse> response = new ListResponse<VpcOfferingResponse>();
List<VpcOfferingResponse> offeringResponses = new ArrayList<VpcOfferingResponse>();
for (VpcOffering offering : offerings.first()) {
VpcOfferingResponse offeringResponse = _responseGenerator.createVpcOfferingResponse(offering);
offeringResponses.add(offeringResponse);
}
response.setResponses(offeringResponses, offerings.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations