Skip to content

Commit d9984c0

Browse files
author
Julien Hervot de Mattos Vaz
committed
Fix QuotaSummaryCmd
1 parent b4db390 commit d9984c0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaSummaryCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class QuotaSummaryCmd extends BaseListCmd {
5151
QuotaService quotaService;
5252

5353
@ACL
54-
@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "ID of the account for which balance will be listed. Can not be specified with projectId.")
54+
@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "ID of the account for which balance will be listed. Can not be specified with projectId.", since = "4.21.0")
5555
private Long accountId;
5656

5757
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = false, description = "Optional, Account Id for which statement needs to be generated")
@@ -70,7 +70,7 @@ public class QuotaSummaryCmd extends BaseListCmd {
7070
private String accountStateToShow;
7171

7272
@ACL
73-
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Project Id for which balance will be listed. Can not be specified with accountId.")
73+
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Project Id for which balance will be listed. Can not be specified with accountId.", since = "4.21.0")
7474
private Long projectId;
7575

7676
@Override

plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,15 @@ public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO tariff, boole
188188
public Pair<List<QuotaSummaryResponse>, Integer> createQuotaSummaryResponse(QuotaSummaryCmd cmd) {
189189
Account caller = CallContext.current().getCallingAccount();
190190

191-
if (!accountTypesThatCanListAllQuotaSummaries.contains(caller.getType()) || !cmd.isListAll()) {
191+
if (cmd.getAccountId() != null && !cmd.isListAll() && accountTypesThatCanListAllQuotaSummaries.contains(caller.getType())) {
192+
return getQuotaSummaryResponse(cmd.getAccountId(), null, null, null, cmd);
193+
}
194+
195+
else if (cmd.getDomainId() != null && caller.getType() == Account.Type.DOMAIN_ADMIN && !cmd.isListAll()) {
196+
return getQuotaSummaryResponse(null, null, cmd.getDomainId(), null, cmd);
197+
}
198+
199+
else if (!accountTypesThatCanListAllQuotaSummaries.contains(caller.getType()) || !cmd.isListAll()) {
192200
return getQuotaSummaryResponse(caller.getAccountId(), null, null, null, cmd);
193201
}
194202

0 commit comments

Comments
 (0)