mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
api/server: add project id/name in ssh keypair response (#7100)
This commit is contained in:
parent
792f8356e5
commit
37b2a4826d
@ -46,6 +46,14 @@ public class SSHKeyPairResponse extends BaseResponseWithAnnotations {
|
||||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the keypair owner")
|
||||
private String domain;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID)
|
||||
@Param(description = "the project id of the keypair owner")
|
||||
private String projectId;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT)
|
||||
@Param(description = "the project name of the keypair owner")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName("fingerprint")
|
||||
@Param(description = "Fingerprint of the public key")
|
||||
private String fingerprint;
|
||||
@ -106,4 +114,12 @@ public class SSHKeyPairResponse extends BaseResponseWithAnnotations {
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4556,7 +4556,13 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
sshkeyPair.getFingerprint(), sshkeyPair.getPrivateKey());
|
||||
}
|
||||
Account account = ApiDBUtils.findAccountById(sshkeyPair.getAccountId());
|
||||
response.setAccountName(account.getAccountName());
|
||||
if (account.getType() == Account.Type.PROJECT) {
|
||||
Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getAccountId());
|
||||
response.setProjectId(project.getUuid());
|
||||
response.setProjectName(project.getName());
|
||||
} else {
|
||||
response.setAccountName(account.getAccountName());
|
||||
}
|
||||
Domain domain = ApiDBUtils.findDomainById(sshkeyPair.getDomainId());
|
||||
response.setDomainId(domain.getUuid());
|
||||
response.setDomainName(domain.getName());
|
||||
|
||||
@ -576,7 +576,7 @@ export default {
|
||||
return fields
|
||||
},
|
||||
resourceType: 'SSHKeyPair',
|
||||
details: ['id', 'name', 'fingerprint', 'account', 'domain'],
|
||||
details: ['id', 'name', 'fingerprint', 'account', 'domain', 'project'],
|
||||
related: [{
|
||||
name: 'vm',
|
||||
title: 'label.instances',
|
||||
@ -608,11 +608,14 @@ export default {
|
||||
label: 'label.remove.ssh.key.pair',
|
||||
message: 'message.please.confirm.remove.ssh.key.pair',
|
||||
dataView: true,
|
||||
args: ['name', 'account', 'domainid'],
|
||||
args: ['name', 'account', 'domainid', 'projectid'],
|
||||
mapping: {
|
||||
name: {
|
||||
value: (record, params) => { return record.name }
|
||||
},
|
||||
projectid: {
|
||||
value: (record, params) => { return record.projectid }
|
||||
},
|
||||
account: {
|
||||
value: (record, params) => { return record.account }
|
||||
},
|
||||
@ -626,7 +629,10 @@ export default {
|
||||
return selection.map(x => {
|
||||
const data = record.filter(y => { return y.id === x })
|
||||
return {
|
||||
name: data[0].name, account: data[0].account, domainid: data[0].domainid
|
||||
name: data[0].name,
|
||||
account: data[0].account,
|
||||
domainid: data[0].domainid,
|
||||
projectid: data[0].projectid
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user