api,server,ui: add project ID and name to UserDataResponse (#8656)

* api,server,ui: add project ID and name to UserDataResponse

* Update: add since
This commit is contained in:
Wei Zhou 2024-03-25 14:45:34 +01:00 committed by GitHub
parent f4058705d7
commit 08d9d06d45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 8 deletions

View File

@ -24,7 +24,7 @@ import org.apache.cloudstack.api.BaseResponseWithAnnotations;
import org.apache.cloudstack.api.EntityReference;
@EntityReference(value = UserData.class)
public class UserDataResponse extends BaseResponseWithAnnotations {
public class UserDataResponse extends BaseResponseWithAnnotations implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "ID of the ssh keypair")
@ -40,6 +40,14 @@ public class UserDataResponse extends BaseResponseWithAnnotations {
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the owner of the userdata")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID)
@Param(description = "the project id of the userdata", since = "4.19.1")
private String projectId;
@SerializedName(ApiConstants.PROJECT)
@Param(description = "the project name of the userdata", since = "4.19.1")
private String projectName;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id of the userdata owner")
private String domainId;
@ -118,6 +126,16 @@ public class UserDataResponse extends BaseResponseWithAnnotations {
this.accountName = accountName;
}
@Override
public void setProjectId(String projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getDomainName() {
return domain;
}

View File

@ -4818,12 +4818,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public UserDataResponse createUserDataResponse(UserData userData) {
UserDataResponse response = new UserDataResponse(userData.getUuid(), userData.getName(), userData.getUserData(), userData.getParams());
Account account = ApiDBUtils.findAccountById(userData.getAccountId());
response.setAccountId(account.getUuid());
response.setAccountName(account.getAccountName());
Domain domain = ApiDBUtils.findDomainById(userData.getDomainId());
response.setDomainId(domain.getUuid());
response.setDomainName(domain.getName());
populateOwner(response, userData);
response.setHasAnnotation(annotationDao.hasAnnotations(userData.getUuid(), AnnotationService.EntityType.USER_DATA.name(),
_accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())));
return response;

View File

@ -898,7 +898,12 @@ export default {
var fields = ['name', 'id']
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
fields.push('account')
if (store.getters.listAllProjects) {
fields.push('project')
}
fields.push('domain')
} else if (store.getters.listAllProjects) {
fields.push('project')
}
return fields
},

View File

@ -793,7 +793,7 @@ export default {
}
this.projectView = Boolean(store.getters.project && store.getters.project.id)
this.hasProjectId = ['vm', 'vmgroup', 'ssh', 'affinitygroup', 'volume', 'snapshot', 'vmsnapshot', 'guestnetwork',
this.hasProjectId = ['vm', 'vmgroup', 'ssh', 'affinitygroup', 'userdata', 'volume', 'snapshot', 'vmsnapshot', 'guestnetwork',
'vpc', 'securitygroups', 'publicip', 'vpncustomergateway', 'template', 'iso', 'event', 'kubernetes',
'autoscalevmgroup', 'vnfapp'].includes(this.$route.name)