![JAR search and dependency download from the Maven repository](/logo.png)
com.microsoft.azure.management.monitor.implementation.DiagnosticSettingsInner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-mgmt-monitor Show documentation
Show all versions of azure-mgmt-monitor Show documentation
This package contains Microsoft Azure Monitor SDK.
/**
* 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.management.monitor.implementation;
import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete;
import retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.management.monitor.ErrorResponseException;
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.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.HTTP;
import retrofit2.http.Path;
import retrofit2.http.PUT;
import retrofit2.http.Query;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;
/**
* An instance of this class provides access to all the operations defined
* in DiagnosticSettings.
*/
public class DiagnosticSettingsInner implements InnerSupportsDelete {
/** The Retrofit service to perform REST calls. */
private DiagnosticSettingsService service;
/** The service client containing this operation class. */
private MonitorManagementClientImpl client;
/**
* Initializes an instance of DiagnosticSettingsInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public DiagnosticSettingsInner(Retrofit retrofit, MonitorManagementClientImpl client) {
this.service = retrofit.create(DiagnosticSettingsService.class);
this.client = client;
}
/**
* The interface defining all the services for DiagnosticSettings to be
* used by Retrofit to perform actually REST calls.
*/
interface DiagnosticSettingsService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.DiagnosticSettings get" })
@GET("{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}")
Observable> get(@Path(value = "resourceUri", encoded = true) String resourceUri, @Path("name") String name, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.DiagnosticSettings createOrUpdate" })
@PUT("{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}")
Observable> createOrUpdate(@Path(value = "resourceUri", encoded = true) String resourceUri, @Path("name") String name, @Query("api-version") String apiVersion, @Body DiagnosticSettingsResourceInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.DiagnosticSettings delete" })
@HTTP(path = "{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}", method = "DELETE", hasBody = true)
Observable> delete(@Path(value = "resourceUri", encoded = true) String resourceUri, @Path("name") String name, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.DiagnosticSettings list" })
@GET("{resourceUri}/providers/microsoft.insights/diagnosticSettings")
Observable> list(@Path(value = "resourceUri", encoded = true) String resourceUri, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
}
/**
* Gets the active diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the DiagnosticSettingsResourceInner object if successful.
*/
public DiagnosticSettingsResourceInner get(String resourceUri, String name) {
return getWithServiceResponseAsync(resourceUri, name).toBlocking().single().body();
}
/**
* Gets the active diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @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 getAsync(String resourceUri, String name, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceUri, name), serviceCallback);
}
/**
* Gets the active diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the DiagnosticSettingsResourceInner object
*/
public Observable getAsync(String resourceUri, String name) {
return getWithServiceResponseAsync(resourceUri, name).map(new Func1, DiagnosticSettingsResourceInner>() {
@Override
public DiagnosticSettingsResourceInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Gets the active diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the DiagnosticSettingsResourceInner object
*/
public Observable> getWithServiceResponseAsync(String resourceUri, String name) {
if (resourceUri == null) {
throw new IllegalArgumentException("Parameter resourceUri is required and cannot be null.");
}
if (name == null) {
throw new IllegalArgumentException("Parameter name is required and cannot be null.");
}
final String apiVersion = "2017-05-01-preview";
return service.get(resourceUri, name, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = getDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse getDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
/**
* Creates or updates diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @param parameters Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the DiagnosticSettingsResourceInner object if successful.
*/
public DiagnosticSettingsResourceInner createOrUpdate(String resourceUri, String name, DiagnosticSettingsResourceInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceUri, name, parameters).toBlocking().single().body();
}
/**
* Creates or updates diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @param parameters Parameters supplied to the operation.
* @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 createOrUpdateAsync(String resourceUri, String name, DiagnosticSettingsResourceInner parameters, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceUri, name, parameters), serviceCallback);
}
/**
* Creates or updates diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @param parameters Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the DiagnosticSettingsResourceInner object
*/
public Observable createOrUpdateAsync(String resourceUri, String name, DiagnosticSettingsResourceInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceUri, name, parameters).map(new Func1, DiagnosticSettingsResourceInner>() {
@Override
public DiagnosticSettingsResourceInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Creates or updates diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @param parameters Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the DiagnosticSettingsResourceInner object
*/
public Observable> createOrUpdateWithServiceResponseAsync(String resourceUri, String name, DiagnosticSettingsResourceInner parameters) {
if (resourceUri == null) {
throw new IllegalArgumentException("Parameter resourceUri is required and cannot be null.");
}
if (name == null) {
throw new IllegalArgumentException("Parameter name is required and cannot be null.");
}
if (parameters == null) {
throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
}
Validator.validate(parameters);
final String apiVersion = "2017-05-01-preview";
return service.createOrUpdate(resourceUri, name, apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = createOrUpdateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse createOrUpdateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
/**
* Deletes existing diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
*/
public void delete(String resourceUri, String name) {
deleteWithServiceResponseAsync(resourceUri, name).toBlocking().single().body();
}
/**
* Deletes existing diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @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 deleteAsync(String resourceUri, String name, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceUri, name), serviceCallback);
}
/**
* Deletes existing diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable deleteAsync(String resourceUri, String name) {
return deleteWithServiceResponseAsync(resourceUri, name).map(new Func1, Void>() {
@Override
public Void call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Deletes existing diagnostic settings for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @param name The name of the diagnostic setting.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable> deleteWithServiceResponseAsync(String resourceUri, String name) {
if (resourceUri == null) {
throw new IllegalArgumentException("Parameter resourceUri is required and cannot be null.");
}
if (name == null) {
throw new IllegalArgumentException("Parameter name is required and cannot be null.");
}
final String apiVersion = "2017-05-01-preview";
return service.delete(resourceUri, name, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = deleteDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse deleteDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.register(204, new TypeToken() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
/**
* Gets the active diagnostic settings list for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the DiagnosticSettingsResourceCollectionInner object if successful.
*/
public DiagnosticSettingsResourceCollectionInner list(String resourceUri) {
return listWithServiceResponseAsync(resourceUri).toBlocking().single().body();
}
/**
* Gets the active diagnostic settings list for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @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 listAsync(String resourceUri, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(listWithServiceResponseAsync(resourceUri), serviceCallback);
}
/**
* Gets the active diagnostic settings list for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the DiagnosticSettingsResourceCollectionInner object
*/
public Observable listAsync(String resourceUri) {
return listWithServiceResponseAsync(resourceUri).map(new Func1, DiagnosticSettingsResourceCollectionInner>() {
@Override
public DiagnosticSettingsResourceCollectionInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Gets the active diagnostic settings list for the specified resource.
*
* @param resourceUri The identifier of the resource.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the DiagnosticSettingsResourceCollectionInner object
*/
public Observable> listWithServiceResponseAsync(String resourceUri) {
if (resourceUri == null) {
throw new IllegalArgumentException("Parameter resourceUri is required and cannot be null.");
}
final String apiVersion = "2017-05-01-preview";
return service.list(resourceUri, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = listDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy