Adjusts/fixes in quota tariff APIs (#7146)

This commit is contained in:
Daniel Augusto Veronezi Salvador 2023-02-01 11:05:30 -03:00 committed by GitHub
parent 954fed6ed6
commit 9c4b3a6847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 59 deletions

View File

@ -34,7 +34,7 @@ import javax.inject.Inject;
import java.util.Date;
@APICommand(name = "quotaTariffCreate", responseObject = QuotaTariffResponse.class, description = "Creates a quota tariff for a resource.", since = "4.17.0.0",
@APICommand(name = "quotaTariffCreate", responseObject = QuotaTariffResponse.class, description = "Creates a quota tariff for a resource.", since = "4.18.0.0",
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin})
public class QuotaTariffCreateCmd extends BaseCmd {
protected Logger logger = Logger.getLogger(getClass());
@ -42,10 +42,10 @@ public class QuotaTariffCreateCmd extends BaseCmd {
@Inject
QuotaResponseBuilder responseBuilder;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Quota tariff's name", length = 32)
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Quota tariff's name", length = 65535)
private String name;
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Quota tariff's description.", length = 256)
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Quota tariff's description.", length = 65535)
private String description;
@Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, required = true, description = "Integer value for the usage type of the resource.")
@ -54,8 +54,10 @@ public class QuotaTariffCreateCmd extends BaseCmd {
@Parameter(name = "value", type = CommandType.DOUBLE, required = true, description = "The quota tariff value of the resource as per the default unit.")
private Double value;
@Parameter(name = ApiConstants.ACTIVATION_RULE, type = CommandType.STRING, description = "Quota tariff's activation rule.",
length = 65535)
@Parameter(name = ApiConstants.ACTIVATION_RULE, type = CommandType.STRING, description = "Quota tariff's activation rule. It can receive a JS script that results in either " +
"a boolean or a numeric value: if it results in a boolean value, the tariff value will be applied according to the result; if it results in a numeric value, the " +
"numeric value will be applied; if the result is neither a boolean nor a numeric value, the tariff will not be applied. If the rule is not informed, the tariff " +
"value will be applied.", length = 65535)
private String activationRule;
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "The effective start date on/after which the quota tariff is effective. Use yyyy-MM-dd as"
@ -66,10 +68,6 @@ public class QuotaTariffCreateCmd extends BaseCmd {
+ " endDate=2009-06-03.")
private Date endDate;
public QuotaTariffCreateCmd() {
super();
}
@Override
public void execute() {
QuotaTariffVO result = responseBuilder.createQuotaTariff(this);
@ -108,10 +106,6 @@ public class QuotaTariffCreateCmd extends BaseCmd {
return usageType;
}
public void setUsageType(Integer usageType) {
this.usageType = usageType;
}
public Double getValue() {
return value;
}
@ -124,10 +118,6 @@ public class QuotaTariffCreateCmd extends BaseCmd {
return activationRule;
}
public void setActivationRule(String activationRule) {
this.activationRule = activationRule;
}
public Date getStartDate() {
return startDate;
}

View File

@ -32,32 +32,24 @@ import org.apache.log4j.Logger;
import javax.inject.Inject;
@APICommand(name = "quotaTariffDelete", description = "Marks a quota tariff as removed.", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false, since = "4.17.0.0", authorized = {RoleType.Admin})
responseHasSensitiveInfo = false, since = "4.18.0.0", authorized = {RoleType.Admin})
public class QuotaTariffDeleteCmd extends BaseCmd {
protected Logger logger = Logger.getLogger(getClass());
@Inject
QuotaResponseBuilder responseBuilder;
@Parameter(name = ApiConstants.UUID, type = BaseCmd.CommandType.STRING, required = true, entityType = QuotaTariffResponse.class,
description = "UUID of the quota tariff", validations = {ApiArgValidator.UuidString})
private String quotaTariffUuid;
@Parameter(name = ApiConstants.ID, type = BaseCmd.CommandType.STRING, required = true, entityType = QuotaTariffResponse.class,
description = "ID of the quota tariff", validations = {ApiArgValidator.UuidString})
private String id;
public String getQuotaTariffUuid() {
return quotaTariffUuid;
}
public void setQuotaTariffId(String quotaTariffUuid) {
this.quotaTariffUuid = quotaTariffUuid;
}
public QuotaTariffDeleteCmd() {
super();
public String getId() {
return id;
}
@Override
public void execute() {
boolean result = responseBuilder.deleteQuotaTariff(getQuotaTariffUuid());
boolean result = responseBuilder.deleteQuotaTariff(getId());
SuccessResponse response = new SuccessResponse(getCommandName());
response.setSuccess(result);
setResponseObject(response);

View File

@ -43,22 +43,22 @@ public class QuotaTariffListCmd extends BaseListCmd {
@Inject
QuotaResponseBuilder _responseBuilder;
@Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, required = false, description = "Usage type of the resource")
@Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, description = "Usage type of the resource")
private Integer usageType;
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, required = false, description = "The start date of the quota tariff. Use yyyy-MM-dd as the date format, "
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "The start date of the quota tariff. Use yyyy-MM-dd as the date format, "
+ "e.g. startDate=2009-06-03.")
private Date effectiveDate;
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, required = false, description = "The end date of the quota tariff. Use yyyy-MM-dd as the date format, e.g. "
+ "endDate=2021-11-03.")
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "The end date of the quota tariff. Use yyyy-MM-dd as the date format, e.g. "
+ "endDate=2021-11-03.", since = "4.18.0.0")
private Date endDate;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = false, description = "The name of the quota tariff.")
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the quota tariff.", since = "4.18.0.0")
private String name;
@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, required = false, description = "False will list only not removed quota tariffs. If set to True, we will "
+ "list all, including the removed ones. The default is false.")
@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "False will list only not removed quota tariffs. If set to True, we will "
+ "list all, including the removed ones. The default is false.", since = "4.18.0.0")
private boolean listAll = false;
public QuotaTariffListCmd() {
@ -69,7 +69,7 @@ public class QuotaTariffListCmd extends BaseListCmd {
public void execute() {
final Pair<List<QuotaTariffVO>, Integer> result = _responseBuilder.listQuotaTariffPlans(this);
final List<QuotaTariffResponse> responses = new ArrayList<QuotaTariffResponse>();
final List<QuotaTariffResponse> responses = new ArrayList<>();
s_logger.trace(String.format("Adding quota tariffs [%s] to response of API quotaTariffList.", ReflectionToStringBuilderUtils.reflectCollection(responses)));
@ -77,7 +77,7 @@ public class QuotaTariffListCmd extends BaseListCmd {
responses.add(_responseBuilder.createQuotaTariffResponse(resource));
}
final ListResponse<QuotaTariffResponse> response = new ListResponse<QuotaTariffResponse>();
final ListResponse<QuotaTariffResponse> response = new ListResponse<>();
response.setResponses(responses, result.second());
response.setResponseName(getCommandName());
setResponseObject(response);
@ -89,17 +89,13 @@ public class QuotaTariffListCmd extends BaseListCmd {
}
public Date getEffectiveDate() {
return effectiveDate ==null ? null : new Date(effectiveDate.getTime());
return effectiveDate;
}
public Integer getUsageType() {
return usageType;
}
public void setUsageType(Integer usageType) {
this.usageType = usageType;
}
public Date getEndDate() {
return endDate;
}

View File

@ -42,37 +42,37 @@ public class QuotaTariffUpdateCmd extends BaseCmd {
@Inject
QuotaResponseBuilder _responseBuilder;
@Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, description = "Integer value for the usage type of the resource")
@Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, description = "DEPRECATED. Integer value for the usage type of the resource")
private Integer usageType;
@Parameter(name = ApiConstants.VALUE, type = CommandType.DOUBLE, description = "The quota tariff value of the resource as per the default unit.")
private Double value;
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "The effective start date on/after which the quota tariff is effective. Use yyyy-MM-dd as"
+ " the date format, e.g. startDate=2009-06-03.")
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "DEPRECATED. The effective start date on/after which the quota tariff is effective. " +
"Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.")
private Date startDate;
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "The end date of the quota tariff. Use yyyy-MM-dd as the date format, e.g."
+ " endDate=2009-06-03.")
+ " endDate=2009-06-03.", since = "4.18.0.0")
private Date endDate;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Quota tariff's name")
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Quota tariff's name", length = 65535, since = "4.18.0.0")
private String name;
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Quota tariff's description. Inform empty to remove the description.")
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Quota tariff's description. Inform empty to remove the description.", length = 65535,
since = "4.18.0.0")
private String description;
@Parameter(name = ApiConstants.ACTIVATION_RULE, type = CommandType.STRING, description = "Quota tariff's activation rule. Inform empty to remove the activation rule.")
@Parameter(name = ApiConstants.ACTIVATION_RULE, type = CommandType.STRING, description = "Quota tariff's activation rule. It can receive a JS script that results in either " +
"a boolean or a numeric value: if it results in a boolean value, the tariff value will be applied according to the result; if it results in a numeric value, the " +
"numeric value will be applied; if the result is neither a boolean nor a numeric value, the tariff will not be applied. If the rule is not informed, the tariff " +
"value will be applied. Inform empty to remove the activation rule.", length = 65535, since = "4.18.0.0")
private String activationRule;
public Integer getUsageType() {
return usageType;
}
public void setUsageType(Integer usageType) {
this.usageType = usageType;
}
public Double getValue() {
return value;
}
@ -82,11 +82,11 @@ public class QuotaTariffUpdateCmd extends BaseCmd {
}
public Date getStartDate() {
return startDate == null ? null : new Date(startDate.getTime());
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate == null ? null : new Date(startDate.getTime());
this.startDate = startDate;
}
public Date getEndDate() {