LogAnalyticsClientImpl.java
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.compute.implementation;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Post;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.compute.fluent.LogAnalyticsClient;
import com.azure.resourcemanager.compute.fluent.models.LogAnalyticsOperationResultInner;
import com.azure.resourcemanager.compute.models.LogAnalyticsInputBase;
import com.azure.resourcemanager.compute.models.RequestRateByIntervalInput;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in LogAnalyticsClient. */
public final class LogAnalyticsClientImpl implements LogAnalyticsClient {
private final ClientLogger logger = new ClientLogger(LogAnalyticsClientImpl.class);
/** The proxy service used to perform REST calls. */
private final LogAnalyticsService service;
/** The service client containing this operation class. */
private final ComputeManagementClientImpl client;
/**
* Initializes an instance of LogAnalyticsClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
LogAnalyticsClientImpl(ComputeManagementClientImpl client) {
this.service =
RestProxy.create(LogAnalyticsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for ComputeManagementClientLogAnalytics to be used by the proxy service
* to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "ComputeManagementCli")
private interface LogAnalyticsService {
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Post(
"/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess"
+ "/getRequestRateByInterval")
@ExpectedResponses({200, 202})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<Flux<ByteBuffer>>> exportRequestRateByInterval(
@HostParam("$host") String endpoint,
@PathParam("location") String location,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
@BodyParam("application/json") RequestRateByIntervalInput parameters,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Post(
"/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess"
+ "/getThrottledRequests")
@ExpectedResponses({200, 202})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<Flux<ByteBuffer>>> exportThrottledRequests(
@HostParam("$host") String endpoint,
@PathParam("location") String location,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
@BodyParam("application/json") LogAnalyticsInputBase parameters,
Context context);
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Flux<ByteBuffer>>> exportRequestRateByIntervalWithResponseAsync(
String location, RequestRateByIntervalInput parameters) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (parameters == null) {
return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
} else {
parameters.validate();
}
final String apiVersion = "2019-12-01";
return FluxUtil
.withContext(
context ->
service
.exportRequestRateByInterval(
this.client.getEndpoint(),
location,
apiVersion,
this.client.getSubscriptionId(),
parameters,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<Flux<ByteBuffer>>> exportRequestRateByIntervalWithResponseAsync(
String location, RequestRateByIntervalInput parameters, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (parameters == null) {
return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
} else {
parameters.validate();
}
final String apiVersion = "2019-12-01";
context = this.client.mergeContext(context);
return service
.exportRequestRateByInterval(
this.client.getEndpoint(), location, apiVersion, this.client.getSubscriptionId(), parameters, context);
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PollerFlux<PollResult<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>
beginExportRequestRateByIntervalAsync(String location, RequestRateByIntervalInput parameters) {
Mono<Response<Flux<ByteBuffer>>> mono = exportRequestRateByIntervalWithResponseAsync(location, parameters);
return this
.client
.<LogAnalyticsOperationResultInner, LogAnalyticsOperationResultInner>getLroResult(
mono,
this.client.getHttpPipeline(),
LogAnalyticsOperationResultInner.class,
LogAnalyticsOperationResultInner.class,
Context.NONE);
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private PollerFlux<PollResult<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>
beginExportRequestRateByIntervalAsync(String location, RequestRateByIntervalInput parameters, Context context) {
context = this.client.mergeContext(context);
Mono<Response<Flux<ByteBuffer>>> mono =
exportRequestRateByIntervalWithResponseAsync(location, parameters, context);
return this
.client
.<LogAnalyticsOperationResultInner, LogAnalyticsOperationResultInner>getLroResult(
mono,
this.client.getHttpPipeline(),
LogAnalyticsOperationResultInner.class,
LogAnalyticsOperationResultInner.class,
context);
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>
beginExportRequestRateByInterval(String location, RequestRateByIntervalInput parameters) {
return beginExportRequestRateByIntervalAsync(location, parameters).getSyncPoller();
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>
beginExportRequestRateByInterval(String location, RequestRateByIntervalInput parameters, Context context) {
return beginExportRequestRateByIntervalAsync(location, parameters, context).getSyncPoller();
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<LogAnalyticsOperationResultInner> exportRequestRateByIntervalAsync(
String location, RequestRateByIntervalInput parameters) {
return beginExportRequestRateByIntervalAsync(location, parameters)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<LogAnalyticsOperationResultInner> exportRequestRateByIntervalAsync(
String location, RequestRateByIntervalInput parameters, Context context) {
return beginExportRequestRateByIntervalAsync(location, parameters, context)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public LogAnalyticsOperationResultInner exportRequestRateByInterval(
String location, RequestRateByIntervalInput parameters) {
return exportRequestRateByIntervalAsync(location, parameters).block();
}
/**
* Export logs that show Api requests made by this subscription in the given time window to show throttling
* activities.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api request input for LogAnalytics getRequestRateByInterval Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public LogAnalyticsOperationResultInner exportRequestRateByInterval(
String location, RequestRateByIntervalInput parameters, Context context) {
return exportRequestRateByIntervalAsync(location, parameters, context).block();
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Flux<ByteBuffer>>> exportThrottledRequestsWithResponseAsync(
String location, LogAnalyticsInputBase parameters) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (parameters == null) {
return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
} else {
parameters.validate();
}
final String apiVersion = "2019-12-01";
return FluxUtil
.withContext(
context ->
service
.exportThrottledRequests(
this.client.getEndpoint(),
location,
apiVersion,
this.client.getSubscriptionId(),
parameters,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<Flux<ByteBuffer>>> exportThrottledRequestsWithResponseAsync(
String location, LogAnalyticsInputBase parameters, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (parameters == null) {
return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
} else {
parameters.validate();
}
final String apiVersion = "2019-12-01";
context = this.client.mergeContext(context);
return service
.exportThrottledRequests(
this.client.getEndpoint(), location, apiVersion, this.client.getSubscriptionId(), parameters, context);
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PollerFlux<PollResult<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>
beginExportThrottledRequestsAsync(String location, LogAnalyticsInputBase parameters) {
Mono<Response<Flux<ByteBuffer>>> mono = exportThrottledRequestsWithResponseAsync(location, parameters);
return this
.client
.<LogAnalyticsOperationResultInner, LogAnalyticsOperationResultInner>getLroResult(
mono,
this.client.getHttpPipeline(),
LogAnalyticsOperationResultInner.class,
LogAnalyticsOperationResultInner.class,
Context.NONE);
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private PollerFlux<PollResult<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>
beginExportThrottledRequestsAsync(String location, LogAnalyticsInputBase parameters, Context context) {
context = this.client.mergeContext(context);
Mono<Response<Flux<ByteBuffer>>> mono = exportThrottledRequestsWithResponseAsync(location, parameters, context);
return this
.client
.<LogAnalyticsOperationResultInner, LogAnalyticsOperationResultInner>getLroResult(
mono,
this.client.getHttpPipeline(),
LogAnalyticsOperationResultInner.class,
LogAnalyticsOperationResultInner.class,
context);
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>
beginExportThrottledRequests(String location, LogAnalyticsInputBase parameters) {
return beginExportThrottledRequestsAsync(location, parameters).getSyncPoller();
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>
beginExportThrottledRequests(String location, LogAnalyticsInputBase parameters, Context context) {
return beginExportThrottledRequestsAsync(location, parameters, context).getSyncPoller();
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<LogAnalyticsOperationResultInner> exportThrottledRequestsAsync(
String location, LogAnalyticsInputBase parameters) {
return beginExportThrottledRequestsAsync(location, parameters)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<LogAnalyticsOperationResultInner> exportThrottledRequestsAsync(
String location, LogAnalyticsInputBase parameters, Context context) {
return beginExportThrottledRequestsAsync(location, parameters, context)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public LogAnalyticsOperationResultInner exportThrottledRequests(String location, LogAnalyticsInputBase parameters) {
return exportThrottledRequestsAsync(location, parameters).block();
}
/**
* Export logs that show total throttled Api requests for this subscription in the given time window.
*
* @param location The location upon which virtual-machine-sizes is queried.
* @param parameters Api input base class for LogAnalytics Api.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return logAnalytics operation status response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public LogAnalyticsOperationResultInner exportThrottledRequests(
String location, LogAnalyticsInputBase parameters, Context context) {
return exportThrottledRequestsAsync(location, parameters, context).block();
}
}