com.azure.resourcemanager.advisor.implementation.SuppressionsClientImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-advisor Show documentation
Show all versions of azure-resourcemanager-advisor Show documentation
This package contains Microsoft Azure SDK for Advisor Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. REST APIs for Azure Advisor. Package tag package-2020-01.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.advisor.implementation;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
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.Put;
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.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
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.advisor.fluent.SuppressionsClient;
import com.azure.resourcemanager.advisor.fluent.models.SuppressionContractInner;
import com.azure.resourcemanager.advisor.models.SuppressionContractListResult;
import reactor.core.publisher.Mono;
/**
* An instance of this class provides access to all the operations defined in SuppressionsClient.
*/
public final class SuppressionsClientImpl implements SuppressionsClient {
/**
* The proxy service used to perform REST calls.
*/
private final SuppressionsService service;
/**
* The service client containing this operation class.
*/
private final AdvisorManagementClientImpl client;
/**
* Initializes an instance of SuppressionsClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
SuppressionsClientImpl(AdvisorManagementClientImpl client) {
this.service
= RestProxy.create(SuppressionsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for AdvisorManagementClientSuppressions to be used by the proxy service
* to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "AdvisorManagementCli")
public interface SuppressionsService {
@Headers({ "Content-Type: application/json" })
@Get("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(value = ManagementException.class, code = { 404 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> get(@HostParam("$host") String endpoint,
@PathParam("resourceUri") String resourceUri, @PathParam("recommendationId") String recommendationId,
@PathParam("name") String name, @QueryParam("api-version") String apiVersion,
@HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Put("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(value = ManagementException.class, code = { 404 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> create(@HostParam("$host") String endpoint,
@PathParam("resourceUri") String resourceUri, @PathParam("recommendationId") String recommendationId,
@PathParam("name") String name, @QueryParam("api-version") String apiVersion,
@BodyParam("application/json") SuppressionContractInner suppressionContract,
@HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Delete("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}")
@ExpectedResponses({ 204 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> delete(@HostParam("$host") String endpoint, @PathParam("resourceUri") String resourceUri,
@PathParam("recommendationId") String recommendationId, @PathParam("name") String name,
@QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Get("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> list(@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId, @QueryParam("api-version") String apiVersion,
@QueryParam("$top") Integer top, @QueryParam("$skipToken") String skipToken,
@HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Get("{nextLink}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> listNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
@HeaderParam("Accept") String accept, Context context);
}
/**
* Obtains the details of a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> getWithResponseAsync(String resourceUri, String recommendationId,
String name) {
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."));
}
if (recommendationId == null) {
return Mono
.error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null."));
}
if (name == null) {
return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.get(this.client.getEndpoint(), resourceUri, recommendationId, name,
this.client.getApiVersion(), accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Obtains the details of a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @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 ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> getWithResponseAsync(String resourceUri, String recommendationId,
String name, 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."));
}
if (recommendationId == null) {
return Mono
.error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null."));
}
if (name == null) {
return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.get(this.client.getEndpoint(), resourceUri, recommendationId, name, this.client.getApiVersion(),
accept, context);
}
/**
* Obtains the details of a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono getAsync(String resourceUri, String recommendationId, String name) {
return getWithResponseAsync(resourceUri, recommendationId, name)
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
}
/**
* Obtains the details of a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @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 ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response getWithResponse(String resourceUri, String recommendationId, String name,
Context context) {
return getWithResponseAsync(resourceUri, recommendationId, name, context).block();
}
/**
* Obtains the details of a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SuppressionContractInner get(String resourceUri, String recommendationId, String name) {
return getWithResponse(resourceUri, recommendationId, name, Context.NONE).getValue();
}
/**
* Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to
* as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> createWithResponseAsync(String resourceUri,
String recommendationId, String name, SuppressionContractInner suppressionContract) {
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."));
}
if (recommendationId == null) {
return Mono
.error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null."));
}
if (name == null) {
return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null."));
}
if (suppressionContract == null) {
return Mono
.error(new IllegalArgumentException("Parameter suppressionContract is required and cannot be null."));
} else {
suppressionContract.validate();
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.create(this.client.getEndpoint(), resourceUri, recommendationId, name,
this.client.getApiVersion(), suppressionContract, accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to
* as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration.
* @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 ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> createWithResponseAsync(String resourceUri,
String recommendationId, String name, SuppressionContractInner suppressionContract, 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."));
}
if (recommendationId == null) {
return Mono
.error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null."));
}
if (name == null) {
return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null."));
}
if (suppressionContract == null) {
return Mono
.error(new IllegalArgumentException("Parameter suppressionContract is required and cannot be null."));
} else {
suppressionContract.validate();
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.create(this.client.getEndpoint(), resourceUri, recommendationId, name,
this.client.getApiVersion(), suppressionContract, accept, context);
}
/**
* Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to
* as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono createAsync(String resourceUri, String recommendationId, String name,
SuppressionContractInner suppressionContract) {
return createWithResponseAsync(resourceUri, recommendationId, name, suppressionContract)
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
}
/**
* Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to
* as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration.
* @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 ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response createWithResponse(String resourceUri, String recommendationId,
String name, SuppressionContractInner suppressionContract, Context context) {
return createWithResponseAsync(resourceUri, recommendationId, name, suppressionContract, context).block();
}
/**
* Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to
* as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws ManagementException thrown if the request is rejected by server on status code 404.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with
* the rule.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SuppressionContractInner create(String resourceUri, String recommendationId, String name,
SuppressionContractInner suppressionContract) {
return createWithResponse(resourceUri, recommendationId, name, suppressionContract, Context.NONE).getValue();
}
/**
* Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a
* recommendation is referred to as a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @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 {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> deleteWithResponseAsync(String resourceUri, String recommendationId, String name) {
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."));
}
if (recommendationId == null) {
return Mono
.error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null."));
}
if (name == null) {
return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.delete(this.client.getEndpoint(), resourceUri, recommendationId, name,
this.client.getApiVersion(), accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a
* recommendation is referred to as a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @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 {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> deleteWithResponseAsync(String resourceUri, String recommendationId, String name,
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."));
}
if (recommendationId == null) {
return Mono
.error(new IllegalArgumentException("Parameter recommendationId is required and cannot be null."));
}
if (name == null) {
return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.delete(this.client.getEndpoint(), resourceUri, recommendationId, name,
this.client.getApiVersion(), accept, context);
}
/**
* Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a
* recommendation is referred to as a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @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 A {@link Mono} that completes when a successful response is received.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono deleteAsync(String resourceUri, String recommendationId, String name) {
return deleteWithResponseAsync(resourceUri, recommendationId, name).flatMap(ignored -> Mono.empty());
}
/**
* Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a
* recommendation is referred to as a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @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 {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response deleteWithResponse(String resourceUri, String recommendationId, String name,
Context context) {
return deleteWithResponseAsync(resourceUri, recommendationId, name, context).block();
}
/**
* Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a
* recommendation is referred to as a suppression.
*
* @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which the
* recommendation applies.
* @param recommendationId The recommendation ID.
* @param name The name of the suppression.
* @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.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void delete(String resourceUri, String recommendationId, String name) {
deleteWithResponse(resourceUri, recommendationId, name, Context.NONE);
}
/**
* Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of
* a recommendation is referred to as a suppression.
*
* @param top The number of suppressions per page if a paged version of this API is being used.
* @param skipToken The page-continuation token to use with a paged version of this 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 the list of Advisor suppressions along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listSinglePageAsync(Integer top, String skipToken) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() 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."));
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.list(this.client.getEndpoint(), this.client.getSubscriptionId(),
this.client.getApiVersion(), top, skipToken, accept, context))
.>map(res -> new PagedResponseBase<>(res.getRequest(),
res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of
* a recommendation is referred to as a suppression.
*
* @param top The number of suppressions per page if a paged version of this API is being used.
* @param skipToken The page-continuation token to use with a paged version of this 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 the list of Advisor suppressions along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listSinglePageAsync(Integer top, String skipToken,
Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() 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."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service
.list(this.client.getEndpoint(), this.client.getSubscriptionId(), this.client.getApiVersion(), top,
skipToken, accept, context)
.map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
res.getValue().value(), res.getValue().nextLink(), null));
}
/**
* Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of
* a recommendation is referred to as a suppression.
*
* @param top The number of suppressions per page if a paged version of this API is being used.
* @param skipToken The page-continuation token to use with a paged version of this 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 the list of Advisor suppressions as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listAsync(Integer top, String skipToken) {
return new PagedFlux<>(() -> listSinglePageAsync(top, skipToken),
nextLink -> listNextSinglePageAsync(nextLink));
}
/**
* Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of
* a recommendation is referred to as a suppression.
*
* @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 list of Advisor suppressions as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listAsync() {
final Integer top = null;
final String skipToken = null;
return new PagedFlux<>(() -> listSinglePageAsync(top, skipToken),
nextLink -> listNextSinglePageAsync(nextLink));
}
/**
* Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of
* a recommendation is referred to as a suppression.
*
* @param top The number of suppressions per page if a paged version of this API is being used.
* @param skipToken The page-continuation token to use with a paged version of this 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 the list of Advisor suppressions as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listAsync(Integer top, String skipToken, Context context) {
return new PagedFlux<>(() -> listSinglePageAsync(top, skipToken, context),
nextLink -> listNextSinglePageAsync(nextLink, context));
}
/**
* Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of
* a recommendation is referred to as a suppression.
*
* @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 list of Advisor suppressions as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable list() {
final Integer top = null;
final String skipToken = null;
return new PagedIterable<>(listAsync(top, skipToken));
}
/**
* Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of
* a recommendation is referred to as a suppression.
*
* @param top The number of suppressions per page if a paged version of this API is being used.
* @param skipToken The page-continuation token to use with a paged version of this 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 the list of Advisor suppressions as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable list(Integer top, String skipToken, Context context) {
return new PagedIterable<>(listAsync(top, skipToken, context));
}
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items.
* @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 list of Advisor suppressions along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listNextSinglePageAsync(String nextLink) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context))
.>map(res -> new PagedResponseBase<>(res.getRequest(),
res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items.
* @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 list of Advisor suppressions along with {@link PagedResponse} on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listNextSinglePageAsync(String nextLink, Context context) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.listNext(nextLink, this.client.getEndpoint(), accept, context)
.map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
res.getValue().value(), res.getValue().nextLink(), null));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy