Fix bug JAH-1455
Make metric name mandatory for measurement-list and metric-statistics. Change-Id: I3535a6fe052071fd1733102630e511210eef386e
This commit is contained in:
parent
f93ec0db47
commit
1c934dcb80
|
@ -1038,7 +1038,7 @@ If users do not wish to see measurements for a single metric, but would prefer t
|
|||
None.
|
||||
|
||||
#### Query Parameters
|
||||
* name (string(255), optional) - A metric name to filter metrics by.
|
||||
* name (string(255), required) - A metric name to filter metrics by.
|
||||
* dimensions (string, optional) - A dictionary to filter metrics by specified as a comma separated array of (key, value) pairs as `key1:value1,key2:value2, ...`
|
||||
* start_time (string, required) - The start time in ISO 8601 combined date and time format in UTC.
|
||||
* end_time (string, optional) - The end time in ISO 8601 combined date and time format in UTC.
|
||||
|
|
|
@ -152,7 +152,7 @@ public final class Validation {
|
|||
/**
|
||||
* @throws WebApplicationException if the {@code value} is null or empty.
|
||||
*/
|
||||
public static void validateNotNullOrEmpty(String value, String parameterName) {
|
||||
public static <T extends String> void validateNotNullOrEmpty(T value, String parameterName) {
|
||||
if (Strings.isNullOrEmpty(value))
|
||||
throw Exceptions.unprocessableEntity("%s is required", parameterName);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ public class MeasurementResource {
|
|||
throws Exception {
|
||||
|
||||
// Validate query parameters
|
||||
Validation.validateNotNullOrEmpty(name, "name");
|
||||
DateTime startTime = Validation.parseAndValidateDate(startTimeStr, "start_time", true);
|
||||
DateTime endTime = Validation.parseAndValidateDate(endTimeStr, "end_time", false);
|
||||
Validation.validateTimes(startTime, endTime);
|
||||
|
|
|
@ -73,6 +73,7 @@ public class StatisticResource {
|
|||
@QueryParam("merge_metrics") Boolean mergeMetricsFlag) throws Exception {
|
||||
|
||||
// Validate query parameters
|
||||
Validation.validateNotNullOrEmpty(name, "name");
|
||||
DateTime startTime = Validation.parseAndValidateDate(startTimeStr, "start_time", true);
|
||||
DateTime endTime = Validation.parseAndValidateDate(endTimeStr, "end_time", false);
|
||||
Validation.validateTimes(startTime, endTime);
|
||||
|
|
Loading…
Reference in New Issue