Search in sources :

Example 16 with ListResponse

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

the class ListNetworksCmd method execute.

@Override
public void execute() {
    List<? extends Network> networks = _networkService.searchForNetworks(this);
    ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
    List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
    for (Network network : networks) {
        NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(network);
        networkResponses.add(networkResponse);
    }
    response.setResponses(networkResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) Network(com.cloud.network.Network) NetworkResponse(com.cloud.api.response.NetworkResponse) ArrayList(java.util.ArrayList)

Example 17 with ListResponse

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

the class ListPhysicalNetworksCmd method execute.

@Override
public void execute() {
    List<? extends PhysicalNetwork> result = _networkService.searchPhysicalNetworks(getId(), getZoneId(), this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getNetworkName());
    if (result != null) {
        ListResponse<PhysicalNetworkResponse> response = new ListResponse<PhysicalNetworkResponse>();
        List<PhysicalNetworkResponse> networkResponses = new ArrayList<PhysicalNetworkResponse>();
        for (PhysicalNetwork network : result) {
            PhysicalNetworkResponse networkResponse = _responseGenerator.createPhysicalNetworkResponse(network);
            networkResponses.add(networkResponse);
        }
        response.setResponses(networkResponses);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to search for physical networks");
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) PhysicalNetworkResponse(com.cloud.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList)

Example 18 with ListResponse

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

the class ListPodsByCmd method execute.

@Override
public void execute() {
    List<? extends Pod> result = _mgr.searchForPods(this);
    ListResponse<PodResponse> response = new ListResponse<PodResponse>();
    List<PodResponse> podResponses = new ArrayList<PodResponse>();
    for (Pod pod : result) {
        PodResponse podResponse = _responseGenerator.createPodResponse(pod, showCapacities);
        podResponse.setObjectName("pod");
        podResponses.add(podResponse);
    }
    response.setResponses(podResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) Pod(com.cloud.dc.Pod) ArrayList(java.util.ArrayList) PodResponse(com.cloud.api.response.PodResponse)

Example 19 with ListResponse

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

the class ListProjectInvitationsCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    List<? extends ProjectInvitation> invites = _projectService.listProjectInvitations(id, projectId, this.getAccountName(), this.getDomainId(), state, activeOnly, this.getStartIndex(), this.getPageSizeVal(), this.isRecursive(), this.listAll());
    ListResponse<ProjectInvitationResponse> response = new ListResponse<ProjectInvitationResponse>();
    List<ProjectInvitationResponse> projectInvitationResponses = new ArrayList<ProjectInvitationResponse>();
    for (ProjectInvitation invite : invites) {
        ProjectInvitationResponse projectResponse = _responseGenerator.createProjectInvitationResponse(invite);
        projectInvitationResponses.add(projectResponse);
    }
    response.setResponses(projectInvitationResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ProjectInvitationResponse(com.cloud.api.response.ProjectInvitationResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) ProjectInvitation(com.cloud.projects.ProjectInvitation)

Example 20 with ListResponse

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

the class ListAccountsCmd method execute.

@Override
public void execute() {
    List<? extends Account> accounts = _accountService.searchForAccounts(this);
    ListResponse<AccountResponse> response = new ListResponse<AccountResponse>();
    List<AccountResponse> accountResponses = new ArrayList<AccountResponse>();
    for (Account account : accounts) {
        AccountResponse acctResponse = _responseGenerator.createAccountResponse(account);
        acctResponse.setObjectName("account");
        accountResponses.add(acctResponse);
    }
    response.setResponses(accountResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : Account(com.cloud.user.Account) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) AccountResponse(com.cloud.api.response.AccountResponse)

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