com.microsoft.azure.management.monitor.implementation.LogProfilesInner 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. This package has been deprecated. A replacement package com.azure.resourcemanager:azure-resourcemanager-monitor is available as of 31-March-2022. We strongly encourage you to upgrade to continue receiving updates. See Migration Guide https://aka.ms/java-track2-migration-guide for guidance on upgrading. Refer to our deprecation policy https://azure.github.io/azure-sdk/policies_support.html for more details.
/**
* 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 retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.CloudException;
import com.microsoft.azure.management.monitor.ErrorResponseException;
import com.microsoft.azure.management.monitor.LogProfileResourcePatch;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
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 java.util.List;
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.PATCH;
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 LogProfiles.
*/
public class LogProfilesInner {
/** The Retrofit service to perform REST calls. */
private LogProfilesService service;
/** The service client containing this operation class. */
private MonitorManagementClientImpl client;
/**
* Initializes an instance of LogProfilesInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public LogProfilesInner(Retrofit retrofit, MonitorManagementClientImpl client) {
this.service = retrofit.create(LogProfilesService.class);
this.client = client;
}
/**
* The interface defining all the services for LogProfiles to be
* used by Retrofit to perform actually REST calls.
*/
interface LogProfilesService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.LogProfiles delete" })
@HTTP(path = "subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", method = "DELETE", hasBody = true)
Observable> delete(@Path("logProfileName") String logProfileName, @Path("subscriptionId") String subscriptionId, @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.LogProfiles get" })
@GET("subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}")
Observable> get(@Path("logProfileName") String logProfileName, @Path("subscriptionId") String subscriptionId, @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.LogProfiles createOrUpdate" })
@PUT("subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}")
Observable> createOrUpdate(@Path("logProfileName") String logProfileName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Body LogProfileResourceInner 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.LogProfiles update" })
@PATCH("subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}")
Observable> update(@Path("subscriptionId") String subscriptionId, @Path("logProfileName") String logProfileName, @Query("api-version") String apiVersion, @Body LogProfileResourcePatch logProfilesResource, @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.LogProfiles list" })
@GET("subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles")
Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
}
/**
* Deletes the log profile.
*
* @param logProfileName The name of the log profile.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws CloudException 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 logProfileName) {
deleteWithServiceResponseAsync(logProfileName).toBlocking().single().body();
}
/**
* Deletes the log profile.
*
* @param logProfileName The name of the log profile.
* @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 logProfileName, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(logProfileName), serviceCallback);
}
/**
* Deletes the log profile.
*
* @param logProfileName The name of the log profile.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable deleteAsync(String logProfileName) {
return deleteWithServiceResponseAsync(logProfileName).map(new Func1, Void>() {
@Override
public Void call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Deletes the log profile.
*
* @param logProfileName The name of the log profile.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable> deleteWithServiceResponseAsync(String logProfileName) {
if (logProfileName == null) {
throw new IllegalArgumentException("Parameter logProfileName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2016-03-01";
return service.delete(logProfileName, this.client.subscriptionId(), 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 CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Gets the log profile.
*
* @param logProfileName The name of the log profile.
* @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 LogProfileResourceInner object if successful.
*/
public LogProfileResourceInner get(String logProfileName) {
return getWithServiceResponseAsync(logProfileName).toBlocking().single().body();
}
/**
* Gets the log profile.
*
* @param logProfileName The name of the log profile.
* @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 logProfileName, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(getWithServiceResponseAsync(logProfileName), serviceCallback);
}
/**
* Gets the log profile.
*
* @param logProfileName The name of the log profile.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the LogProfileResourceInner object
*/
public Observable getAsync(String logProfileName) {
return getWithServiceResponseAsync(logProfileName).map(new Func1, LogProfileResourceInner>() {
@Override
public LogProfileResourceInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Gets the log profile.
*
* @param logProfileName The name of the log profile.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the LogProfileResourceInner object
*/
public Observable> getWithServiceResponseAsync(String logProfileName) {
if (logProfileName == null) {
throw new IllegalArgumentException("Parameter logProfileName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2016-03-01";
return service.get(logProfileName, this.client.subscriptionId(), 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);
}
/**
* Create or update a log profile in Azure Monitoring REST API.
*
* @param logProfileName The name of the log profile.
* @param parameters Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws CloudException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the LogProfileResourceInner object if successful.
*/
public LogProfileResourceInner createOrUpdate(String logProfileName, LogProfileResourceInner parameters) {
return createOrUpdateWithServiceResponseAsync(logProfileName, parameters).toBlocking().single().body();
}
/**
* Create or update a log profile in Azure Monitoring REST API.
*
* @param logProfileName The name of the log profile.
* @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 logProfileName, LogProfileResourceInner parameters, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(logProfileName, parameters), serviceCallback);
}
/**
* Create or update a log profile in Azure Monitoring REST API.
*
* @param logProfileName The name of the log profile.
* @param parameters Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the LogProfileResourceInner object
*/
public Observable createOrUpdateAsync(String logProfileName, LogProfileResourceInner parameters) {
return createOrUpdateWithServiceResponseAsync(logProfileName, parameters).map(new Func1, LogProfileResourceInner>() {
@Override
public LogProfileResourceInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Create or update a log profile in Azure Monitoring REST API.
*
* @param logProfileName The name of the log profile.
* @param parameters Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the LogProfileResourceInner object
*/
public Observable> createOrUpdateWithServiceResponseAsync(String logProfileName, LogProfileResourceInner parameters) {
if (logProfileName == null) {
throw new IllegalArgumentException("Parameter logProfileName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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 = "2016-03-01";
return service.createOrUpdate(logProfileName, this.client.subscriptionId(), 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 CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method.
*
* @param logProfileName The name of the log profile.
* @param logProfilesResource 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 LogProfileResourceInner object if successful.
*/
public LogProfileResourceInner update(String logProfileName, LogProfileResourcePatch logProfilesResource) {
return updateWithServiceResponseAsync(logProfileName, logProfilesResource).toBlocking().single().body();
}
/**
* Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method.
*
* @param logProfileName The name of the log profile.
* @param logProfilesResource 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 updateAsync(String logProfileName, LogProfileResourcePatch logProfilesResource, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(updateWithServiceResponseAsync(logProfileName, logProfilesResource), serviceCallback);
}
/**
* Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method.
*
* @param logProfileName The name of the log profile.
* @param logProfilesResource Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the LogProfileResourceInner object
*/
public Observable updateAsync(String logProfileName, LogProfileResourcePatch logProfilesResource) {
return updateWithServiceResponseAsync(logProfileName, logProfilesResource).map(new Func1, LogProfileResourceInner>() {
@Override
public LogProfileResourceInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method.
*
* @param logProfileName The name of the log profile.
* @param logProfilesResource Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the LogProfileResourceInner object
*/
public Observable> updateWithServiceResponseAsync(String logProfileName, LogProfileResourcePatch logProfilesResource) {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (logProfileName == null) {
throw new IllegalArgumentException("Parameter logProfileName is required and cannot be null.");
}
if (logProfilesResource == null) {
throw new IllegalArgumentException("Parameter logProfilesResource is required and cannot be null.");
}
Validator.validate(logProfilesResource);
final String apiVersion = "2016-03-01";
return service.update(this.client.subscriptionId(), logProfileName, apiVersion, logProfilesResource, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = updateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse updateDelegate(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);
}
/**
* List the log profiles.
*
* @return the PagedList object if successful.
*/
public PagedList list() {
PageImpl1 page = new PageImpl1<>();
page.setItems(listWithServiceResponseAsync().toBlocking().single().body());
page.setNextPageLink(null);
return new PagedList(page) {
@Override
public Page nextPage(String nextPageLink) {
return null;
}
};
}
/**
* List the log profiles.
*
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @return the {@link ServiceFuture} object
*/
public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) {
return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback);
}
/**
* List the log profiles.
*
* @return the observable to the List<LogProfileResourceInner> object
*/
public Observable> listAsync() {
return listWithServiceResponseAsync().map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
PageImpl1 page = new PageImpl1<>();
page.setItems(response.body());
return page;
}
});
}
/**
* List the log profiles.
*
* @return the observable to the List<LogProfileResourceInner> object
*/
public Observable>> listWithServiceResponseAsync() {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2016-03-01";
return service.list(this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = listDelegate(response);
List items = null;
if (result.body() != null) {
items = result.body().items();
}
ServiceResponse> clientResponse = new ServiceResponse>(items, result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
}