use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class UpdateResourceCountCmd method execute.
@Override
public void execute() {
final List<? extends ResourceCount> result = _resourceLimitService.recalculateResourceCount(_accountService.finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), getResourceType());
if ((result != null) && (result.size() > 0)) {
final ListResponse<ResourceCountResponse> response = new ListResponse<>();
final List<ResourceCountResponse> countResponses = new ArrayList<>();
for (final ResourceCount count : result) {
final ResourceCountResponse resourceCountResponse = _responseGenerator.createResourceCountResponse(count);
resourceCountResponse.setObjectName("resourcecount");
countResponses.add(resourceCountResponse);
}
response.setResponses(countResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to recalculate resource counts");
}
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListLoadBalancerRulesCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends LoadBalancer>, Integer> loadBalancers = _lbService.searchForLoadBalancers(this);
final ListResponse<LoadBalancerResponse> response = new ListResponse<>();
final List<LoadBalancerResponse> lbResponses = new ArrayList<>();
if (loadBalancers != null) {
for (final LoadBalancer loadBalancer : loadBalancers.first()) {
final LoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerResponse(loadBalancer);
lbResponse.setObjectName("loadbalancerrule");
lbResponses.add(lbResponse);
}
response.setResponses(lbResponses, loadBalancers.second());
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListNetworkOfferingsCmd method execute.
@Override
public void execute() {
final Pair<List<? extends NetworkOffering>, Integer> offerings = _configService.searchForNetworkOfferings(this);
final ListResponse<NetworkOfferingResponse> response = new ListResponse<>();
final List<NetworkOfferingResponse> offeringResponses = new ArrayList<>();
for (final NetworkOffering offering : offerings.first()) {
final NetworkOfferingResponse offeringResponse = _responseGenerator.createNetworkOfferingResponse(offering);
offeringResponses.add(offeringResponse);
}
response.setResponses(offeringResponses, offerings.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListPrivateGatewaysCmd method execute.
@Override
public void execute() {
final Pair<List<PrivateGateway>, Integer> gateways = _vpcService.listPrivateGateway(this);
final ListResponse<PrivateGatewayResponse> response = new ListResponse<>();
final List<PrivateGatewayResponse> projectResponses = new ArrayList<>();
for (final PrivateGateway gateway : gateways.first()) {
final PrivateGatewayResponse gatewayResponse = _responseGenerator.createPrivateGatewayResponse(gateway);
projectResponses.add(gatewayResponse);
}
response.setResponses(projectResponses, gateways.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListStaticRoutesCmd method execute.
@Override
public void execute() {
checkDeprecatedParameters();
final Pair<List<? extends StaticRoute>, Integer> result = _vpcService.listStaticRoutes(this);
final ListResponse<StaticRouteResponse> response = new ListResponse<>();
final List<StaticRouteResponse> routeResponses = new ArrayList<>();
result.first().forEach(route -> {
final StaticRouteResponse ruleData = _responseGenerator.createStaticRouteResponse(route);
routeResponses.add(ruleData);
});
response.setResponses(routeResponses, result.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
Aggregations