Search in sources :

Example 86 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 87 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 88 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)

Example 89 with ListResponse

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

the class ListPortForwardingRulesCmd method execute.

@Override
public void execute() {
    List<? extends PortForwardingRule> result = _rulesService.listPortForwardingRules(this);
    ListResponse<FirewallRuleResponse> response = new ListResponse<FirewallRuleResponse>();
    List<FirewallRuleResponse> fwResponses = new ArrayList<FirewallRuleResponse>();
    for (PortForwardingRule fwRule : result) {
        FirewallRuleResponse ruleData = _responseGenerator.createPortForwardingRuleResponse(fwRule);
        ruleData.setObjectName("portforwardingrule");
        fwResponses.add(ruleData);
    }
    response.setResponses(fwResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) FirewallRuleResponse(com.cloud.api.response.FirewallRuleResponse) PortForwardingRule(com.cloud.network.rules.PortForwardingRule)

Example 90 with ListResponse

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

the class ListProjectAccountsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    List<? extends ProjectAccount> projectAccounts = _projectService.listProjectAccounts(projectId, accountName, role, this.getStartIndex(), this.getPageSizeVal());
    ListResponse<ProjectAccountResponse> response = new ListResponse<ProjectAccountResponse>();
    List<ProjectAccountResponse> projectResponses = new ArrayList<ProjectAccountResponse>();
    for (ProjectAccount projectAccount : projectAccounts) {
        ProjectAccountResponse projectAccountResponse = _responseGenerator.createProjectAccountResponse(projectAccount);
        projectResponses.add(projectAccountResponse);
    }
    response.setResponses(projectResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ProjectAccount(com.cloud.projects.ProjectAccount) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) ProjectAccountResponse(com.cloud.api.response.ProjectAccountResponse)

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