Search in sources :

Example 1 with ResponseView

use of org.apache.cloudstack.api.ResponseObject.ResponseView in project cloudstack by apache.

the class QueryManagerImpl method searchForAccounts.

@Override
public ListResponse<AccountResponse> searchForAccounts(ListAccountsCmd cmd) {
    Pair<List<AccountJoinVO>, Integer> result = searchForAccountsInternal(cmd);
    ListResponse<AccountResponse> response = new ListResponse<AccountResponse>();
    ResponseView respView = ResponseView.Restricted;
    if (cmd instanceof ListAccountsCmdByAdmin) {
        respView = ResponseView.Full;
    }
    List<AccountResponse> accountResponses = ViewResponseHelper.createAccountResponse(respView, result.first().toArray(new AccountJoinVO[result.first().size()]));
    response.setResponses(accountResponses, result.second());
    return response;
}
Also used : ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) List(java.util.List) ProjectAccountResponse(org.apache.cloudstack.api.response.ProjectAccountResponse) AccountResponse(org.apache.cloudstack.api.response.AccountResponse) ListAccountsCmdByAdmin(org.apache.cloudstack.api.command.admin.account.ListAccountsCmdByAdmin) ProjectAccountJoinVO(com.cloud.api.query.vo.ProjectAccountJoinVO) UserAccountJoinVO(com.cloud.api.query.vo.UserAccountJoinVO) AccountJoinVO(com.cloud.api.query.vo.AccountJoinVO)

Example 2 with ResponseView

use of org.apache.cloudstack.api.ResponseObject.ResponseView in project cloudstack by apache.

the class QueryManagerImpl method listDataCenters.

@Override
public ListResponse<ZoneResponse> listDataCenters(ListZonesCmd cmd) {
    Pair<List<DataCenterJoinVO>, Integer> result = listDataCentersInternal(cmd);
    ListResponse<ZoneResponse> response = new ListResponse<ZoneResponse>();
    ResponseView respView = ResponseView.Restricted;
    if (cmd instanceof ListZonesCmdByAdmin) {
        respView = ResponseView.Full;
    }
    List<ZoneResponse> dcResponses = ViewResponseHelper.createDataCenterResponse(respView, cmd.getShowCapacities(), result.first().toArray(new DataCenterJoinVO[result.first().size()]));
    response.setResponses(dcResponses, result.second());
    return response;
}
Also used : ZoneResponse(org.apache.cloudstack.api.response.ZoneResponse) DataCenterJoinVO(com.cloud.api.query.vo.DataCenterJoinVO) ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) List(java.util.List) ListZonesCmdByAdmin(org.apache.cloudstack.api.command.admin.zone.ListZonesCmdByAdmin)

Example 3 with ResponseView

use of org.apache.cloudstack.api.ResponseObject.ResponseView in project cloudstack by apache.

the class QueryManagerImpl method listTemplates.

@Override
public ListResponse<TemplateResponse> listTemplates(ListTemplatesCmd cmd) {
    Pair<List<TemplateJoinVO>, Integer> result = searchForTemplatesInternal(cmd);
    ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
    ResponseView respView = ResponseView.Restricted;
    if (cmd instanceof ListTemplatesCmdByAdmin) {
        respView = ResponseView.Full;
    }
    List<TemplateResponse> templateResponses = ViewResponseHelper.createTemplateResponse(respView, result.first().toArray(new TemplateJoinVO[result.first().size()]));
    response.setResponses(templateResponses, result.second());
    return response;
}
Also used : ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) ListResponse(org.apache.cloudstack.api.response.ListResponse) ListTemplatesCmdByAdmin(org.apache.cloudstack.api.command.admin.template.ListTemplatesCmdByAdmin) TemplateJoinVO(com.cloud.api.query.vo.TemplateJoinVO) ArrayList(java.util.ArrayList) List(java.util.List) TemplateResponse(org.apache.cloudstack.api.response.TemplateResponse)

Example 4 with ResponseView

use of org.apache.cloudstack.api.ResponseObject.ResponseView in project cloudstack by apache.

the class QueryManagerImpl method searchForVolumes.

@Override
public ListResponse<VolumeResponse> searchForVolumes(ListVolumesCmd cmd) {
    Pair<List<VolumeJoinVO>, Integer> result = searchForVolumesInternal(cmd);
    ListResponse<VolumeResponse> response = new ListResponse<VolumeResponse>();
    ResponseView respView = ResponseView.Restricted;
    if (cmd instanceof ListVolumesCmdByAdmin) {
        respView = ResponseView.Full;
    }
    List<VolumeResponse> volumeResponses = ViewResponseHelper.createVolumeResponse(respView, result.first().toArray(new VolumeJoinVO[result.first().size()]));
    for (VolumeResponse vr : volumeResponses) {
        String poolId = vr.getStoragePoolId();
        if (poolId == null) {
            continue;
        }
        DataStore store = dataStoreManager.getPrimaryDataStore(poolId);
        if (store == null) {
            continue;
        }
        DataStoreDriver driver = store.getDriver();
        if (driver == null) {
            continue;
        }
        Map<String, String> caps = driver.getCapabilities();
        if (caps != null) {
            boolean quiescevm = Boolean.parseBoolean(caps.get(DataStoreCapabilities.VOLUME_SNAPSHOT_QUIESCEVM.toString()));
            vr.setNeedQuiescevm(quiescevm);
        }
    }
    response.setResponses(volumeResponses, result.second());
    return response;
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) VolumeResponse(org.apache.cloudstack.api.response.VolumeResponse) DataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver) ListVolumesCmdByAdmin(org.apache.cloudstack.api.command.admin.volume.ListVolumesCmdByAdmin) ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) List(java.util.List) VolumeJoinVO(com.cloud.api.query.vo.VolumeJoinVO)

Example 5 with ResponseView

use of org.apache.cloudstack.api.ResponseObject.ResponseView in project cloudstack by apache.

the class QueryManagerImpl method searchForUserVMs.

@Override
public ListResponse<UserVmResponse> searchForUserVMs(ListVMsCmd cmd) {
    Pair<List<UserVmJoinVO>, Integer> result = searchForUserVMsInternal(cmd);
    ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
    ResponseView respView = ResponseView.Restricted;
    if (cmd instanceof ListVMsCmdByAdmin) {
        respView = ResponseView.Full;
    }
    List<UserVmResponse> vmResponses = ViewResponseHelper.createUserVmResponse(respView, "virtualmachine", cmd.getDetails(), result.first().toArray(new UserVmJoinVO[result.first().size()]));
    response.setResponses(vmResponses, result.second());
    return response;
}
Also used : ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) ListResponse(org.apache.cloudstack.api.response.ListResponse) ListVMsCmdByAdmin(org.apache.cloudstack.api.command.admin.vm.ListVMsCmdByAdmin) ArrayList(java.util.ArrayList) List(java.util.List) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO)

Aggregations

ArrayList (java.util.ArrayList)7 List (java.util.List)7 ResponseView (org.apache.cloudstack.api.ResponseObject.ResponseView)7 ListResponse (org.apache.cloudstack.api.response.ListResponse)7 TemplateJoinVO (com.cloud.api.query.vo.TemplateJoinVO)2 TemplateResponse (org.apache.cloudstack.api.response.TemplateResponse)2 AccountJoinVO (com.cloud.api.query.vo.AccountJoinVO)1 DataCenterJoinVO (com.cloud.api.query.vo.DataCenterJoinVO)1 DomainJoinVO (com.cloud.api.query.vo.DomainJoinVO)1 ProjectAccountJoinVO (com.cloud.api.query.vo.ProjectAccountJoinVO)1 UserAccountJoinVO (com.cloud.api.query.vo.UserAccountJoinVO)1 UserVmJoinVO (com.cloud.api.query.vo.UserVmJoinVO)1 VolumeJoinVO (com.cloud.api.query.vo.VolumeJoinVO)1 ListAccountsCmdByAdmin (org.apache.cloudstack.api.command.admin.account.ListAccountsCmdByAdmin)1 ListDomainsCmdByAdmin (org.apache.cloudstack.api.command.admin.domain.ListDomainsCmdByAdmin)1 ListIsosCmdByAdmin (org.apache.cloudstack.api.command.admin.iso.ListIsosCmdByAdmin)1 ListTemplatesCmdByAdmin (org.apache.cloudstack.api.command.admin.template.ListTemplatesCmdByAdmin)1 ListVMsCmdByAdmin (org.apache.cloudstack.api.command.admin.vm.ListVMsCmdByAdmin)1 ListVolumesCmdByAdmin (org.apache.cloudstack.api.command.admin.volume.ListVolumesCmdByAdmin)1 ListZonesCmdByAdmin (org.apache.cloudstack.api.command.admin.zone.ListZonesCmdByAdmin)1