// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.paloaltonetworks.ngfw.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.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Post;
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.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.LocalRulestacksClient;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.AdvSecurityObjectListResponseInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.ChangelogInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.CountriesResponseInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.ListAppIdResponseInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.ListFirewallsResponseInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.LocalRulestackResourceInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.PredefinedUrlCategoriesResponseInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.SecurityServicesResponseInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.SupportInfoInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.AdvSecurityObjectTypeEnum;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.LocalRulestackResourceListResult;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.LocalRulestackResourceUpdate;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.SecurityServicesTypeEnum;
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 LocalRulestacksClient. */
public final class LocalRulestacksClientImpl implements LocalRulestacksClient {
    /** The proxy service used to perform REST calls. */
    private final LocalRulestacksService service;

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

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

    /**
     * The interface defining all the services for PaloAltoNetworksCloudngfwLocalRulestacks to be used by the proxy
     * service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "PaloAltoNetworksClou")
    public interface LocalRulestacksService {
        @Headers({"Content-Type: application/json"})
        @Get("/subscriptions/{subscriptionId}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<LocalRulestackResourceListResult>> list(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<LocalRulestackResourceListResult>> listByResourceGroup(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<LocalRulestackResourceInner>> getByResourceGroup(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @BodyParam("application/json") LocalRulestackResourceInner resource,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<LocalRulestackResourceInner>> update(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @BodyParam("application/json") LocalRulestackResourceUpdate properties,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}")
        @ExpectedResponses({200, 202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> delete(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/commit")
        @ExpectedResponses({202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> commit(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getChangeLog")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ChangelogInner>> getChangeLog(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getSupportInfo")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SupportInfoInner>> getSupportInfo(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @QueryParam("email") String email,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listAdvancedSecurityObjects")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AdvSecurityObjectListResponseInner>> listAdvancedSecurityObjects(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @QueryParam("skip") String skip,
            @QueryParam("top") Integer top,
            @QueryParam("type") AdvSecurityObjectTypeEnum type,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listAppIds")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ListAppIdResponseInner>> listAppIds(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @QueryParam("appIdVersion") String appIdVersion,
            @QueryParam("appPrefix") String appPrefix,
            @QueryParam("skip") String skip,
            @QueryParam("top") Integer top,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listCountries")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<CountriesResponseInner>> listCountries(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @QueryParam("skip") String skip,
            @QueryParam("top") Integer top,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listFirewalls")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ListFirewallsResponseInner>> listFirewalls(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listPredefinedUrlCategories")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<PredefinedUrlCategoriesResponseInner>> listPredefinedUrlCategories(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @QueryParam("skip") String skip,
            @QueryParam("top") Integer top,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listSecurityServices")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SecurityServicesResponseInner>> listSecurityServices(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @QueryParam("skip") String skip,
            @QueryParam("top") Integer top,
            @QueryParam("type") SecurityServicesTypeEnum type,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/revert")
        @ExpectedResponses({204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Void>> revert(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("localRulestackName") String localRulestackName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<LocalRulestackResourceListResult>> listBySubscriptionNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink,
            @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<LocalRulestackResourceListResult>> listByResourceGroupNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink,
            @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept,
            Context context);
    }

    /**
     * List LocalRulestackResource resources by subscription ID.
     *
     * @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 of a LocalRulestackResource list operation along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<LocalRulestackResourceInner>> listSinglePageAsync() {
        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.getApiVersion(),
                            this.client.getSubscriptionId(),
                            accept,
                            context))
            .<PagedResponse<LocalRulestackResourceInner>>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 LocalRulestackResource resources by subscription ID.
     *
     * @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 of a LocalRulestackResource list operation along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<LocalRulestackResourceInner>> listSinglePageAsync(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.getApiVersion(),
                this.client.getSubscriptionId(),
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * List LocalRulestackResource resources by subscription ID.
     *
     * @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 of a LocalRulestackResource list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<LocalRulestackResourceInner> listAsync() {
        return new PagedFlux<>(
            () -> listSinglePageAsync(), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink));
    }

    /**
     * List LocalRulestackResource resources by subscription ID.
     *
     * @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 of a LocalRulestackResource list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<LocalRulestackResourceInner> listAsync(Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(context), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context));
    }

    /**
     * List LocalRulestackResource resources by subscription ID.
     *
     * @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 of a LocalRulestackResource list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<LocalRulestackResourceInner> list() {
        return new PagedIterable<>(listAsync());
    }

    /**
     * List LocalRulestackResource resources by subscription ID.
     *
     * @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 of a LocalRulestackResource list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<LocalRulestackResourceInner> list(Context context) {
        return new PagedIterable<>(listAsync(context));
    }

    /**
     * List LocalRulestackResource resources by resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 of a LocalRulestackResource list operation along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<LocalRulestackResourceInner>> listByResourceGroupSinglePageAsync(
        String resourceGroupName) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByResourceGroup(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            accept,
                            context))
            .<PagedResponse<LocalRulestackResourceInner>>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 LocalRulestackResource resources by resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 of a LocalRulestackResource list operation along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<LocalRulestackResourceInner>> listByResourceGroupSinglePageAsync(
        String resourceGroupName, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByResourceGroup(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * List LocalRulestackResource resources by resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 of a LocalRulestackResource list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<LocalRulestackResourceInner> listByResourceGroupAsync(String resourceGroupName) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink));
    }

    /**
     * List LocalRulestackResource resources by resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 of a LocalRulestackResource list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<LocalRulestackResourceInner> listByResourceGroupAsync(String resourceGroupName, Context context) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName, context),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context));
    }

    /**
     * List LocalRulestackResource resources by resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 of a LocalRulestackResource list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<LocalRulestackResourceInner> listByResourceGroup(String resourceGroupName) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName));
    }

    /**
     * List LocalRulestackResource resources by resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 of a LocalRulestackResource list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<LocalRulestackResourceInner> listByResourceGroup(String resourceGroupName, Context context) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context));
    }

    /**
     * Get a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 LocalRulestackResource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<LocalRulestackResourceInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String localRulestackName) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getByResourceGroup(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 a LocalRulestackResource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<LocalRulestackResourceInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String localRulestackName, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getByResourceGroup(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                accept,
                context);
    }

    /**
     * Get a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 LocalRulestackResource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<LocalRulestackResourceInner> getByResourceGroupAsync(
        String resourceGroupName, String localRulestackName) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, localRulestackName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 a LocalRulestackResource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<LocalRulestackResourceInner> getByResourceGroupWithResponse(
        String resourceGroupName, String localRulestackName, Context context) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, localRulestackName, context).block();
    }

    /**
     * Get a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 LocalRulestackResource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public LocalRulestackResourceInner getByResourceGroup(String resourceGroupName, String localRulestackName) {
        return getByResourceGroupWithResponse(resourceGroupName, localRulestackName, Context.NONE).getValue();
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 paloAltoNetworks LocalRulestack along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        if (resource == null) {
            return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            resource,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 paloAltoNetworks LocalRulestack along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        if (resource == null) {
            return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                resource,
                accept,
                context);
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 PollerFlux} for polling of paloAltoNetworks LocalRulestack.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<LocalRulestackResourceInner>, LocalRulestackResourceInner> beginCreateOrUpdateAsync(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(resourceGroupName, localRulestackName, resource);
        return this
            .client
            .<LocalRulestackResourceInner, LocalRulestackResourceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                LocalRulestackResourceInner.class,
                LocalRulestackResourceInner.class,
                this.client.getContext());
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 PollerFlux} for polling of paloAltoNetworks LocalRulestack.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<LocalRulestackResourceInner>, LocalRulestackResourceInner> beginCreateOrUpdateAsync(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(resourceGroupName, localRulestackName, resource, context);
        return this
            .client
            .<LocalRulestackResourceInner, LocalRulestackResourceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                LocalRulestackResourceInner.class,
                LocalRulestackResourceInner.class,
                context);
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 SyncPoller} for polling of paloAltoNetworks LocalRulestack.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<LocalRulestackResourceInner>, LocalRulestackResourceInner> beginCreateOrUpdate(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource) {
        return this.beginCreateOrUpdateAsync(resourceGroupName, localRulestackName, resource).getSyncPoller();
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 SyncPoller} for polling of paloAltoNetworks LocalRulestack.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<LocalRulestackResourceInner>, LocalRulestackResourceInner> beginCreateOrUpdate(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource, Context context) {
        return this.beginCreateOrUpdateAsync(resourceGroupName, localRulestackName, resource, context).getSyncPoller();
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 paloAltoNetworks LocalRulestack on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<LocalRulestackResourceInner> createOrUpdateAsync(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource) {
        return beginCreateOrUpdateAsync(resourceGroupName, localRulestackName, resource)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 paloAltoNetworks LocalRulestack on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<LocalRulestackResourceInner> createOrUpdateAsync(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource, Context context) {
        return beginCreateOrUpdateAsync(resourceGroupName, localRulestackName, resource, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 paloAltoNetworks LocalRulestack.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public LocalRulestackResourceInner createOrUpdate(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource) {
        return createOrUpdateAsync(resourceGroupName, localRulestackName, resource).block();
    }

    /**
     * Create a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param resource Resource create parameters.
     * @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 paloAltoNetworks LocalRulestack.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public LocalRulestackResourceInner createOrUpdate(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceInner resource, Context context) {
        return createOrUpdateAsync(resourceGroupName, localRulestackName, resource, context).block();
    }

    /**
     * Update a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param properties The resource properties to be updated.
     * @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 paloAltoNetworks LocalRulestack along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<LocalRulestackResourceInner>> updateWithResponseAsync(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceUpdate properties) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        if (properties == null) {
            return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null."));
        } else {
            properties.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            properties,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param properties The resource properties to be updated.
     * @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 paloAltoNetworks LocalRulestack along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<LocalRulestackResourceInner>> updateWithResponseAsync(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceUpdate properties, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        if (properties == null) {
            return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null."));
        } else {
            properties.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                properties,
                accept,
                context);
    }

    /**
     * Update a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param properties The resource properties to be updated.
     * @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 paloAltoNetworks LocalRulestack on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<LocalRulestackResourceInner> updateAsync(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceUpdate properties) {
        return updateWithResponseAsync(resourceGroupName, localRulestackName, properties)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Update a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param properties The resource properties to be updated.
     * @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 paloAltoNetworks LocalRulestack along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<LocalRulestackResourceInner> updateWithResponse(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceUpdate properties, Context context) {
        return updateWithResponseAsync(resourceGroupName, localRulestackName, properties, context).block();
    }

    /**
     * Update a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param properties The resource properties to be updated.
     * @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 paloAltoNetworks LocalRulestack.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public LocalRulestackResourceInner update(
        String resourceGroupName, String localRulestackName, LocalRulestackResourceUpdate properties) {
        return updateWithResponse(resourceGroupName, localRulestackName, properties, Context.NONE).getValue();
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
        String resourceGroupName, String localRulestackName) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
        String resourceGroupName, String localRulestackName, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                accept,
                context);
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(String resourceGroupName, String localRulestackName) {
        Mono<Response<Flux<ByteBuffer>>> mono = deleteWithResponseAsync(resourceGroupName, localRulestackName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(
        String resourceGroupName, String localRulestackName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = deleteWithResponseAsync(resourceGroupName, localRulestackName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(String resourceGroupName, String localRulestackName) {
        return this.beginDeleteAsync(resourceGroupName, localRulestackName).getSyncPoller();
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(
        String resourceGroupName, String localRulestackName, Context context) {
        return this.beginDeleteAsync(resourceGroupName, localRulestackName, context).getSyncPoller();
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Void> deleteAsync(String resourceGroupName, String localRulestackName) {
        return beginDeleteAsync(resourceGroupName, localRulestackName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(String resourceGroupName, String localRulestackName, Context context) {
        return beginDeleteAsync(resourceGroupName, localRulestackName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 resourceGroupName, String localRulestackName) {
        deleteAsync(resourceGroupName, localRulestackName).block();
    }

    /**
     * Delete a LocalRulestackResource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String resourceGroupName, String localRulestackName, Context context) {
        deleteAsync(resourceGroupName, localRulestackName, context).block();
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Response<Flux<ByteBuffer>>> commitWithResponseAsync(
        String resourceGroupName, String localRulestackName) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .commit(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Response<Flux<ByteBuffer>>> commitWithResponseAsync(
        String resourceGroupName, String localRulestackName, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .commit(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                accept,
                context);
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginCommitAsync(String resourceGroupName, String localRulestackName) {
        Mono<Response<Flux<ByteBuffer>>> mono = commitWithResponseAsync(resourceGroupName, localRulestackName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginCommitAsync(
        String resourceGroupName, String localRulestackName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = commitWithResponseAsync(resourceGroupName, localRulestackName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginCommit(String resourceGroupName, String localRulestackName) {
        return this.beginCommitAsync(resourceGroupName, localRulestackName).getSyncPoller();
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginCommit(
        String resourceGroupName, String localRulestackName, Context context) {
        return this.beginCommitAsync(resourceGroupName, localRulestackName, context).getSyncPoller();
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Void> commitAsync(String resourceGroupName, String localRulestackName) {
        return beginCommitAsync(resourceGroupName, localRulestackName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> commitAsync(String resourceGroupName, String localRulestackName, Context context) {
        return beginCommitAsync(resourceGroupName, localRulestackName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 commit(String resourceGroupName, String localRulestackName) {
        commitAsync(resourceGroupName, localRulestackName).block();
    }

    /**
     * Commit rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void commit(String resourceGroupName, String localRulestackName, Context context) {
        commitAsync(resourceGroupName, localRulestackName, context).block();
    }

    /**
     * Get changelog.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 changelog along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ChangelogInner>> getChangeLogWithResponseAsync(
        String resourceGroupName, String localRulestackName) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getChangeLog(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get changelog.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 changelog along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ChangelogInner>> getChangeLogWithResponseAsync(
        String resourceGroupName, String localRulestackName, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getChangeLog(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                accept,
                context);
    }

    /**
     * Get changelog.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 changelog on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ChangelogInner> getChangeLogAsync(String resourceGroupName, String localRulestackName) {
        return getChangeLogWithResponseAsync(resourceGroupName, localRulestackName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get changelog.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 changelog along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ChangelogInner> getChangeLogWithResponse(
        String resourceGroupName, String localRulestackName, Context context) {
        return getChangeLogWithResponseAsync(resourceGroupName, localRulestackName, context).block();
    }

    /**
     * Get changelog.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 changelog.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ChangelogInner getChangeLog(String resourceGroupName, String localRulestackName) {
        return getChangeLogWithResponse(resourceGroupName, localRulestackName, Context.NONE).getValue();
    }

    /**
     * support info for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param email email address on behalf of which this API called.
     * @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 support information for the resource along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SupportInfoInner>> getSupportInfoWithResponseAsync(
        String resourceGroupName, String localRulestackName, String email) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getSupportInfo(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            email,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * support info for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param email email address on behalf of which this API called.
     * @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 support information for the resource along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SupportInfoInner>> getSupportInfoWithResponseAsync(
        String resourceGroupName, String localRulestackName, String email, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getSupportInfo(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                email,
                accept,
                context);
    }

    /**
     * support info for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 support information for the resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SupportInfoInner> getSupportInfoAsync(String resourceGroupName, String localRulestackName) {
        final String email = null;
        return getSupportInfoWithResponseAsync(resourceGroupName, localRulestackName, email)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * support info for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param email email address on behalf of which this API called.
     * @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 support information for the resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SupportInfoInner> getSupportInfoWithResponse(
        String resourceGroupName, String localRulestackName, String email, Context context) {
        return getSupportInfoWithResponseAsync(resourceGroupName, localRulestackName, email, context).block();
    }

    /**
     * support info for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 support information for the resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SupportInfoInner getSupportInfo(String resourceGroupName, String localRulestackName) {
        final String email = null;
        return getSupportInfoWithResponse(resourceGroupName, localRulestackName, email, Context.NONE).getValue();
    }

    /**
     * Get the list of advanced security objects.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 advanced security objects along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AdvSecurityObjectListResponseInner>> listAdvancedSecurityObjectsWithResponseAsync(
        String resourceGroupName, String localRulestackName, AdvSecurityObjectTypeEnum type, String skip, Integer top) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        if (type == null) {
            return Mono.error(new IllegalArgumentException("Parameter type is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listAdvancedSecurityObjects(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            skip,
                            top,
                            type,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the list of advanced security objects.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 advanced security objects along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AdvSecurityObjectListResponseInner>> listAdvancedSecurityObjectsWithResponseAsync(
        String resourceGroupName,
        String localRulestackName,
        AdvSecurityObjectTypeEnum type,
        String skip,
        Integer top,
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        if (type == null) {
            return Mono.error(new IllegalArgumentException("Parameter type is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listAdvancedSecurityObjects(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                skip,
                top,
                type,
                accept,
                context);
    }

    /**
     * Get the list of advanced security objects.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @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 advanced security objects on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AdvSecurityObjectListResponseInner> listAdvancedSecurityObjectsAsync(
        String resourceGroupName, String localRulestackName, AdvSecurityObjectTypeEnum type) {
        final String skip = null;
        final Integer top = null;
        return listAdvancedSecurityObjectsWithResponseAsync(resourceGroupName, localRulestackName, type, skip, top)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get the list of advanced security objects.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 advanced security objects along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AdvSecurityObjectListResponseInner> listAdvancedSecurityObjectsWithResponse(
        String resourceGroupName,
        String localRulestackName,
        AdvSecurityObjectTypeEnum type,
        String skip,
        Integer top,
        Context context) {
        return listAdvancedSecurityObjectsWithResponseAsync(
                resourceGroupName, localRulestackName, type, skip, top, context)
            .block();
    }

    /**
     * Get the list of advanced security objects.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @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 advanced security objects.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AdvSecurityObjectListResponseInner listAdvancedSecurityObjects(
        String resourceGroupName, String localRulestackName, AdvSecurityObjectTypeEnum type) {
        final String skip = null;
        final Integer top = null;
        return listAdvancedSecurityObjectsWithResponse(
                resourceGroupName, localRulestackName, type, skip, top, Context.NONE)
            .getValue();
    }

    /**
     * List of AppIds for LocalRulestack ApiVersion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param appIdVersion The appIdVersion parameter.
     * @param appPrefix The appPrefix parameter.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 body along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ListAppIdResponseInner>> listAppIdsWithResponseAsync(
        String resourceGroupName,
        String localRulestackName,
        String appIdVersion,
        String appPrefix,
        String skip,
        Integer top) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listAppIds(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            appIdVersion,
                            appPrefix,
                            skip,
                            top,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List of AppIds for LocalRulestack ApiVersion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param appIdVersion The appIdVersion parameter.
     * @param appPrefix The appPrefix parameter.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 body along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ListAppIdResponseInner>> listAppIdsWithResponseAsync(
        String resourceGroupName,
        String localRulestackName,
        String appIdVersion,
        String appPrefix,
        String skip,
        Integer top,
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listAppIds(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                appIdVersion,
                appPrefix,
                skip,
                top,
                accept,
                context);
    }

    /**
     * List of AppIds for LocalRulestack ApiVersion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 body on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ListAppIdResponseInner> listAppIdsAsync(String resourceGroupName, String localRulestackName) {
        final String appIdVersion = null;
        final String appPrefix = null;
        final String skip = null;
        final Integer top = null;
        return listAppIdsWithResponseAsync(resourceGroupName, localRulestackName, appIdVersion, appPrefix, skip, top)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * List of AppIds for LocalRulestack ApiVersion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param appIdVersion The appIdVersion parameter.
     * @param appPrefix The appPrefix parameter.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 body along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ListAppIdResponseInner> listAppIdsWithResponse(
        String resourceGroupName,
        String localRulestackName,
        String appIdVersion,
        String appPrefix,
        String skip,
        Integer top,
        Context context) {
        return listAppIdsWithResponseAsync(
                resourceGroupName, localRulestackName, appIdVersion, appPrefix, skip, top, context)
            .block();
    }

    /**
     * List of AppIds for LocalRulestack ApiVersion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ListAppIdResponseInner listAppIds(String resourceGroupName, String localRulestackName) {
        final String appIdVersion = null;
        final String appPrefix = null;
        final String skip = null;
        final Integer top = null;
        return listAppIdsWithResponse(
                resourceGroupName, localRulestackName, appIdVersion, appPrefix, skip, top, Context.NONE)
            .getValue();
    }

    /**
     * List of countries for Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 countries Response Object along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CountriesResponseInner>> listCountriesWithResponseAsync(
        String resourceGroupName, String localRulestackName, String skip, Integer top) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listCountries(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            skip,
                            top,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List of countries for Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 countries Response Object along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CountriesResponseInner>> listCountriesWithResponseAsync(
        String resourceGroupName, String localRulestackName, String skip, Integer top, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listCountries(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                skip,
                top,
                accept,
                context);
    }

    /**
     * List of countries for Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 countries Response Object on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CountriesResponseInner> listCountriesAsync(String resourceGroupName, String localRulestackName) {
        final String skip = null;
        final Integer top = null;
        return listCountriesWithResponseAsync(resourceGroupName, localRulestackName, skip, top)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * List of countries for Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 countries Response Object along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<CountriesResponseInner> listCountriesWithResponse(
        String resourceGroupName, String localRulestackName, String skip, Integer top, Context context) {
        return listCountriesWithResponseAsync(resourceGroupName, localRulestackName, skip, top, context).block();
    }

    /**
     * List of countries for Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 countries Response Object.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CountriesResponseInner listCountries(String resourceGroupName, String localRulestackName) {
        final String skip = null;
        final Integer top = null;
        return listCountriesWithResponse(resourceGroupName, localRulestackName, skip, top, Context.NONE).getValue();
    }

    /**
     * List of Firewalls associated with Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 list firewalls response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ListFirewallsResponseInner>> listFirewallsWithResponseAsync(
        String resourceGroupName, String localRulestackName) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listFirewalls(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List of Firewalls associated with Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 list firewalls response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ListFirewallsResponseInner>> listFirewallsWithResponseAsync(
        String resourceGroupName, String localRulestackName, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listFirewalls(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                accept,
                context);
    }

    /**
     * List of Firewalls associated with Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 list firewalls response on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ListFirewallsResponseInner> listFirewallsAsync(String resourceGroupName, String localRulestackName) {
        return listFirewallsWithResponseAsync(resourceGroupName, localRulestackName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * List of Firewalls associated with Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 list firewalls response along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ListFirewallsResponseInner> listFirewallsWithResponse(
        String resourceGroupName, String localRulestackName, Context context) {
        return listFirewallsWithResponseAsync(resourceGroupName, localRulestackName, context).block();
    }

    /**
     * List of Firewalls associated with Rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 list firewalls response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ListFirewallsResponseInner listFirewalls(String resourceGroupName, String localRulestackName) {
        return listFirewallsWithResponse(resourceGroupName, localRulestackName, Context.NONE).getValue();
    }

    /**
     * List predefined URL categories for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 predefined url categories response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<PredefinedUrlCategoriesResponseInner>> listPredefinedUrlCategoriesWithResponseAsync(
        String resourceGroupName, String localRulestackName, String skip, Integer top) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listPredefinedUrlCategories(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            skip,
                            top,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List predefined URL categories for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 predefined url categories response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<PredefinedUrlCategoriesResponseInner>> listPredefinedUrlCategoriesWithResponseAsync(
        String resourceGroupName, String localRulestackName, String skip, Integer top, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listPredefinedUrlCategories(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                skip,
                top,
                accept,
                context);
    }

    /**
     * List predefined URL categories for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 predefined url categories response on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PredefinedUrlCategoriesResponseInner> listPredefinedUrlCategoriesAsync(
        String resourceGroupName, String localRulestackName) {
        final String skip = null;
        final Integer top = null;
        return listPredefinedUrlCategoriesWithResponseAsync(resourceGroupName, localRulestackName, skip, top)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * List predefined URL categories for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 predefined url categories response along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<PredefinedUrlCategoriesResponseInner> listPredefinedUrlCategoriesWithResponse(
        String resourceGroupName, String localRulestackName, String skip, Integer top, Context context) {
        return listPredefinedUrlCategoriesWithResponseAsync(resourceGroupName, localRulestackName, skip, top, context)
            .block();
    }

    /**
     * List predefined URL categories for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 predefined url categories response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PredefinedUrlCategoriesResponseInner listPredefinedUrlCategories(
        String resourceGroupName, String localRulestackName) {
        final String skip = null;
        final Integer top = null;
        return listPredefinedUrlCategoriesWithResponse(resourceGroupName, localRulestackName, skip, top, Context.NONE)
            .getValue();
    }

    /**
     * List the security services for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 security services list response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SecurityServicesResponseInner>> listSecurityServicesWithResponseAsync(
        String resourceGroupName, String localRulestackName, SecurityServicesTypeEnum type, String skip, Integer top) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        if (type == null) {
            return Mono.error(new IllegalArgumentException("Parameter type is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listSecurityServices(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            skip,
                            top,
                            type,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List the security services for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 security services list response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SecurityServicesResponseInner>> listSecurityServicesWithResponseAsync(
        String resourceGroupName,
        String localRulestackName,
        SecurityServicesTypeEnum type,
        String skip,
        Integer top,
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        if (type == null) {
            return Mono.error(new IllegalArgumentException("Parameter type is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listSecurityServices(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                skip,
                top,
                type,
                accept,
                context);
    }

    /**
     * List the security services for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @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 security services list response on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SecurityServicesResponseInner> listSecurityServicesAsync(
        String resourceGroupName, String localRulestackName, SecurityServicesTypeEnum type) {
        final String skip = null;
        final Integer top = null;
        return listSecurityServicesWithResponseAsync(resourceGroupName, localRulestackName, type, skip, top)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * List the security services for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @param skip The skip parameter.
     * @param top The top parameter.
     * @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 security services list response along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SecurityServicesResponseInner> listSecurityServicesWithResponse(
        String resourceGroupName,
        String localRulestackName,
        SecurityServicesTypeEnum type,
        String skip,
        Integer top,
        Context context) {
        return listSecurityServicesWithResponseAsync(resourceGroupName, localRulestackName, type, skip, top, context)
            .block();
    }

    /**
     * List the security services for rulestack.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @param type The type parameter.
     * @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 security services list response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SecurityServicesResponseInner listSecurityServices(
        String resourceGroupName, String localRulestackName, SecurityServicesTypeEnum type) {
        final String skip = null;
        final Integer top = null;
        return listSecurityServicesWithResponse(resourceGroupName, localRulestackName, type, skip, top, Context.NONE)
            .getValue();
    }

    /**
     * Revert rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Response<Void>> revertWithResponseAsync(String resourceGroupName, String localRulestackName) {
        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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .revert(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            localRulestackName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Revert rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Response<Void>> revertWithResponseAsync(
        String resourceGroupName, String localRulestackName, 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (localRulestackName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter localRulestackName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .revert(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                localRulestackName,
                accept,
                context);
    }

    /**
     * Revert rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Void> revertAsync(String resourceGroupName, String localRulestackName) {
        return revertWithResponseAsync(resourceGroupName, localRulestackName).flatMap(ignored -> Mono.empty());
    }

    /**
     * Revert rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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<Void> revertWithResponse(String resourceGroupName, String localRulestackName, Context context) {
        return revertWithResponseAsync(resourceGroupName, localRulestackName, context).block();
    }

    /**
     * Revert rulestack configuration.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param localRulestackName LocalRulestack resource name.
     * @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 revert(String resourceGroupName, String localRulestackName) {
        revertWithResponse(resourceGroupName, localRulestackName, Context.NONE);
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @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 of a LocalRulestackResource list operation along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<LocalRulestackResourceInner>> listBySubscriptionNextSinglePageAsync(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.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<LocalRulestackResourceInner>>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
     *     <p>The nextLink parameter.
     * @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 of a LocalRulestackResource list operation along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<LocalRulestackResourceInner>> listBySubscriptionNextSinglePageAsync(
        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
            .listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @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 of a LocalRulestackResource list operation along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<LocalRulestackResourceInner>> listByResourceGroupNextSinglePageAsync(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.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<LocalRulestackResourceInner>>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
     *     <p>The nextLink parameter.
     * @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 of a LocalRulestackResource list operation along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<LocalRulestackResourceInner>> listByResourceGroupNextSinglePageAsync(
        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
            .listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }
}
