All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.security.implementation.AlertsSuppressionRulesClientImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Security Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. API spec for Microsoft.Security (Azure Security Center) resource provider. Package tag package-composite-v3.

There is a newer version: 1.0.0
Show 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.security.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.security.fluent.AlertsSuppressionRulesClient;
import com.azure.resourcemanager.security.fluent.models.AlertsSuppressionRuleInner;
import com.azure.resourcemanager.security.models.AlertsSuppressionRulesList;
import reactor.core.publisher.Mono;

/**
 * An instance of this class provides access to all the operations defined in AlertsSuppressionRulesClient.
 */
public final class AlertsSuppressionRulesClientImpl implements AlertsSuppressionRulesClient {
    /**
     * The proxy service used to perform REST calls.
     */
    private final AlertsSuppressionRulesService service;

    /**
     * The service client containing this operation class.
     */
    private final SecurityCenterImpl client;

    /**
     * Initializes an instance of AlertsSuppressionRulesClientImpl.
     * 
     * @param client the instance of the service client containing this operation class.
     */
    AlertsSuppressionRulesClientImpl(SecurityCenterImpl client) {
        this.service = RestProxy.create(AlertsSuppressionRulesService.class, client.getHttpPipeline(),
            client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for SecurityCenterAlertsSuppressionRules to be used by the proxy service
     * to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "SecurityCenterAlerts")
    public interface AlertsSuppressionRulesService {
        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> list(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @QueryParam("AlertType") String alertType, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> get(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("alertsSuppressionRuleName") String alertsSuppressionRuleName,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Put("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> update(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("alertsSuppressionRuleName") String alertsSuppressionRuleName,
            @BodyParam("application/json") AlertsSuppressionRuleInner alertsSuppressionRule,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}")
        @ExpectedResponses({ 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> delete(@HostParam("$host") String endpoint, @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("alertsSuppressionRuleName") String alertsSuppressionRuleName,
            @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);
    }

    /**
     * List of all the dismiss rules for the given subscription.
     * 
     * @param alertType Type of the alert to get rules for.
     * @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 suppression rules list for subscription along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listSinglePageAsync(String alertType) {
        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 apiVersion = "2019-01-01-preview";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.list(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(),
                alertType, 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()));
    }

    /**
     * List of all the dismiss rules for the given subscription.
     * 
     * @param alertType Type of the alert to get rules for.
     * @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 suppression rules list for subscription along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listSinglePageAsync(String alertType, 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 apiVersion = "2019-01-01-preview";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), alertType, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * List of all the dismiss rules for the given subscription.
     * 
     * @param alertType Type of the alert to get rules for.
     * @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 suppression rules list for subscription as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listAsync(String alertType) {
        return new PagedFlux<>(() -> listSinglePageAsync(alertType), nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * List of all the dismiss rules for the given subscription.
     * 
     * @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 suppression rules list for subscription as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listAsync() {
        final String alertType = null;
        return new PagedFlux<>(() -> listSinglePageAsync(alertType), nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * List of all the dismiss rules for the given subscription.
     * 
     * @param alertType Type of the alert to get rules for.
     * @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 suppression rules list for subscription as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listAsync(String alertType, Context context) {
        return new PagedFlux<>(() -> listSinglePageAsync(alertType, context),
            nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * List of all the dismiss rules for the given subscription.
     * 
     * @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 suppression rules list for subscription as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable list() {
        final String alertType = null;
        return new PagedIterable<>(listAsync(alertType));
    }

    /**
     * List of all the dismiss rules for the given subscription.
     * 
     * @param alertType Type of the alert to get rules for.
     * @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 suppression rules list for subscription as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable list(String alertType, Context context) {
        return new PagedIterable<>(listAsync(alertType, context));
    }

    /**
     * Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription along with
     * {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String alertsSuppressionRuleName) {
        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."));
        }
        if (alertsSuppressionRuleName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter alertsSuppressionRuleName is required and cannot be null."));
        }
        final String apiVersion = "2019-01-01-preview";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.get(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(),
                alertsSuppressionRuleName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription along with
     * {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String alertsSuppressionRuleName,
        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."));
        }
        if (alertsSuppressionRuleName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter alertsSuppressionRuleName is required and cannot be null."));
        }
        final String apiVersion = "2019-01-01-preview";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.get(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(),
            alertsSuppressionRuleName, accept, context);
    }

    /**
     * Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription on successful completion
     * of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getAsync(String alertsSuppressionRuleName) {
        return getWithResponseAsync(alertsSuppressionRuleName).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription along with
     * {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getWithResponse(String alertsSuppressionRuleName, Context context) {
        return getWithResponseAsync(alertsSuppressionRuleName, context).block();
    }

    /**
     * Get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AlertsSuppressionRuleInner get(String alertsSuppressionRuleName) {
        return getWithResponse(alertsSuppressionRuleName, Context.NONE).getValue();
    }

    /**
     * Update existing rule or create new rule if it doesn't exist.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @param alertsSuppressionRule Suppression rule object.
     * @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 describes the suppression rule along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> updateWithResponseAsync(String alertsSuppressionRuleName,
        AlertsSuppressionRuleInner alertsSuppressionRule) {
        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."));
        }
        if (alertsSuppressionRuleName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter alertsSuppressionRuleName is required and cannot be null."));
        }
        if (alertsSuppressionRule == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter alertsSuppressionRule is required and cannot be null."));
        } else {
            alertsSuppressionRule.validate();
        }
        final String apiVersion = "2019-01-01-preview";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.update(this.client.getEndpoint(), apiVersion,
                this.client.getSubscriptionId(), alertsSuppressionRuleName, alertsSuppressionRule, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update existing rule or create new rule if it doesn't exist.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @param alertsSuppressionRule Suppression rule object.
     * @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 describes the suppression rule along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> updateWithResponseAsync(String alertsSuppressionRuleName,
        AlertsSuppressionRuleInner alertsSuppressionRule, 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."));
        }
        if (alertsSuppressionRuleName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter alertsSuppressionRuleName is required and cannot be null."));
        }
        if (alertsSuppressionRule == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter alertsSuppressionRule is required and cannot be null."));
        } else {
            alertsSuppressionRule.validate();
        }
        final String apiVersion = "2019-01-01-preview";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.update(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(),
            alertsSuppressionRuleName, alertsSuppressionRule, accept, context);
    }

    /**
     * Update existing rule or create new rule if it doesn't exist.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @param alertsSuppressionRule Suppression rule object.
     * @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 describes the suppression rule on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono updateAsync(String alertsSuppressionRuleName,
        AlertsSuppressionRuleInner alertsSuppressionRule) {
        return updateWithResponseAsync(alertsSuppressionRuleName, alertsSuppressionRule)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Update existing rule or create new rule if it doesn't exist.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @param alertsSuppressionRule Suppression rule object.
     * @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 describes the suppression rule along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response updateWithResponse(String alertsSuppressionRuleName,
        AlertsSuppressionRuleInner alertsSuppressionRule, Context context) {
        return updateWithResponseAsync(alertsSuppressionRuleName, alertsSuppressionRule, context).block();
    }

    /**
     * Update existing rule or create new rule if it doesn't exist.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @param alertsSuppressionRule Suppression rule object.
     * @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 describes the suppression rule.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AlertsSuppressionRuleInner update(String alertsSuppressionRuleName,
        AlertsSuppressionRuleInner alertsSuppressionRule) {
        return updateWithResponse(alertsSuppressionRuleName, alertsSuppressionRule, Context.NONE).getValue();
    }

    /**
     * Delete dismiss alert rule for this subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 alertsSuppressionRuleName) {
        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."));
        }
        if (alertsSuppressionRuleName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter alertsSuppressionRuleName is required and cannot be null."));
        }
        final String apiVersion = "2019-01-01-preview";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.delete(this.client.getEndpoint(), apiVersion,
                this.client.getSubscriptionId(), alertsSuppressionRuleName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete dismiss alert rule for this subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 alertsSuppressionRuleName, 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."));
        }
        if (alertsSuppressionRuleName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter alertsSuppressionRuleName is required and cannot be null."));
        }
        final String apiVersion = "2019-01-01-preview";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.delete(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(),
            alertsSuppressionRuleName, accept, context);
    }

    /**
     * Delete dismiss alert rule for this subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 alertsSuppressionRuleName) {
        return deleteWithResponseAsync(alertsSuppressionRuleName).flatMap(ignored -> Mono.empty());
    }

    /**
     * Delete dismiss alert rule for this subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 alertsSuppressionRuleName, Context context) {
        return deleteWithResponseAsync(alertsSuppressionRuleName, context).block();
    }

    /**
     * Delete dismiss alert rule for this subscription.
     * 
     * @param alertsSuppressionRuleName The unique name of the suppression alert rule.
     * @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 alertsSuppressionRuleName) {
        deleteWithResponse(alertsSuppressionRuleName, Context.NONE);
    }

    /**
     * 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 suppression rules list for subscription 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 suppression rules list for subscription 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