com.azure.resourcemanager.applicationinsights.implementation.LiveTokensClientImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-applicationinsights Show documentation
Show all versions of azure-resourcemanager-applicationinsights Show documentation
This package contains Microsoft Azure SDK for ApplicationInsights Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Composite Swagger for Application Insights Management Client. Package tag package-2022-04-01.
The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.applicationinsights.implementation;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.HeaderParam;
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.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.applicationinsights.fluent.LiveTokensClient;
import com.azure.resourcemanager.applicationinsights.fluent.models.LiveTokenResponseInner;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in LiveTokensClient. */
public final class LiveTokensClientImpl implements LiveTokensClient {
/** The proxy service used to perform REST calls. */
private final LiveTokensService service;
/** The service client containing this operation class. */
private final ApplicationInsightsManagementClientImpl client;
/**
* Initializes an instance of LiveTokensClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
LiveTokensClientImpl(ApplicationInsightsManagementClientImpl client) {
this.service =
RestProxy.create(LiveTokensService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for ApplicationInsightsManagementClientLiveTokens to be used by the proxy
* service to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "ApplicationInsightsM")
private interface LiveTokensService {
@Headers({"Content-Type: application/json"})
@Post("/{resourceUri}/providers/Microsoft.Insights/generatelivetoken")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> get(
@HostParam("$host") String endpoint,
@PathParam(value = "resourceUri", encoded = true) String resourceUri,
@QueryParam("api-version") String apiVersion,
@HeaderParam("Accept") String accept,
Context context);
}
/**
* **Gets an access token for live metrics stream data.**.
*
* @param resourceUri The identifier of the resource.
* @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 the response to a live token query along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> getWithResponseAsync(String resourceUri) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceUri == null) {
return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
}
final String apiVersion = "2021-10-14";
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.get(this.client.getEndpoint(), resourceUri, apiVersion, accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* **Gets an access token for live metrics stream data.**.
*
* @param resourceUri The identifier of the resource.
* @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 the response to a live token query along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> getWithResponseAsync(String resourceUri, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (resourceUri == null) {
return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
}
final String apiVersion = "2021-10-14";
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.get(this.client.getEndpoint(), resourceUri, apiVersion, accept, context);
}
/**
* **Gets an access token for live metrics stream data.**.
*
* @param resourceUri The identifier of the resource.
* @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 the response to a live token query on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono getAsync(String resourceUri) {
return getWithResponseAsync(resourceUri).flatMap(res -> Mono.justOrEmpty(res.getValue()));
}
/**
* **Gets an access token for live metrics stream data.**.
*
* @param resourceUri The identifier of the resource.
* @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 the response to a live token query.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public LiveTokenResponseInner get(String resourceUri) {
return getAsync(resourceUri).block();
}
/**
* **Gets an access token for live metrics stream data.**.
*
* @param resourceUri The identifier of the resource.
* @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 the response to a live token query along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response getWithResponse(String resourceUri, Context context) {
return getWithResponseAsync(resourceUri, context).block();
}
}