Search in sources :

Example 51 with ListResponse

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");
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) ResourceCount(com.cloud.configuration.ResourceCount) ArrayList(java.util.ArrayList) ResourceCountResponse(com.cloud.api.response.ResourceCountResponse)

Example 52 with ListResponse

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

Example 53 with ListResponse

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);
}
Also used : NetworkOfferingResponse(com.cloud.api.response.NetworkOfferingResponse) ListResponse(com.cloud.api.response.ListResponse) NetworkOffering(com.cloud.offering.NetworkOffering) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 54 with ListResponse

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

Example 55 with ListResponse

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

Aggregations

ListResponse (com.cloud.api.response.ListResponse)156 ArrayList (java.util.ArrayList)139 List (java.util.List)60 ServerApiException (com.cloud.api.ServerApiException)30 TemplateResponse (com.cloud.api.response.TemplateResponse)13 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)11 ResponseView (com.cloud.api.ResponseObject.ResponseView)10 Network (com.cloud.network.Network)9 DedicatedResources (com.cloud.dc.DedicatedResources)8 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)8 DomainResponse (com.cloud.api.response.DomainResponse)7 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)7 Domain (com.cloud.domain.Domain)7 VirtualMachine (com.cloud.vm.VirtualMachine)7 StoragePoolResponse (com.cloud.api.response.StoragePoolResponse)6 UserResponse (com.cloud.api.response.UserResponse)6 UserVmResponse (com.cloud.api.response.UserVmResponse)6 Host (com.cloud.host.Host)6 AccountResponse (com.cloud.api.response.AccountResponse)5 HostResponse (com.cloud.api.response.HostResponse)5