api: Allow users to list VMs by Backup Offering Id (#5679)

Co-authored-by: SadiJr <sadi@scclouds.com.br>
This commit is contained in:
SadiJr 2021-12-30 07:50:33 -03:00 committed by GitHub
parent b63498d847
commit d8d5665903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -37,6 +37,7 @@ import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.response.BackupOfferingResponse;
import org.apache.cloudstack.api.response.HostResponse; import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.InstanceGroupResponse; import org.apache.cloudstack.api.response.InstanceGroupResponse;
import org.apache.cloudstack.api.response.IsoVmResponse; import org.apache.cloudstack.api.response.IsoVmResponse;
@ -132,6 +133,9 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd implements UserCmd {
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, description = "list by the service offering", since = "4.4") @Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, description = "list by the service offering", since = "4.4")
private Long serviceOffId; private Long serviceOffId;
@Parameter(name = ApiConstants.BACKUP_OFFERING_ID, type = CommandType.UUID, entityType = BackupOfferingResponse.class, description = "list by the backup offering", since = "4.17")
private Long backupOffId;
@Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) @Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin})
private Boolean display; private Boolean display;
@ -180,6 +184,10 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd implements UserCmd {
return serviceOffId; return serviceOffId;
} }
public Long getBackupOfferingId() {
return backupOffId;
}
public Long getZoneId() { public Long getZoneId() {
return zoneId; return zoneId;
} }

View File

@ -984,6 +984,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
Object keyPairName = cmd.getKeyPairName(); Object keyPairName = cmd.getKeyPairName();
Object serviceOffId = cmd.getServiceOfferingId(); Object serviceOffId = cmd.getServiceOfferingId();
Object securityGroupId = cmd.getSecurityGroupId(); Object securityGroupId = cmd.getSecurityGroupId();
Object backupOfferingId = cmd.getBackupOfferingId();
Object isHaEnabled = cmd.getHaEnabled(); Object isHaEnabled = cmd.getHaEnabled();
Object pod = null; Object pod = null;
Long clusterId = null; Long clusterId = null;
@ -1016,6 +1017,11 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
if (serviceOffId != null) { if (serviceOffId != null) {
sb.and("serviceOfferingId", sb.entity().getServiceOfferingId(), SearchCriteria.Op.EQ); sb.and("serviceOfferingId", sb.entity().getServiceOfferingId(), SearchCriteria.Op.EQ);
} }
if (backupOfferingId != null) {
sb.and("backupOfferingId", sb.entity().getBackupOfferingId(), SearchCriteria.Op.EQ);
}
if (display != null) { if (display != null) {
sb.and("display", sb.entity().isDisplayVm(), SearchCriteria.Op.EQ); sb.and("display", sb.entity().isDisplayVm(), SearchCriteria.Op.EQ);
} }
@ -1102,6 +1108,10 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
sc.setParameters("serviceOfferingId", serviceOffId); sc.setParameters("serviceOfferingId", serviceOffId);
} }
if (backupOfferingId != null) {
sc.setParameters("backupOfferingId", backupOfferingId);
}
if (securityGroupId != null) { if (securityGroupId != null) {
sc.setParameters("securityGroupId", securityGroupId); sc.setParameters("securityGroupId", securityGroupId);
} }

View File

@ -629,6 +629,10 @@ public class UserVmJoinVO extends BaseViewWithTagInformationVO implements Contro
return backupOfferingUuid; return backupOfferingUuid;
} }
public Long getBackupOfferingId() {
return backupOfferingId;
}
public String getBackupOfferingName() { public String getBackupOfferingName() {
return backupOfferingName; return backupOfferingName;
} }