diff --git a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsBaseData.java b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsBaseData.java index ad2608c425ef..e3b2796a1cbf 100644 --- a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsBaseData.java +++ b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsBaseData.java @@ -18,13 +18,13 @@ public class AzureMetricsBaseData { /** * Gets or sets the Metric name. */ - @JsonProperty(value = "metric") + @JsonProperty(value = "metric", required = true) private String metric; /** * Gets or sets the Metric namespace. */ - @JsonProperty(value = "namespace") + @JsonProperty(value = "namespace", required = true) private String namespace; /** @@ -37,7 +37,7 @@ public class AzureMetricsBaseData { * Gets or sets the list of time series data for the metric (one per unique * dimension combination). */ - @JsonProperty(value = "series") + @JsonProperty(value = "series", required = true) private List series; /** diff --git a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsData.java b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsData.java index d1062b9f318f..af9e30cee605 100644 --- a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsData.java +++ b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsData.java @@ -17,7 +17,7 @@ public class AzureMetricsData { /** * The baseData property. */ - @JsonProperty(value = "baseData") + @JsonProperty(value = "baseData", required = true) private AzureMetricsBaseData baseData; /** diff --git a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsDocument.java b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsDocument.java index 22201c7d8d76..1eec52e7dd14 100644 --- a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsDocument.java +++ b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureMetricsDocument.java @@ -17,13 +17,13 @@ public class AzureMetricsDocument { /** * Gets or sets Time property (in ISO 8601 format). */ - @JsonProperty(value = "time") + @JsonProperty(value = "time", required = true) private String time; /** * The data property. */ - @JsonProperty(value = "data") + @JsonProperty(value = "data", required = true) private AzureMetricsData data; /** diff --git a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureTimeSeriesData.java b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureTimeSeriesData.java index 981beef90e1d..bd91ee4f4aad 100644 --- a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureTimeSeriesData.java +++ b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/AzureTimeSeriesData.java @@ -24,26 +24,26 @@ public class AzureTimeSeriesData { /** * Gets or sets Min value. */ - @JsonProperty(value = "min") - private Double min; + @JsonProperty(value = "min", required = true) + private double min; /** * Gets or sets Max value. */ - @JsonProperty(value = "max") - private Double max; + @JsonProperty(value = "max", required = true) + private double max; /** * Gets or sets Sum value. */ - @JsonProperty(value = "sum") - private Double sum; + @JsonProperty(value = "sum", required = true) + private double sum; /** * Gets or sets Count value. */ - @JsonProperty(value = "count") - private Integer count; + @JsonProperty(value = "count", required = true) + private int count; /** * Get gets or sets dimension values. @@ -70,7 +70,7 @@ public AzureTimeSeriesData withDimValues(List dimValues) { * * @return the min value */ - public Double min() { + public double min() { return this.min; } @@ -80,7 +80,7 @@ public Double min() { * @param min the min value to set * @return the AzureTimeSeriesData object itself. */ - public AzureTimeSeriesData withMin(Double min) { + public AzureTimeSeriesData withMin(double min) { this.min = min; return this; } @@ -90,7 +90,7 @@ public AzureTimeSeriesData withMin(Double min) { * * @return the max value */ - public Double max() { + public double max() { return this.max; } @@ -100,7 +100,7 @@ public Double max() { * @param max the max value to set * @return the AzureTimeSeriesData object itself. */ - public AzureTimeSeriesData withMax(Double max) { + public AzureTimeSeriesData withMax(double max) { this.max = max; return this; } @@ -110,7 +110,7 @@ public AzureTimeSeriesData withMax(Double max) { * * @return the sum value */ - public Double sum() { + public double sum() { return this.sum; } @@ -120,7 +120,7 @@ public Double sum() { * @param sum the sum value to set * @return the AzureTimeSeriesData object itself. */ - public AzureTimeSeriesData withSum(Double sum) { + public AzureTimeSeriesData withSum(double sum) { this.sum = sum; return this; } @@ -130,7 +130,7 @@ public AzureTimeSeriesData withSum(Double sum) { * * @return the count value */ - public Integer count() { + public int count() { return this.count; } @@ -140,7 +140,7 @@ public Integer count() { * @param count the count value to set * @return the AzureTimeSeriesData object itself. */ - public AzureTimeSeriesData withCount(Integer count) { + public AzureTimeSeriesData withCount(int count) { this.count = count; return this; } diff --git a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/implementation/MetricsInner.java b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/implementation/MetricsInner.java index c15df8abe1e7..551450d13d15 100644 --- a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/implementation/MetricsInner.java +++ b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/implementation/MetricsInner.java @@ -55,7 +55,7 @@ public MetricsInner(Retrofit retrofit, AzureMetricsClientImpl client) { interface MetricsService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.monitor.Metrics create" }) @POST("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProvider}/{resourceTypeName}/{resourceName}/metrics") - Observable> create(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("resourceProvider") String resourceProvider, @Path("resourceTypeName") String resourceTypeName, @Path("resourceName") String resourceName, @Header("Content-Type") String contentType, @Header("Content-Length") Integer contentLength, @Body AzureMetricsDocument body, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> create(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("resourceProvider") String resourceProvider, @Path("resourceTypeName") String resourceTypeName, @Path("resourceName") String resourceName, @Header("Content-Type") String contentType, @Header("Content-Length") int contentLength, @Body AzureMetricsDocument body, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } @@ -67,120 +67,16 @@ interface MetricsService { * @param resourceProvider The ARM resource provider name * @param resourceTypeName The ARM resource type name * @param resourceName The ARM resource name - * @param body The Azure metrics document json payload - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws AzureMetricsResultInnerException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the AzureMetricsResultInner object if successful. - */ - public AzureMetricsResultInner create(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body) { - return createWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body).toBlocking().single().body(); - } - - /** - * **Post the metric values for a resource**. - * - * @param subscriptionId The azure subscription id - * @param resourceGroupName The ARM resource group name - * @param resourceProvider The ARM resource provider name - * @param resourceTypeName The ARM resource type name - * @param resourceName The ARM resource name - * @param body The Azure metrics document json payload - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture createAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body), serviceCallback); - } - - /** - * **Post the metric values for a resource**. - * - * @param subscriptionId The azure subscription id - * @param resourceGroupName The ARM resource group name - * @param resourceProvider The ARM resource provider name - * @param resourceTypeName The ARM resource type name - * @param resourceName The ARM resource name - * @param body The Azure metrics document json payload - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the AzureMetricsResultInner object - */ - public Observable createAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body) { - return createWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body).map(new Func1, AzureMetricsResultInner>() { - @Override - public AzureMetricsResultInner call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * **Post the metric values for a resource**. - * - * @param subscriptionId The azure subscription id - * @param resourceGroupName The ARM resource group name - * @param resourceProvider The ARM resource provider name - * @param resourceTypeName The ARM resource type name - * @param resourceName The ARM resource name - * @param body The Azure metrics document json payload - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the AzureMetricsResultInner object - */ - public Observable> createWithServiceResponseAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body) { - if (subscriptionId == null) { - throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."); - } - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (resourceProvider == null) { - throw new IllegalArgumentException("Parameter resourceProvider is required and cannot be null."); - } - if (resourceTypeName == null) { - throw new IllegalArgumentException("Parameter resourceTypeName is required and cannot be null."); - } - if (resourceName == null) { - throw new IllegalArgumentException("Parameter resourceName is required and cannot be null."); - } - if (body == null) { - throw new IllegalArgumentException("Parameter body is required and cannot be null."); - } - Validator.validate(body); - final String contentType = null; - final Integer contentLength = null; - return service.create(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, contentType, contentLength, body, this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - /** - * **Post the metric values for a resource**. - * - * @param subscriptionId The azure subscription id - * @param resourceGroupName The ARM resource group name - * @param resourceProvider The ARM resource provider name - * @param resourceTypeName The ARM resource type name - * @param resourceName The ARM resource name - * @param body The Azure metrics document json payload * @param contentType Supports application/json and application/x-ndjson * @param contentLength Content length of the payload + * @param body The Azure metrics document json payload * @throws IllegalArgumentException thrown if parameters fail the validation * @throws AzureMetricsResultInnerException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the AzureMetricsResultInner object if successful. */ - public AzureMetricsResultInner create(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, String contentType, Integer contentLength) { - return createWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body, contentType, contentLength).toBlocking().single().body(); + public AzureMetricsResultInner create(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, String contentType, int contentLength, AzureMetricsDocument body) { + return createWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, contentType, contentLength, body).toBlocking().single().body(); } /** @@ -191,15 +87,15 @@ public AzureMetricsResultInner create(String subscriptionId, String resourceGrou * @param resourceProvider The ARM resource provider name * @param resourceTypeName The ARM resource type name * @param resourceName The ARM resource name - * @param body The Azure metrics document json payload * @param contentType Supports application/json and application/x-ndjson * @param contentLength Content length of the payload + * @param body The Azure metrics document json payload * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture createAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, String contentType, Integer contentLength, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body, contentType, contentLength), serviceCallback); + public ServiceFuture createAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, String contentType, int contentLength, AzureMetricsDocument body, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, contentType, contentLength, body), serviceCallback); } /** @@ -210,14 +106,14 @@ public ServiceFuture createAsync(String subscriptionId, * @param resourceProvider The ARM resource provider name * @param resourceTypeName The ARM resource type name * @param resourceName The ARM resource name - * @param body The Azure metrics document json payload * @param contentType Supports application/json and application/x-ndjson * @param contentLength Content length of the payload + * @param body The Azure metrics document json payload * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the AzureMetricsResultInner object */ - public Observable createAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, String contentType, Integer contentLength) { - return createWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body, contentType, contentLength).map(new Func1, AzureMetricsResultInner>() { + public Observable createAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, String contentType, int contentLength, AzureMetricsDocument body) { + return createWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, contentType, contentLength, body).map(new Func1, AzureMetricsResultInner>() { @Override public AzureMetricsResultInner call(ServiceResponse response) { return response.body(); @@ -233,13 +129,13 @@ public AzureMetricsResultInner call(ServiceResponse res * @param resourceProvider The ARM resource provider name * @param resourceTypeName The ARM resource type name * @param resourceName The ARM resource name - * @param body The Azure metrics document json payload * @param contentType Supports application/json and application/x-ndjson * @param contentLength Content length of the payload + * @param body The Azure metrics document json payload * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the AzureMetricsResultInner object */ - public Observable> createWithServiceResponseAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, String contentType, Integer contentLength) { + public Observable> createWithServiceResponseAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, String contentType, int contentLength, AzureMetricsDocument body) { if (subscriptionId == null) { throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null."); } @@ -255,6 +151,9 @@ public Observable> createWithServiceRes if (resourceName == null) { throw new IllegalArgumentException("Parameter resourceName is required and cannot be null."); } + if (contentType == null) { + throw new IllegalArgumentException("Parameter contentType is required and cannot be null."); + } if (body == null) { throw new IllegalArgumentException("Parameter body is required and cannot be null."); }