Skip to content

Commit 8a3871f

Browse files
committed
sslcert: add account and domainid to api
streamline ssl cert list api, deprecate accountid
1 parent a9dc8bf commit 8a3871f

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/ListSslCertsCmd.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.cloudstack.api.BaseCmd;
2727
import org.apache.cloudstack.api.Parameter;
2828
import org.apache.cloudstack.api.response.AccountResponse;
29+
import org.apache.cloudstack.api.response.DomainResponse;
2930
import org.apache.cloudstack.api.response.FirewallRuleResponse;
3031
import org.apache.cloudstack.api.response.ListResponse;
3132
import org.apache.cloudstack.api.response.ProjectResponse;
@@ -50,9 +51,15 @@ public class ListSslCertsCmd extends BaseCmd {
5051
@Parameter(name = ApiConstants.CERTIFICATE_ID, type = CommandType.UUID, entityType = SslCertResponse.class, required = false, description = "ID of SSL certificate")
5152
private Long certId;
5253

53-
@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, required = false, description = "Account ID")
54+
@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, required = false, description = "Account ID, deprecated: use " + ApiConstants.ACCOUNT + " and " + ApiConstants.DOMAIN_ID + " instead")
5455
private Long accountId;
5556

57+
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, since = "4.24", description = "Account owning the SSL certificate")
58+
private String accountName;
59+
60+
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, since = "4.24", entityType = DomainResponse.class, description = "Domain ID of the account owning the SSL certificate")
61+
private Long domainId;
62+
5663
@Parameter(name = ApiConstants.LBID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = false, description = "Load balancer rule ID")
5764
private Long lbId;
5865

@@ -67,6 +74,7 @@ public Long getCertId() {
6774
return certId;
6875
}
6976

77+
@Deprecated
7078
public Long getAccountId() {
7179
return accountId;
7280
}
@@ -79,6 +87,14 @@ public Long getProjectId() {
7987
return projectId;
8088
}
8189

90+
public String getAccountName() {
91+
return accountName;
92+
}
93+
94+
public Long getDomainId() {
95+
return domainId;
96+
}
97+
8298
/////////////////////////////////////////////////////
8399
/////////////// API Implementation///////////////////
84100
/////////////////////////////////////////////////////

server/src/main/java/org/apache/cloudstack/network/ssl/CertServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,15 @@ public List<SslCertResponse> listSslCerts(final ListSslCertsCmd listSslCertCmd)
198198
final CallContext ctx = CallContext.current();
199199
final Account caller = ctx.getCallingAccount();
200200

201+
Account owner = null;
202+
if (StringUtils.isNotEmpty(listSslCertCmd.getAccountName()) && listSslCertCmd.getDomainId() != null || listSslCertCmd.getProjectId() != null) {
203+
owner = _accountMgr.finalizeOwner(caller, listSslCertCmd.getAccountName(), listSslCertCmd.getDomainId(), listSslCertCmd.getProjectId());
204+
} else {
205+
owner = caller;
206+
}
207+
201208
final Long certId = listSslCertCmd.getCertId();
202-
final Long accountId = listSslCertCmd.getAccountId() != null ? listSslCertCmd.getAccountId() : caller.getAccountId();
209+
final Long accountId = listSslCertCmd.getAccountId() != null ? listSslCertCmd.getAccountId() : owner.getId();
203210
final Long lbRuleId = listSslCertCmd.getLbId();
204211
final Long projectId = listSslCertCmd.getProjectId();
205212

0 commit comments

Comments
 (0)