Skip to content

Commit 08d9d06

Browse files
api,server,ui: add project ID and name to UserDataResponse (#8656)
* api,server,ui: add project ID and name to UserDataResponse * Update: add since
1 parent f405870 commit 08d9d06

4 files changed

Lines changed: 26 additions & 8 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.apache.cloudstack.api.EntityReference;
2525

2626
@EntityReference(value = UserData.class)
27-
public class UserDataResponse extends BaseResponseWithAnnotations {
27+
public class UserDataResponse extends BaseResponseWithAnnotations implements ControlledEntityResponse {
2828

2929
@SerializedName(ApiConstants.ID)
3030
@Param(description = "ID of the ssh keypair")
@@ -40,6 +40,14 @@ public class UserDataResponse extends BaseResponseWithAnnotations {
4040
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the owner of the userdata")
4141
private String accountName;
4242

43+
@SerializedName(ApiConstants.PROJECT_ID)
44+
@Param(description = "the project id of the userdata", since = "4.19.1")
45+
private String projectId;
46+
47+
@SerializedName(ApiConstants.PROJECT)
48+
@Param(description = "the project name of the userdata", since = "4.19.1")
49+
private String projectName;
50+
4351
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id of the userdata owner")
4452
private String domainId;
4553

@@ -118,6 +126,16 @@ public void setAccountName(String accountName) {
118126
this.accountName = accountName;
119127
}
120128

129+
@Override
130+
public void setProjectId(String projectId) {
131+
this.projectId = projectId;
132+
}
133+
134+
@Override
135+
public void setProjectName(String projectName) {
136+
this.projectName = projectName;
137+
}
138+
121139
public String getDomainName() {
122140
return domain;
123141
}

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4818,12 +4818,7 @@ public SSHKeyPairResponse createSSHKeyPairResponse(SSHKeyPair sshkeyPair, boolea
48184818
@Override
48194819
public UserDataResponse createUserDataResponse(UserData userData) {
48204820
UserDataResponse response = new UserDataResponse(userData.getUuid(), userData.getName(), userData.getUserData(), userData.getParams());
4821-
Account account = ApiDBUtils.findAccountById(userData.getAccountId());
4822-
response.setAccountId(account.getUuid());
4823-
response.setAccountName(account.getAccountName());
4824-
Domain domain = ApiDBUtils.findDomainById(userData.getDomainId());
4825-
response.setDomainId(domain.getUuid());
4826-
response.setDomainName(domain.getName());
4821+
populateOwner(response, userData);
48274822
response.setHasAnnotation(annotationDao.hasAnnotations(userData.getUuid(), AnnotationService.EntityType.USER_DATA.name(),
48284823
_accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())));
48294824
return response;

ui/src/config/section/compute.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,12 @@ export default {
898898
var fields = ['name', 'id']
899899
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
900900
fields.push('account')
901+
if (store.getters.listAllProjects) {
902+
fields.push('project')
903+
}
901904
fields.push('domain')
905+
} else if (store.getters.listAllProjects) {
906+
fields.push('project')
902907
}
903908
return fields
904909
},

ui/src/views/AutogenView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ export default {
793793
}
794794
795795
this.projectView = Boolean(store.getters.project && store.getters.project.id)
796-
this.hasProjectId = ['vm', 'vmgroup', 'ssh', 'affinitygroup', 'volume', 'snapshot', 'vmsnapshot', 'guestnetwork',
796+
this.hasProjectId = ['vm', 'vmgroup', 'ssh', 'affinitygroup', 'userdata', 'volume', 'snapshot', 'vmsnapshot', 'guestnetwork',
797797
'vpc', 'securitygroups', 'publicip', 'vpncustomergateway', 'template', 'iso', 'event', 'kubernetes',
798798
'autoscalevmgroup', 'vnfapp'].includes(this.$route.name)
799799

0 commit comments

Comments
 (0)