Skip to content

Commit abfc638

Browse files
committed
Address reviews
1 parent 2ae0806 commit abfc638

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
import javax.inject.Inject;
4040

41-
@APICommand(name = "quotaSummary", responseObject = QuotaSummaryResponse.class, description = "Lists Quota balance summary of Accounts.", since = "4.7.0",
41+
@APICommand(name = "quotaSummary", responseObject = QuotaSummaryResponse.class, description = "Lists Quota balance summary of Accounts and Projects.", since = "4.7.0",
4242
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, httpMethod = "GET")
4343
public class QuotaSummaryCmd extends BaseListCmd {
4444

@@ -49,19 +49,19 @@ public class QuotaSummaryCmd extends BaseListCmd {
4949
QuotaService quotaService;
5050

5151
@ACL
52-
@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.23.0")
52+
@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.23.0")
5353
private Long accountId;
5454

5555
@ACL
56-
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = false, description = "Optional, Account Id for which statement needs to be generated")
56+
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = false, description = "Name of the Account for which balance will be listed.")
5757
private String accountName;
5858

5959
@ACL
60-
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = false, entityType = DomainResponse.class, description = "Optional, If domain Id is given and the caller is domain admin then the statement is generated for domain.")
60+
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = false, entityType = DomainResponse.class, description = "ID of the Domain for which balance will be listed. May be used individually or with accountname.")
6161
private Long domainId;
6262

6363
@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "False (default) lists the Quota balance summary for calling Account. True lists balance summary for " +
64-
"Accounts which the caller has access.")
64+
"Accounts which the caller has access. If domain ID is informed, this parameter is considered as true.")
6565
private Boolean listAll;
6666

6767
@Parameter(name = ApiConstants.ACCOUNT_STATE_TO_SHOW, type = CommandType.STRING, description = "Possible values are [ALL, ACTIVE, REMOVED]. ALL will list summaries for " +
@@ -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 = "ID of the project for which balance will be listed. Can not be specified with accountId.", since = "4.23.0")
73+
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "ID of the Project for which balance will be listed. Can not be specified with accountId.", since = "4.23.0")
7474
private Long projectId;
7575

7676
@Override

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import com.cloud.utils.exception.CloudRuntimeException;
5252
import org.apache.cloudstack.api.ApiErrorCode;
5353
import org.apache.cloudstack.api.ServerApiException;
54-
5554
import org.apache.cloudstack.api.command.QuotaBalanceCmd;
5655
import org.apache.cloudstack.api.command.QuotaConfigureEmailCmd;
5756
import org.apache.cloudstack.api.command.QuotaCreditsListCmd;
@@ -217,7 +216,6 @@ protected Pair<List<QuotaSummaryResponse>, Integer> getQuotaSummaryResponseWithL
217216

218217
Long accountId = cmd.getEntityOwnerId();
219218
if (accountId == -1) {
220-
// No specific account was provided
221219
accountId = cmd.isListAll() ? null : caller.getAccountId();
222220
}
223221

@@ -245,9 +243,15 @@ protected String getDomainPathByDomainIdForDomainAdmin(Account caller) {
245243
return domain.getPath();
246244
}
247245

246+
/**
247+
* Returns a <code>List</code> of <code>QuotaSummaryResponse</code> based on the provided parameters.
248+
* @param accountId ID of the Account to return the summaries for. If <code>-1</code>, either because no specific
249+
* Account was provided, or list all is disabled, then the summary is generated for the calling Account.
250+
* @param domainId ID of the Domain to return the summaries for.
251+
* @param domainPath path of the Domain to return the summaries for.
252+
*/
248253
protected Pair<List<QuotaSummaryResponse>, Integer> getQuotaSummaryResponse(Long accountId, Long domainId, String domainPath, QuotaSummaryCmd cmd) {
249254
if (accountId != null && accountId == -1) {
250-
// Either no specific account as provided, or list all is disabled
251255
accountId = CallContext.current().getCallingAccountId();
252256
}
253257

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public class QuotaSummaryResponse extends BaseResponse {
5353
private State state;
5454

5555
@SerializedName("domainremoved")
56-
@Param(description = "If the domain is removed or not", since = "4.21.0")
56+
@Param(description = "If the domain is removed or not", since = "4.23.0")
5757
private boolean domainRemoved;
5858

5959
@SerializedName("accountremoved")
60-
@Param(description = "If the account is removed or not", since = "4.21.0")
60+
@Param(description = "If the account is removed or not", since = "4.23.0")
6161
private boolean accountRemoved;
6262

6363
@SerializedName("quota")
@@ -81,15 +81,15 @@ public class QuotaSummaryResponse extends BaseResponse {
8181
private boolean quotaEnabled;
8282

8383
@SerializedName("projectname")
84-
@Param(description = "Name of the project", since = "4.21.0")
84+
@Param(description = "Name of the project", since = "4.23.0")
8585
private String projectName;
8686

8787
@SerializedName("projectid")
88-
@Param(description = "Project's id", since = "4.21.0")
88+
@Param(description = "Project's id", since = "4.23.0")
8989
private String projectId;
9090

9191
@SerializedName("projectremoved")
92-
@Param(description = "Whether the project is removed or not", since = "4.21.0")
92+
@Param(description = "Whether the project is removed or not", since = "4.23.0")
9393
private Boolean projectRemoved;
9494

9595
public String getAccountId() {

server/src/main/java/com/cloud/user/AccountManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3904,7 +3904,7 @@ public Long finalizeAccountId(Long accountId, String accountName, Long domainId,
39043904
}
39053905

39063906
if (accountName == null && domainId == null) {
3907-
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, String.format("Either %s or %s is required.", ApiConstants.ACCOUNT_ID, ApiConstants.PROJECT_ID));
3907+
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, String.format("Either %s or %s must be informed.", ApiConstants.ACCOUNT_ID, ApiConstants.PROJECT_ID));
39083908
}
39093909

39103910
try {

0 commit comments

Comments
 (0)