Search in sources :

Example 56 with ListResponse

use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.

the class ListVPCOfferingsCmd method execute.

@Override
public void execute() {
    final Pair<List<? extends VpcOffering>, Integer> offerings = _vpcProvSvc.listVpcOfferings(getId(), getVpcOffName(), getDisplayText(), getSupportedServices(), isDefault, this.getKeyword(), getState(), this.getStartIndex(), this.getPageSizeVal());
    final ListResponse<VpcOfferingResponse> response = new ListResponse<>();
    final List<VpcOfferingResponse> offeringResponses = new ArrayList<>();
    for (final VpcOffering offering : offerings.first()) {
        final VpcOfferingResponse offeringResponse = _responseGenerator.createVpcOfferingResponse(offering);
        offeringResponses.add(offeringResponse);
    }
    response.setResponses(offeringResponses, offerings.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : VpcOfferingResponse(com.cloud.api.response.VpcOfferingResponse) ListResponse(com.cloud.api.response.ListResponse) VpcOffering(com.cloud.network.vpc.VpcOffering) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 57 with ListResponse

use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.

the class ListVPCsCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends Vpc>, Integer> vpcs = _vpcService.listVpcs(getId(), getVpcName(), getDisplayText(), getSupportedServices(), getCidr(), getVpcOffId(), getState(), getAccountName(), getDomainId(), getKeyword(), getStartIndex(), getPageSizeVal(), getZoneId(), isRecursive(), listAll(), getRestartRequired(), getTags(), getProjectId(), getDisplay());
    final ListResponse<VpcResponse> response = new ListResponse<>();
    final List<VpcResponse> vpcResponses = new ArrayList<>();
    for (final Vpc vpc : vpcs.first()) {
        final VpcResponse offeringResponse = _responseGenerator.createVpcResponse(ResponseView.Restricted, vpc);
        vpcResponses.add(offeringResponse);
    }
    response.setResponses(vpcResponses, vpcs.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) VpcResponse(com.cloud.api.response.VpcResponse) Vpc(com.cloud.network.vpc.Vpc) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 58 with ListResponse

use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.

the class ListVMSnapshotCmd method execute.

@Override
public void execute() {
    final List<? extends VMSnapshot> result = _vmSnapshotService.listVMSnapshots(this);
    final ListResponse<VMSnapshotResponse> response = new ListResponse<>();
    final List<VMSnapshotResponse> snapshotResponses = new ArrayList<>();
    for (final VMSnapshot r : result) {
        final VMSnapshotResponse vmSnapshotResponse = _responseGenerator.createVMSnapshotResponse(r);
        vmSnapshotResponse.setObjectName("vmSnapshot");
        snapshotResponses.add(vmSnapshotResponse);
    }
    response.setResponses(snapshotResponses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) VMSnapshotResponse(com.cloud.api.response.VMSnapshotResponse) ArrayList(java.util.ArrayList) VMSnapshot(com.cloud.vm.snapshot.VMSnapshot)

Example 59 with ListResponse

use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.

the class ListVpnCustomerGatewaysCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends Site2SiteCustomerGateway>, Integer> gws = _s2sVpnService.searchForCustomerGateways(this);
    final ListResponse<Site2SiteCustomerGatewayResponse> response = new ListResponse<>();
    final List<Site2SiteCustomerGatewayResponse> gwResponses = new ArrayList<>();
    for (final Site2SiteCustomerGateway gw : gws.first()) {
        if (gw == null) {
            continue;
        }
        final Site2SiteCustomerGatewayResponse site2SiteCustomerGatewayRes = _responseGenerator.createSite2SiteCustomerGatewayResponse(gw);
        site2SiteCustomerGatewayRes.setObjectName("vpncustomergateway");
        gwResponses.add(site2SiteCustomerGatewayRes);
    }
    response.setResponses(gwResponses, gws.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) Site2SiteCustomerGatewayResponse(com.cloud.api.response.Site2SiteCustomerGatewayResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Site2SiteCustomerGateway(com.cloud.network.Site2SiteCustomerGateway)

Example 60 with ListResponse

use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.

the class ListUsersCmdTest method testExecuteWithEmptySecretKey.

@Test
public void testExecuteWithEmptySecretKey() {
    ListResponse<UserResponse> responseList = new ListResponse<>();
    UserResponse response = new UserResponse();
    responseList.setResponses(Arrays.asList(response));
    when(queryService.searchForUsers(listUsersCmd)).thenReturn(responseList);
    listUsersCmd.execute();
    responseList = (ListResponse) listUsersCmd.getResponseObject();
    response = responseList.getResponses().get(0);
    assertFalse("Empty SecretKey should be left empty", StringUtils.isNotBlank(response.getSecretKey()));
}
Also used : UserResponse(com.cloud.api.response.UserResponse) ListResponse(com.cloud.api.response.ListResponse) Test(org.junit.Test)

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