Search in sources :

Example 31 with ListResponse

use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.

the class ListServiceOfferingsCmd method execute.

@Override
public void execute() {
    List<? extends ServiceOffering> offerings = _mgr.searchForServiceOfferings(this);
    ListResponse<ServiceOfferingResponse> response = new ListResponse<ServiceOfferingResponse>();
    List<ServiceOfferingResponse> offeringResponses = new ArrayList<ServiceOfferingResponse>();
    for (ServiceOffering offering : offerings) {
        ServiceOfferingResponse offeringResponse = _responseGenerator.createServiceOfferingResponse(offering);
        offeringResponse.setObjectName("serviceoffering");
        offeringResponses.add(offeringResponse);
    }
    response.setResponses(offeringResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ServiceOfferingResponse(com.cloud.api.response.ServiceOfferingResponse) ListResponse(com.cloud.api.response.ListResponse) ServiceOffering(com.cloud.offering.ServiceOffering) ArrayList(java.util.ArrayList)

Example 32 with ListResponse

use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.

the class ListSnapshotPoliciesCmd method execute.

@Override
public void execute() {
    List<? extends SnapshotPolicy> result = _snapshotService.listPoliciesforVolume(this);
    ListResponse<SnapshotPolicyResponse> response = new ListResponse<SnapshotPolicyResponse>();
    List<SnapshotPolicyResponse> policyResponses = new ArrayList<SnapshotPolicyResponse>();
    for (SnapshotPolicy policy : result) {
        SnapshotPolicyResponse policyResponse = _responseGenerator.createSnapshotPolicyResponse(policy);
        policyResponse.setObjectName("snapshotpolicy");
        policyResponses.add(policyResponse);
    }
    response.setResponses(policyResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : SnapshotPolicyResponse(com.cloud.api.response.SnapshotPolicyResponse) SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList)

Example 33 with ListResponse

use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.

the class ListSnapshotsCmd method execute.

@Override
public void execute() {
    List<? extends Snapshot> result = _snapshotService.listSnapshots(this);
    ListResponse<SnapshotResponse> response = new ListResponse<SnapshotResponse>();
    List<SnapshotResponse> snapshotResponses = new ArrayList<SnapshotResponse>();
    for (Snapshot snapshot : result) {
        SnapshotResponse snapshotResponse = _responseGenerator.createSnapshotResponse(snapshot);
        snapshotResponse.setObjectName("snapshot");
        snapshotResponses.add(snapshotResponse);
    }
    response.setResponses(snapshotResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : Snapshot(com.cloud.storage.Snapshot) ListResponse(com.cloud.api.response.ListResponse) SnapshotResponse(com.cloud.api.response.SnapshotResponse) ArrayList(java.util.ArrayList)

Example 34 with ListResponse

use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.

the class ListLBStickinessPoliciesCmd method execute.

@Override
public void execute() {
    List<LBStickinessResponse> spResponses = new ArrayList<LBStickinessResponse>();
    LoadBalancer lb = _lbService.findById(getLbRuleId());
    ListResponse<LBStickinessResponse> response = new ListResponse<LBStickinessResponse>();
    if (lb != null) {
        //check permissions
        Account caller = UserContext.current().getCaller();
        _accountService.checkAccess(caller, null, true, lb);
        List<? extends StickinessPolicy> stickinessPolicies = _lbService.searchForLBStickinessPolicies(this);
        LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(stickinessPolicies, lb);
        spResponses.add(spResponse);
        response.setResponses(spResponses);
    }
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : Account(com.cloud.user.Account) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) LoadBalancer(com.cloud.network.rules.LoadBalancer) LBStickinessResponse(com.cloud.api.response.LBStickinessResponse)

Example 35 with ListResponse

use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.

the class ListNetworkOfferingsCmd method execute.

@Override
public void execute() {
    List<? extends NetworkOffering> offerings = _configService.searchForNetworkOfferings(this);
    ListResponse<NetworkOfferingResponse> response = new ListResponse<NetworkOfferingResponse>();
    List<NetworkOfferingResponse> offeringResponses = new ArrayList<NetworkOfferingResponse>();
    for (NetworkOffering offering : offerings) {
        NetworkOfferingResponse offeringResponse = _responseGenerator.createNetworkOfferingResponse(offering);
        offeringResponses.add(offeringResponse);
    }
    response.setResponses(offeringResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) NetworkOfferingResponse(com.cloud.api.response.NetworkOfferingResponse) NetworkOffering(com.cloud.offering.NetworkOffering) ArrayList(java.util.ArrayList)

Aggregations

ListResponse (com.cloud.api.response.ListResponse)57 ArrayList (java.util.ArrayList)54 ServerApiException (com.cloud.api.ServerApiException)7 TemplateResponse (com.cloud.api.response.TemplateResponse)3 ClusterResponse (com.cloud.api.response.ClusterResponse)2 DomainResponse (com.cloud.api.response.DomainResponse)2 HostResponse (com.cloud.api.response.HostResponse)2 Domain (com.cloud.domain.Domain)2 DiscoveryException (com.cloud.exception.DiscoveryException)2 Host (com.cloud.host.Host)2 Cluster (com.cloud.org.Cluster)2 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)2 Alert (com.cloud.alert.Alert)1 AccountResponse (com.cloud.api.response.AccountResponse)1 AlertResponse (com.cloud.api.response.AlertResponse)1 AsyncJobResponse (com.cloud.api.response.AsyncJobResponse)1 ConfigurationResponse (com.cloud.api.response.ConfigurationResponse)1 DiskOfferingResponse (com.cloud.api.response.DiskOfferingResponse)1 DomainRouterResponse (com.cloud.api.response.DomainRouterResponse)1 EventResponse (com.cloud.api.response.EventResponse)1