Search in sources :

Example 36 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 37 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)

Example 38 with ListResponse

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

the class RegisterIsoCmd method execute.

@Override
public void execute() throws ResourceAllocationException {
    VirtualMachineTemplate template = _templateService.registerIso(this);
    if (template != null) {
        ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
        List<TemplateResponse> templateResponses = _responseGenerator.createIsoResponses(template.getId(), zoneId, false);
        response.setResponses(templateResponses);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register iso");
    }
}
Also used : VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) TemplateResponse(com.cloud.api.response.TemplateResponse)

Example 39 with ListResponse

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

the class ListVpnUsersCmd method execute.

@Override
public void execute() {
    List<? extends VpnUser> vpnUsers = _ravService.searchForVpnUsers(this);
    ListResponse<VpnUsersResponse> response = new ListResponse<VpnUsersResponse>();
    List<VpnUsersResponse> vpnResponses = new ArrayList<VpnUsersResponse>();
    for (VpnUser vpnUser : vpnUsers) {
        vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
    }
    response.setResponses(vpnResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : VpnUser(com.cloud.network.VpnUser) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) VpnUsersResponse(com.cloud.api.response.VpnUsersResponse)

Example 40 with ListResponse

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

the class ListSupportedNetworkServicesCmd method execute.

@Override
public void execute() {
    List<? extends Network.Service> services;
    if (getServiceName() != null) {
        Network.Service service = null;
        if (serviceName != null) {
            service = Network.Service.getService(serviceName);
            if (service == null) {
                throw new InvalidParameterValueException("Invalid Network Service=" + serviceName);
            }
        }
        List<Network.Service> serviceList = new ArrayList<Network.Service>();
        serviceList.add(service);
        services = serviceList;
    } else {
        services = _networkService.listNetworkServices(getProviderName());
    }
    ListResponse<ServiceResponse> response = new ListResponse<ServiceResponse>();
    List<ServiceResponse> servicesResponses = new ArrayList<ServiceResponse>();
    for (Network.Service service : services) {
        //skip gateway service
        if (service == Service.Gateway) {
            continue;
        }
        ServiceResponse serviceResponse = _responseGenerator.createNetworkServiceResponse(service);
        servicesResponses.add(serviceResponse);
    }
    response.setResponses(servicesResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ServiceResponse(com.cloud.api.response.ServiceResponse) ListResponse(com.cloud.api.response.ListResponse) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Network(com.cloud.network.Network) ArrayList(java.util.ArrayList) Service(com.cloud.network.Network.Service) Service(com.cloud.network.Network.Service)

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