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

package com.azure.resourcemanager.networkcloud.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.networkcloud.fluent.StorageAppliancesClient;
import com.azure.resourcemanager.networkcloud.fluent.models.StorageApplianceInner;
import com.azure.resourcemanager.networkcloud.models.StorageApplianceEnableRemoteVendorManagementParameters;
import com.azure.resourcemanager.networkcloud.models.StorageApplianceList;
import com.azure.resourcemanager.networkcloud.models.StorageAppliancePatchParameters;
import com.azure.resourcemanager.networkcloud.models.StorageApplianceRunReadCommandsParameters;
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 StorageAppliancesClient. */
public final class StorageAppliancesClientImpl implements StorageAppliancesClient {
    /** The proxy service used to perform REST calls. */
    private final StorageAppliancesService service;

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

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

    /**
     * The interface defining all the services for NetworkCloudStorageAppliances to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "NetworkCloudStorageA")
    public interface StorageAppliancesService {
        @Headers({"Content-Type: application/json"})
        @Get("/subscriptions/{subscriptionId}/providers/Microsoft.NetworkCloud/storageAppliances")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<StorageApplianceList>> 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/Microsoft.NetworkCloud/storageAppliances")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<StorageApplianceList>> 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/Microsoft.NetworkCloud/storageAppliances/{storageApplianceName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<StorageApplianceInner>> getByResourceGroup(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("storageApplianceName") String storageApplianceName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/storageAppliances/{storageApplianceName}")
        @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("storageApplianceName") String storageApplianceName,
            @BodyParam("application/json") StorageApplianceInner storageApplianceParameters,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/storageAppliances/{storageApplianceName}")
        @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("storageApplianceName") String storageApplianceName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/storageAppliances/{storageApplianceName}")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> update(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("storageApplianceName") String storageApplianceName,
            @BodyParam("application/json") StorageAppliancePatchParameters storageApplianceUpdateParameters,
            @HeaderParam("Accept") String accept,
            Context context);

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

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/storageAppliances/{storageApplianceName}/enableRemoteVendorManagement")
        @ExpectedResponses({202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> enableRemoteVendorManagement(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("storageApplianceName") String storageApplianceName,
            @BodyParam("application/json")
                StorageApplianceEnableRemoteVendorManagementParameters
                    storageApplianceEnableRemoteVendorManagementParameters,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/storageAppliances/{storageApplianceName}/runReadCommands")
        @ExpectedResponses({202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> runReadCommands(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("storageApplianceName") String storageApplianceName,
            @BodyParam("application/json")
                StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters,
            @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * List storage appliances in the subscription.
     *
     * <p>Get a list of storage appliances in the provided subscription.
     *
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of storage appliances in the provided subscription along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<StorageApplianceInner>> 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<StorageApplianceInner>>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 storage appliances in the subscription.
     *
     * <p>Get a list of storage appliances in the provided subscription.
     *
     * @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 list of storage appliances in the provided subscription along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<StorageApplianceInner>> 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 storage appliances in the subscription.
     *
     * <p>Get a list of storage appliances in the provided subscription.
     *
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of storage appliances in the provided subscription as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<StorageApplianceInner> listAsync() {
        return new PagedFlux<>(
            () -> listSinglePageAsync(), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink));
    }

    /**
     * List storage appliances in the subscription.
     *
     * <p>Get a list of storage appliances in the provided subscription.
     *
     * @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 list of storage appliances in the provided subscription as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<StorageApplianceInner> listAsync(Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(context), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context));
    }

    /**
     * List storage appliances in the subscription.
     *
     * <p>Get a list of storage appliances in the provided subscription.
     *
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of storage appliances in the provided subscription as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<StorageApplianceInner> list() {
        return new PagedIterable<>(listAsync());
    }

    /**
     * List storage appliances in the subscription.
     *
     * <p>Get a list of storage appliances in the provided subscription.
     *
     * @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 list of storage appliances in the provided subscription as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<StorageApplianceInner> list(Context context) {
        return new PagedIterable<>(listAsync(context));
    }

    /**
     * List storage appliances in the resource group.
     *
     * <p>Get a list of storage appliances in the provided 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 a list of storage appliances in the provided resource group along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<StorageApplianceInner>> 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<StorageApplianceInner>>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 storage appliances in the resource group.
     *
     * <p>Get a list of storage appliances in the provided 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 a list of storage appliances in the provided resource group along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<StorageApplianceInner>> 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 storage appliances in the resource group.
     *
     * <p>Get a list of storage appliances in the provided 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 a list of storage appliances in the provided resource group as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<StorageApplianceInner> listByResourceGroupAsync(String resourceGroupName) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink));
    }

    /**
     * List storage appliances in the resource group.
     *
     * <p>Get a list of storage appliances in the provided 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 a list of storage appliances in the provided resource group as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<StorageApplianceInner> listByResourceGroupAsync(String resourceGroupName, Context context) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName, context),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context));
    }

    /**
     * List storage appliances in the resource group.
     *
     * <p>Get a list of storage appliances in the provided 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 a list of storage appliances in the provided resource group as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<StorageApplianceInner> listByResourceGroup(String resourceGroupName) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName));
    }

    /**
     * List storage appliances in the resource group.
     *
     * <p>Get a list of storage appliances in the provided 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 a list of storage appliances in the provided resource group as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<StorageApplianceInner> listByResourceGroup(String resourceGroupName, Context context) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context));
    }

    /**
     * Retrieve the storage appliance.
     *
     * <p>Get properties of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 properties of the provided storage appliance along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<StorageApplianceInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String storageApplianceName) {
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName 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,
                            storageApplianceName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Retrieve the storage appliance.
     *
     * <p>Get properties of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 properties of the provided storage appliance along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<StorageApplianceInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String storageApplianceName, 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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName 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,
                storageApplianceName,
                accept,
                context);
    }

    /**
     * Retrieve the storage appliance.
     *
     * <p>Get properties of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 properties of the provided storage appliance on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<StorageApplianceInner> getByResourceGroupAsync(String resourceGroupName, String storageApplianceName) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, storageApplianceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Retrieve the storage appliance.
     *
     * <p>Get properties of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 properties of the provided storage appliance along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<StorageApplianceInner> getByResourceGroupWithResponse(
        String resourceGroupName, String storageApplianceName, Context context) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, storageApplianceName, context).block();
    }

    /**
     * Retrieve the storage appliance.
     *
     * <p>Get properties of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 properties of the provided storage appliance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public StorageApplianceInner getByResourceGroup(String resourceGroupName, String storageApplianceName) {
        return getByResourceGroupWithResponse(resourceGroupName, storageApplianceName, Context.NONE).getValue();
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String storageApplianceName, StorageApplianceInner storageApplianceParameters) {
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        if (storageApplianceParameters == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter storageApplianceParameters is required and cannot be null."));
        } else {
            storageApplianceParameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            storageApplianceName,
                            storageApplianceParameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceInner storageApplianceParameters,
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        if (storageApplianceParameters == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter storageApplianceParameters is required and cannot be null."));
        } else {
            storageApplianceParameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                storageApplianceName,
                storageApplianceParameters,
                accept,
                context);
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage
     *     appliance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<StorageApplianceInner>, StorageApplianceInner> beginCreateOrUpdateAsync(
        String resourceGroupName, String storageApplianceName, StorageApplianceInner storageApplianceParameters) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(resourceGroupName, storageApplianceName, storageApplianceParameters);
        return this
            .client
            .<StorageApplianceInner, StorageApplianceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                StorageApplianceInner.class,
                StorageApplianceInner.class,
                this.client.getContext());
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage
     *     appliance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<StorageApplianceInner>, StorageApplianceInner> beginCreateOrUpdateAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceInner storageApplianceParameters,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(
                resourceGroupName, storageApplianceName, storageApplianceParameters, context);
        return this
            .client
            .<StorageApplianceInner, StorageApplianceInner>getLroResult(
                mono, this.client.getHttpPipeline(), StorageApplianceInner.class, StorageApplianceInner.class, context);
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage
     *     appliance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<StorageApplianceInner>, StorageApplianceInner> beginCreateOrUpdate(
        String resourceGroupName, String storageApplianceName, StorageApplianceInner storageApplianceParameters) {
        return this
            .beginCreateOrUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceParameters)
            .getSyncPoller();
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage
     *     appliance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<StorageApplianceInner>, StorageApplianceInner> beginCreateOrUpdate(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceInner storageApplianceParameters,
        Context context) {
        return this
            .beginCreateOrUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceParameters, context)
            .getSyncPoller();
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<StorageApplianceInner> createOrUpdateAsync(
        String resourceGroupName, String storageApplianceName, StorageApplianceInner storageApplianceParameters) {
        return beginCreateOrUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceParameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<StorageApplianceInner> createOrUpdateAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceInner storageApplianceParameters,
        Context context) {
        return beginCreateOrUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceParameters, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public StorageApplianceInner createOrUpdate(
        String resourceGroupName, String storageApplianceName, StorageApplianceInner storageApplianceParameters) {
        return createOrUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceParameters).block();
    }

    /**
     * Create or update the storage appliance.
     *
     * <p>Create a new storage appliance or update the properties of the existing one. All customer initiated requests
     * will be rejected as the life cycle of this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public StorageApplianceInner createOrUpdate(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceInner storageApplianceParameters,
        Context context) {
        return createOrUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceParameters, context)
            .block();
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName) {
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName 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,
                            storageApplianceName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName, 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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName 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,
                storageApplianceName,
                accept,
                context);
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName) {
        Mono<Response<Flux<ByteBuffer>>> mono = deleteWithResponseAsync(resourceGroupName, storageApplianceName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(resourceGroupName, storageApplianceName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName) {
        return this.beginDeleteAsync(resourceGroupName, storageApplianceName).getSyncPoller();
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName, Context context) {
        return this.beginDeleteAsync(resourceGroupName, storageApplianceName, context).getSyncPoller();
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName) {
        return beginDeleteAsync(resourceGroupName, storageApplianceName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName, Context context) {
        return beginDeleteAsync(resourceGroupName, storageApplianceName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName) {
        deleteAsync(resourceGroupName, storageApplianceName).block();
    }

    /**
     * Delete the storage appliance.
     *
     * <p>Delete the provided storage appliance. All customer initiated requests will be rejected as the life cycle of
     * this resource is managed by the system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageApplianceName, Context context) {
        deleteAsync(resourceGroupName, storageApplianceName, context).block();
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceUpdateParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageAppliancePatchParameters storageApplianceUpdateParameters) {
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        if (storageApplianceUpdateParameters != null) {
            storageApplianceUpdateParameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            storageApplianceName,
                            storageApplianceUpdateParameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceUpdateParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageAppliancePatchParameters storageApplianceUpdateParameters,
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        if (storageApplianceUpdateParameters != null) {
            storageApplianceUpdateParameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                storageApplianceName,
                storageApplianceUpdateParameters,
                accept,
                context);
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceUpdateParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage
     *     appliance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<StorageApplianceInner>, StorageApplianceInner> beginUpdateAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageAppliancePatchParameters storageApplianceUpdateParameters) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters);
        return this
            .client
            .<StorageApplianceInner, StorageApplianceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                StorageApplianceInner.class,
                StorageApplianceInner.class,
                this.client.getContext());
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageAppliance represents on-premises Network Cloud storage
     *     appliance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<StorageApplianceInner>, StorageApplianceInner> beginUpdateAsync(
        String resourceGroupName, String storageApplianceName) {
        final StorageAppliancePatchParameters storageApplianceUpdateParameters = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters);
        return this
            .client
            .<StorageApplianceInner, StorageApplianceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                StorageApplianceInner.class,
                StorageApplianceInner.class,
                this.client.getContext());
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceUpdateParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage
     *     appliance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<StorageApplianceInner>, StorageApplianceInner> beginUpdateAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageAppliancePatchParameters storageApplianceUpdateParameters,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters, context);
        return this
            .client
            .<StorageApplianceInner, StorageApplianceInner>getLroResult(
                mono, this.client.getHttpPipeline(), StorageApplianceInner.class, StorageApplianceInner.class, context);
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageAppliance represents on-premises Network Cloud storage
     *     appliance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<StorageApplianceInner>, StorageApplianceInner> beginUpdate(
        String resourceGroupName, String storageApplianceName) {
        final StorageAppliancePatchParameters storageApplianceUpdateParameters = null;
        return this
            .beginUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters)
            .getSyncPoller();
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceUpdateParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage
     *     appliance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<StorageApplianceInner>, StorageApplianceInner> beginUpdate(
        String resourceGroupName,
        String storageApplianceName,
        StorageAppliancePatchParameters storageApplianceUpdateParameters,
        Context context) {
        return this
            .beginUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters, context)
            .getSyncPoller();
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceUpdateParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<StorageApplianceInner> updateAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageAppliancePatchParameters storageApplianceUpdateParameters) {
        return beginUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<StorageApplianceInner> updateAsync(String resourceGroupName, String storageApplianceName) {
        final StorageAppliancePatchParameters storageApplianceUpdateParameters = null;
        return beginUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceUpdateParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<StorageApplianceInner> updateAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageAppliancePatchParameters storageApplianceUpdateParameters,
        Context context) {
        return beginUpdateAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public StorageApplianceInner update(String resourceGroupName, String storageApplianceName) {
        final StorageAppliancePatchParameters storageApplianceUpdateParameters = null;
        return updateAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters).block();
    }

    /**
     * Patch the storage appliance.
     *
     * <p>Update properties of the provided storage appliance, or update tags associated with the storage appliance
     * Properties and tag updates can be done independently.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceUpdateParameters The request body.
     * @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 storageAppliance represents on-premises Network Cloud storage appliance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public StorageApplianceInner update(
        String resourceGroupName,
        String storageApplianceName,
        StorageAppliancePatchParameters storageApplianceUpdateParameters,
        Context context) {
        return updateAsync(resourceGroupName, storageApplianceName, storageApplianceUpdateParameters, context).block();
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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>>> disableRemoteVendorManagementWithResponseAsync(
        String resourceGroupName, String storageApplianceName) {
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .disableRemoteVendorManagement(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            storageApplianceName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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>>> disableRemoteVendorManagementWithResponseAsync(
        String resourceGroupName, String storageApplianceName, 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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .disableRemoteVendorManagement(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                storageApplianceName,
                accept,
                context);
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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> beginDisableRemoteVendorManagementAsync(
        String resourceGroupName, String storageApplianceName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            disableRemoteVendorManagementWithResponseAsync(resourceGroupName, storageApplianceName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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> beginDisableRemoteVendorManagementAsync(
        String resourceGroupName, String storageApplianceName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            disableRemoteVendorManagementWithResponseAsync(resourceGroupName, storageApplianceName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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> beginDisableRemoteVendorManagement(
        String resourceGroupName, String storageApplianceName) {
        return this.beginDisableRemoteVendorManagementAsync(resourceGroupName, storageApplianceName).getSyncPoller();
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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> beginDisableRemoteVendorManagement(
        String resourceGroupName, String storageApplianceName, Context context) {
        return this
            .beginDisableRemoteVendorManagementAsync(resourceGroupName, storageApplianceName, context)
            .getSyncPoller();
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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> disableRemoteVendorManagementAsync(String resourceGroupName, String storageApplianceName) {
        return beginDisableRemoteVendorManagementAsync(resourceGroupName, storageApplianceName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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> disableRemoteVendorManagementAsync(
        String resourceGroupName, String storageApplianceName, Context context) {
        return beginDisableRemoteVendorManagementAsync(resourceGroupName, storageApplianceName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 disableRemoteVendorManagement(String resourceGroupName, String storageApplianceName) {
        disableRemoteVendorManagementAsync(resourceGroupName, storageApplianceName).block();
    }

    /**
     * Turn off remote vendor management for a storage appliance, if supported.
     *
     * <p>Disable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 disableRemoteVendorManagement(String resourceGroupName, String storageApplianceName, Context context) {
        disableRemoteVendorManagementAsync(resourceGroupName, storageApplianceName, context).block();
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceEnableRemoteVendorManagementParameters The request body.
     * @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>>> enableRemoteVendorManagementWithResponseAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceEnableRemoteVendorManagementParameters storageApplianceEnableRemoteVendorManagementParameters) {
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        if (storageApplianceEnableRemoteVendorManagementParameters != null) {
            storageApplianceEnableRemoteVendorManagementParameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .enableRemoteVendorManagement(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            storageApplianceName,
                            storageApplianceEnableRemoteVendorManagementParameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceEnableRemoteVendorManagementParameters The request body.
     * @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>>> enableRemoteVendorManagementWithResponseAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceEnableRemoteVendorManagementParameters storageApplianceEnableRemoteVendorManagementParameters,
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        if (storageApplianceEnableRemoteVendorManagementParameters != null) {
            storageApplianceEnableRemoteVendorManagementParameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .enableRemoteVendorManagement(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                storageApplianceName,
                storageApplianceEnableRemoteVendorManagementParameters,
                accept,
                context);
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceEnableRemoteVendorManagementParameters The request body.
     * @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> beginEnableRemoteVendorManagementAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceEnableRemoteVendorManagementParameters storageApplianceEnableRemoteVendorManagementParameters) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            enableRemoteVendorManagementWithResponseAsync(
                resourceGroupName, storageApplianceName, storageApplianceEnableRemoteVendorManagementParameters);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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> beginEnableRemoteVendorManagementAsync(
        String resourceGroupName, String storageApplianceName) {
        final StorageApplianceEnableRemoteVendorManagementParameters
            storageApplianceEnableRemoteVendorManagementParameters = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            enableRemoteVendorManagementWithResponseAsync(
                resourceGroupName, storageApplianceName, storageApplianceEnableRemoteVendorManagementParameters);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceEnableRemoteVendorManagementParameters The request body.
     * @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> beginEnableRemoteVendorManagementAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceEnableRemoteVendorManagementParameters storageApplianceEnableRemoteVendorManagementParameters,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            enableRemoteVendorManagementWithResponseAsync(
                resourceGroupName,
                storageApplianceName,
                storageApplianceEnableRemoteVendorManagementParameters,
                context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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> beginEnableRemoteVendorManagement(
        String resourceGroupName, String storageApplianceName) {
        final StorageApplianceEnableRemoteVendorManagementParameters
            storageApplianceEnableRemoteVendorManagementParameters = null;
        return this
            .beginEnableRemoteVendorManagementAsync(
                resourceGroupName, storageApplianceName, storageApplianceEnableRemoteVendorManagementParameters)
            .getSyncPoller();
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceEnableRemoteVendorManagementParameters The request body.
     * @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> beginEnableRemoteVendorManagement(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceEnableRemoteVendorManagementParameters storageApplianceEnableRemoteVendorManagementParameters,
        Context context) {
        return this
            .beginEnableRemoteVendorManagementAsync(
                resourceGroupName,
                storageApplianceName,
                storageApplianceEnableRemoteVendorManagementParameters,
                context)
            .getSyncPoller();
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceEnableRemoteVendorManagementParameters The request body.
     * @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> enableRemoteVendorManagementAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceEnableRemoteVendorManagementParameters storageApplianceEnableRemoteVendorManagementParameters) {
        return beginEnableRemoteVendorManagementAsync(
                resourceGroupName, storageApplianceName, storageApplianceEnableRemoteVendorManagementParameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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> enableRemoteVendorManagementAsync(String resourceGroupName, String storageApplianceName) {
        final StorageApplianceEnableRemoteVendorManagementParameters
            storageApplianceEnableRemoteVendorManagementParameters = null;
        return beginEnableRemoteVendorManagementAsync(
                resourceGroupName, storageApplianceName, storageApplianceEnableRemoteVendorManagementParameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceEnableRemoteVendorManagementParameters The request body.
     * @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> enableRemoteVendorManagementAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceEnableRemoteVendorManagementParameters storageApplianceEnableRemoteVendorManagementParameters,
        Context context) {
        return beginEnableRemoteVendorManagementAsync(
                resourceGroupName,
                storageApplianceName,
                storageApplianceEnableRemoteVendorManagementParameters,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @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 enableRemoteVendorManagement(String resourceGroupName, String storageApplianceName) {
        final StorageApplianceEnableRemoteVendorManagementParameters
            storageApplianceEnableRemoteVendorManagementParameters = null;
        enableRemoteVendorManagementAsync(
                resourceGroupName, storageApplianceName, storageApplianceEnableRemoteVendorManagementParameters)
            .block();
    }

    /**
     * Turn on remote vendor management for a storage appliance, if supported.
     *
     * <p>Enable remote vendor management of the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceEnableRemoteVendorManagementParameters The request body.
     * @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 enableRemoteVendorManagement(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceEnableRemoteVendorManagementParameters storageApplianceEnableRemoteVendorManagementParameters,
        Context context) {
        enableRemoteVendorManagementAsync(
                resourceGroupName,
                storageApplianceName,
                storageApplianceEnableRemoteVendorManagementParameters,
                context)
            .block();
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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>>> runReadCommandsWithResponseAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters) {
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        if (storageApplianceRunReadCommandsParameters == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter storageApplianceRunReadCommandsParameters is required and cannot be null."));
        } else {
            storageApplianceRunReadCommandsParameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .runReadCommands(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            storageApplianceName,
                            storageApplianceRunReadCommandsParameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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>>> runReadCommandsWithResponseAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters,
        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 (storageApplianceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter storageApplianceName is required and cannot be null."));
        }
        if (storageApplianceRunReadCommandsParameters == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter storageApplianceRunReadCommandsParameters is required and cannot be null."));
        } else {
            storageApplianceRunReadCommandsParameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .runReadCommands(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                storageApplianceName,
                storageApplianceRunReadCommandsParameters,
                accept,
                context);
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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> beginRunReadCommandsAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            runReadCommandsWithResponseAsync(
                resourceGroupName, storageApplianceName, storageApplianceRunReadCommandsParameters);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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> beginRunReadCommandsAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            runReadCommandsWithResponseAsync(
                resourceGroupName, storageApplianceName, storageApplianceRunReadCommandsParameters, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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> beginRunReadCommands(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters) {
        return this
            .beginRunReadCommandsAsync(
                resourceGroupName, storageApplianceName, storageApplianceRunReadCommandsParameters)
            .getSyncPoller();
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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> beginRunReadCommands(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters,
        Context context) {
        return this
            .beginRunReadCommandsAsync(
                resourceGroupName, storageApplianceName, storageApplianceRunReadCommandsParameters, context)
            .getSyncPoller();
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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> runReadCommandsAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters) {
        return beginRunReadCommandsAsync(
                resourceGroupName, storageApplianceName, storageApplianceRunReadCommandsParameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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> runReadCommandsAsync(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters,
        Context context) {
        return beginRunReadCommandsAsync(
                resourceGroupName, storageApplianceName, storageApplianceRunReadCommandsParameters, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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 runReadCommands(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters) {
        runReadCommandsAsync(resourceGroupName, storageApplianceName, storageApplianceRunReadCommandsParameters)
            .block();
    }

    /**
     * Retrieve output from read-only commands exercised against a storage appliance.
     *
     * <p>Run and retrieve output from read only commands on the provided storage appliance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param storageApplianceName The name of the storage appliance.
     * @param storageApplianceRunReadCommandsParameters The request body.
     * @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 runReadCommands(
        String resourceGroupName,
        String storageApplianceName,
        StorageApplianceRunReadCommandsParameters storageApplianceRunReadCommandsParameters,
        Context context) {
        runReadCommandsAsync(
                resourceGroupName, storageApplianceName, storageApplianceRunReadCommandsParameters, context)
            .block();
    }

    /**
     * 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 storageApplianceList represents a list of storage appliances along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<StorageApplianceInner>> 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<StorageApplianceInner>>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 storageApplianceList represents a list of storage appliances along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<StorageApplianceInner>> 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 storageApplianceList represents a list of storage appliances along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<StorageApplianceInner>> 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<StorageApplianceInner>>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 storageApplianceList represents a list of storage appliances along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<StorageApplianceInner>> 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));
    }
}
