This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.19 by this push:
new 08d9d06d453 api,server,ui: add project ID and name to UserDataResponse
(#8656)
08d9d06d453 is described below
commit 08d9d06d45316edb99ce3aba481de188b2baa7e0
Author: Wei Zhou <[email protected]>
AuthorDate: Mon Mar 25 14:45:34 2024 +0100
api,server,ui: add project ID and name to UserDataResponse (#8656)
* api,server,ui: add project ID and name to UserDataResponse
* Update: add since
---
.../cloudstack/api/response/UserDataResponse.java | 20 +++++++++++++++++++-
.../main/java/com/cloud/api/ApiResponseHelper.java | 7 +------
ui/src/config/section/compute.js | 5 +++++
ui/src/views/AutogenView.vue | 2 +-
4 files changed, 26 insertions(+), 8 deletions(-)
diff --git
a/api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java
b/api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java
index bbe27f84520..e69094c8f80 100644
--- a/api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java
+++ b/api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java
@@ -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;
}
diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java
b/server/src/main/java/com/cloud/api/ApiResponseHelper.java
index e2b72f6175c..6d66da43c37 100644
--- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java
@@ -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;
diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js
index f1b3e1b2c99..bd18535f380 100644
--- a/ui/src/config/section/compute.js
+++ b/ui/src/config/section/compute.js
@@ -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
},
diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue
index bf1c42d4c05..77ee73d700c 100644
--- a/ui/src/views/AutogenView.vue
+++ b/ui/src/views/AutogenView.vue
@@ -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)