-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Create API to list Quota credits #9590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a38619c
3f2ab9d
2138f36
35c792f
4ce5064
542c4c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| //Licensed to the Apache Software Foundation (ASF) under one | ||
| //or more contributor license agreements. See the NOTICE file | ||
| //distributed with this work for additional information | ||
| //regarding copyright ownership. The ASF licenses this file | ||
| //to you under the Apache License, Version 2.0 (the | ||
| //"License"); you may not use this file except in compliance | ||
| //with the License. You may obtain a copy of the License at | ||
| // | ||
| //http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| //Unless required by applicable law or agreed to in writing, | ||
| //software distributed under the License is distributed on an | ||
| //"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| //KIND, either express or implied. See the License for the | ||
| //specific language governing permissions and limitations | ||
| //under the License. | ||
| package org.apache.cloudstack.api.command; | ||
|
|
||
| import com.cloud.utils.Pair; | ||
|
|
||
| import org.apache.cloudstack.api.ACL; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.response.AccountResponse; | ||
| import org.apache.cloudstack.api.response.DomainResponse; | ||
| import org.apache.cloudstack.api.response.ListResponse; | ||
| import org.apache.cloudstack.api.response.QuotaCreditsResponse; | ||
| import org.apache.cloudstack.api.response.QuotaResponseBuilder; | ||
| import org.apache.commons.lang3.ObjectUtils; | ||
| import org.apache.commons.lang3.time.DateUtils; | ||
|
|
||
| import java.util.Calendar; | ||
| import java.util.Date; | ||
| import java.util.List; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = "quotaCreditsList", responseObject = QuotaCreditsResponse.class, description = "Lists quota credits of an account.", since = "4.20.0", | ||
| requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) | ||
| public class QuotaCreditsListCmd extends BaseCmd { | ||
|
|
||
| @Inject | ||
| QuotaResponseBuilder quotaResponseBuilder; | ||
|
|
||
| @ACL | ||
| @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "ID of the account for which the credit statement will be generated.") | ||
| private Long accountId; | ||
|
|
||
| @ACL | ||
| @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "ID of the domain for which credit statement will be generated. " + | ||
| "Available only for administrators.") | ||
| private Long domainId; | ||
|
|
||
| @Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "End date of the credit statement. If not provided, the current date will be " + | ||
| "considered as the end date. " + ApiConstants.PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS) | ||
| private Date endDate; | ||
|
|
||
| @Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "Start date of the credit statement. If not provided, the first day of the current month " + | ||
| "will be considered as the start date. " + ApiConstants.PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS) | ||
| private Date startDate; | ||
|
|
||
| @Parameter(name = ApiConstants.IS_RECURSIVE, type = CommandType.BOOLEAN, description = "Whether to generate the credit statement for the provided domain and its children. " + | ||
| "Defaults to false.") | ||
| private Boolean recursive = false; | ||
|
|
||
| public Long getAccountId() { | ||
| return accountId; | ||
| } | ||
|
|
||
| public void setAccountId(Long accountId) { | ||
| this.accountId = accountId; | ||
| } | ||
|
|
||
| public Long getDomainId() { | ||
| return domainId; | ||
| } | ||
|
|
||
| public void setDomainId(Long domainId) { | ||
| this.domainId = domainId; | ||
| } | ||
|
|
||
| public Date getEndDate() { | ||
| return ObjectUtils.defaultIfNull(endDate, new Date()); | ||
| } | ||
|
|
||
| public void setEndDate(Date endDate) { | ||
| this.endDate = endDate; | ||
| } | ||
|
|
||
| public Date getStartDate() { | ||
| return ObjectUtils.defaultIfNull(startDate, DateUtils.truncate(new Date(), Calendar.MONTH)); | ||
| } | ||
|
|
||
| public void setStartDate(Date startDate) { | ||
| this.startDate = startDate; | ||
| } | ||
|
|
||
| public Boolean getRecursive() { | ||
| return recursive; | ||
| } | ||
|
|
||
| public void setRecursive(Boolean recursive) { | ||
| this.recursive = recursive; | ||
| } | ||
|
Check warning on line 106 in plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaCreditsListCmd.java
|
||
|
|
||
| @Override | ||
| public void execute() { | ||
| Pair<List<QuotaCreditsResponse>, Integer> responses = quotaResponseBuilder.createQuotaCreditsListResponse(this); | ||
| ListResponse<QuotaCreditsResponse> response = new ListResponse<>(); | ||
| response.setResponses(responses.first(), responses.second()); | ||
| response.setResponseName(getCommandName()); | ||
| setResponseObject(response); | ||
| } | ||
|
Check warning on line 115 in plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaCreditsListCmd.java
|
||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return -1; | ||
| } | ||
|
Check warning on line 120 in plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaCreditsListCmd.java
|
||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.