diff --git a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/implementation/AzureMetricsClientImpl.java b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/implementation/AzureMetricsClientImpl.java index 9827794762c1..d4eb8c260adf 100644 --- a/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/implementation/AzureMetricsClientImpl.java +++ b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/implementation/AzureMetricsClientImpl.java @@ -8,34 +8,15 @@ package com.microsoft.azure.monitor.implementation; -import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; -import com.microsoft.azure.monitor.AzureMetricsDocument; -import com.microsoft.azure.monitor.AzureMetricsResultInnerException; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.RestClient; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.Validator; -import java.io.IOException; -import okhttp3.ResponseBody; -import retrofit2.http.Body; -import retrofit2.http.Header; -import retrofit2.http.Headers; -import retrofit2.http.Path; -import retrofit2.http.POST; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; /** * Initializes a new instance of the AzureMetricsClientImpl class. */ public class AzureMetricsClientImpl extends AzureServiceClient { - /** The Retrofit service to perform REST calls. */ - private AzureMetricsClientService service; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; @@ -116,6 +97,19 @@ public AzureMetricsClientImpl withGenerateClientRequestId(boolean generateClient return this; } + /** + * The MetricsInner object to access its operations. + */ + private MetricsInner metrics; + + /** + * Gets the MetricsInner object to access its operations. + * @return the MetricsInner object. + */ + public MetricsInner metrics() { + return this.metrics; + } + /** * Initializes an instance of AzureMetricsClient client. * @@ -150,8 +144,8 @@ protected void initialize() { this.acceptLanguage = "en-US"; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; + this.metrics = new MetricsInner(restClient().retrofit(), this); this.azureClient = new AzureClient(this); - initializeService(); } /** @@ -163,281 +157,4 @@ protected void initialize() { public String userAgent() { return String.format("%s (%s, %s)", super.userAgent(), "AzureMetricsClient", "2018-09-01-preview"); } - - private void initializeService() { - service = restClient().retrofit().create(AzureMetricsClientService.class); - } - - /** - * The interface defining all the services for AzureMetricsClient to be - * used by Retrofit to perform actually REST calls. - */ - interface AzureMetricsClientService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.monitor.AzureMetricsClient azureMonitorCustomMetricsIngestionApi" }) - @POST("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProvider}/{resourceTypeName}/{resourceName}/metrics") - Observable> azureMonitorCustomMetricsIngestionApi(@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); - - } - - /** - * Ingestion API used by Azure custom metrics - Responsible of below operation - 1. Authorize the request - 2. Deserialize payload request body - 3. Perform validation of the payload - 4. Commits the payload for metrics ingestion. - * - * @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 - * @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 azureMonitorCustomMetricsIngestionApi(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body) { - return azureMonitorCustomMetricsIngestionApiWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body).toBlocking().single().body(); - } - - /** - * Ingestion API used by Azure custom metrics - Responsible of below operation - 1. Authorize the request - 2. Deserialize payload request body - 3. Perform validation of the payload - 4. Commits the payload for metrics ingestion. - * - * @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 azureMonitorCustomMetricsIngestionApiAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(azureMonitorCustomMetricsIngestionApiWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body), serviceCallback); - } - - /** - * Ingestion API used by Azure custom metrics - Responsible of below operation - 1. Authorize the request - 2. Deserialize payload request body - 3. Perform validation of the payload - 4. Commits the payload for metrics ingestion. - * - * @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 azureMonitorCustomMetricsIngestionApiAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body) { - return azureMonitorCustomMetricsIngestionApiWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body).map(new Func1, AzureMetricsResultInner>() { - @Override - public AzureMetricsResultInner call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Ingestion API used by Azure custom metrics - Responsible of below operation - 1. Authorize the request - 2. Deserialize payload request body - 3. Perform validation of the payload - 4. Commits the payload for metrics ingestion. - * - * @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> azureMonitorCustomMetricsIngestionApiWithServiceResponseAsync(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.azureMonitorCustomMetricsIngestionApi(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, contentType, contentLength, body, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = azureMonitorCustomMetricsIngestionApiDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - /** - * Ingestion API used by Azure custom metrics - Responsible of below operation - 1. Authorize the request - 2. Deserialize payload request body - 3. Perform validation of the payload - 4. Commits the payload for metrics ingestion. - * - * @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 - * @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 azureMonitorCustomMetricsIngestionApi(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, String contentType, Integer contentLength) { - return azureMonitorCustomMetricsIngestionApiWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body, contentType, contentLength).toBlocking().single().body(); - } - - /** - * Ingestion API used by Azure custom metrics - Responsible of below operation - 1. Authorize the request - 2. Deserialize payload request body - 3. Perform validation of the payload - 4. Commits the payload for metrics ingestion. - * - * @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 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 azureMonitorCustomMetricsIngestionApiAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, String contentType, Integer contentLength, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(azureMonitorCustomMetricsIngestionApiWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body, contentType, contentLength), serviceCallback); - } - - /** - * Ingestion API used by Azure custom metrics - Responsible of below operation - 1. Authorize the request - 2. Deserialize payload request body - 3. Perform validation of the payload - 4. Commits the payload for metrics ingestion. - * - * @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 - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the AzureMetricsResultInner object - */ - public Observable azureMonitorCustomMetricsIngestionApiAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, String contentType, Integer contentLength) { - return azureMonitorCustomMetricsIngestionApiWithServiceResponseAsync(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, body, contentType, contentLength).map(new Func1, AzureMetricsResultInner>() { - @Override - public AzureMetricsResultInner call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Ingestion API used by Azure custom metrics - Responsible of below operation - 1. Authorize the request - 2. Deserialize payload request body - 3. Perform validation of the payload - 4. Commits the payload for metrics ingestion. - * - * @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 - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the AzureMetricsResultInner object - */ - public Observable> azureMonitorCustomMetricsIngestionApiWithServiceResponseAsync(String subscriptionId, String resourceGroupName, String resourceProvider, String resourceTypeName, String resourceName, AzureMetricsDocument body, String contentType, Integer contentLength) { - 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); - return service.azureMonitorCustomMetricsIngestionApi(subscriptionId, resourceGroupName, resourceProvider, resourceTypeName, resourceName, contentType, contentLength, body, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = azureMonitorCustomMetricsIngestionApiDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse azureMonitorCustomMetricsIngestionApiDelegate(Response response) throws AzureMetricsResultInnerException, IOException, IllegalArgumentException { - return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(AzureMetricsResultInnerException.class) - .build(response); - } - } 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 new file mode 100644 index 000000000000..c15df8abe1e7 --- /dev/null +++ b/monitor/data-plane/src/main/java/com/microsoft/azure/monitor/implementation/MetricsInner.java @@ -0,0 +1,283 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.monitor.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.monitor.AzureMetricsDocument; +import com.microsoft.azure.monitor.AzureMetricsResultInnerException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Metrics. + */ +public class MetricsInner { + /** The Retrofit service to perform REST calls. */ + private MetricsService service; + /** The service client containing this operation class. */ + private AzureMetricsClientImpl client; + + /** + * Initializes an instance of MetricsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public MetricsInner(Retrofit retrofit, AzureMetricsClientImpl client) { + this.service = retrofit.create(MetricsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Metrics to be + * used by Retrofit to perform actually REST calls. + */ + 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); + + } + + /** + * **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 + * @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 + * @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(); + } + + /** + * **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 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); + } + + /** + * **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 + * @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>() { + @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 + * @param contentType Supports application/json and application/x-ndjson + * @param contentLength Content length of the 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) { + 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); + 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); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws AzureMetricsResultInnerException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(AzureMetricsResultInnerException.class) + .build(response); + } + +}