Search in sources :

Example 81 with ListResponse

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

the class ListPublicIpAddressesCmd method execute.

@Override
public void execute() {
    List<? extends IpAddress> result = _mgr.searchForIPAddresses(this);
    ListResponse<IPAddressResponse> response = new ListResponse<IPAddressResponse>();
    List<IPAddressResponse> ipAddrResponses = new ArrayList<IPAddressResponse>();
    for (IpAddress ipAddress : result) {
        IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ipAddress);
        ipResponse.setObjectName("publicipaddress");
        ipAddrResponses.add(ipResponse);
    }
    response.setResponses(ipAddrResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) IpAddress(com.cloud.network.IpAddress) IPAddressResponse(com.cloud.api.response.IPAddressResponse)

Example 82 with ListResponse

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

the class ListRoutersCmd method execute.

@Override
public void execute() {
    List<? extends VirtualRouter> result = _mgr.searchForRouters(this);
    ListResponse<DomainRouterResponse> response = new ListResponse<DomainRouterResponse>();
    List<DomainRouterResponse> routerResponses = new ArrayList<DomainRouterResponse>();
    for (VirtualRouter router : result) {
        DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(router);
        routerResponse.setObjectName("router");
        routerResponses.add(routerResponse);
    }
    response.setResponses(routerResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 83 with ListResponse

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

the class ListSSHKeyPairsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    List<? extends SSHKeyPair> resultList = _mgr.listSSHKeyPairs(this);
    List<SSHKeyPairResponse> responses = new ArrayList<SSHKeyPairResponse>();
    for (SSHKeyPair result : resultList) {
        SSHKeyPairResponse r = new SSHKeyPairResponse(result.getName(), result.getFingerprint());
        r.setObjectName("sshkeypair");
        responses.add(r);
    }
    ListResponse<SSHKeyPairResponse> response = new ListResponse<SSHKeyPairResponse>();
    response.setResponses(responses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : SSHKeyPairResponse(com.cloud.api.response.SSHKeyPairResponse) SSHKeyPair(com.cloud.user.SSHKeyPair) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList)

Example 84 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 85 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)

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