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

package com.azure.resourcemanager.storagecache.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.storagecache.fluent.CachesClient;
import com.azure.resourcemanager.storagecache.fluent.models.CacheInner;
import com.azure.resourcemanager.storagecache.models.CachesListResult;
import com.azure.resourcemanager.storagecache.models.PrimingJob;
import com.azure.resourcemanager.storagecache.models.PrimingJobIdParameter;
import com.azure.resourcemanager.storagecache.models.StorageTargetSpaceAllocation;
import java.nio.ByteBuffer;
import java.util.List;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

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

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

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

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

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}")
        @ExpectedResponses({200, 202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> delete(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("cacheName") String cacheName,
            @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.StorageCache/caches/{cacheName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<CacheInner>> getByResourceGroup(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("cacheName") String cacheName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}")
        @ExpectedResponses({200, 201, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("cacheName") String cacheName,
            @BodyParam("application/json") CacheInner cache,
            @HeaderParam("Accept") String accept,
            Context context);

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

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

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

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

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

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/startPrimingJob")
        @ExpectedResponses({202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> startPrimingJob(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("cacheName") String cacheName,
            @BodyParam("application/json") PrimingJob primingjob,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stopPrimingJob")
        @ExpectedResponses({202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> stopPrimingJob(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("cacheName") String cacheName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @BodyParam("application/json") PrimingJobIdParameter primingJobId,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/pausePrimingJob")
        @ExpectedResponses({202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> pausePrimingJob(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("cacheName") String cacheName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @BodyParam("application/json") PrimingJobIdParameter primingJobId,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/resumePrimingJob")
        @ExpectedResponses({202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> resumePrimingJob(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("cacheName") String cacheName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @BodyParam("application/json") PrimingJobIdParameter primingJobId,
            @HeaderParam("Accept") String accept,
            Context context);

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

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/spaceAllocation")
        @ExpectedResponses({202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> spaceAllocation(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("cacheName") String cacheName,
            @BodyParam("application/json") List<StorageTargetSpaceAllocation> spaceAllocation,
            @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CacheInner>> 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<CacheInner>>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()));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CacheInner>> 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));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<CacheInner> listAsync() {
        return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<CacheInner> listAsync(Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<CacheInner> list() {
        return new PagedIterable<>(listAsync());
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<CacheInner> list(Context context) {
        return new PagedIterable<>(listAsync(context));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CacheInner>> listByResourceGroupSinglePageAsync(String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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
                        .listByResourceGroup(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            accept,
                            context))
            .<PagedResponse<CacheInner>>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()));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CacheInner>> 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 (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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
            .listByResourceGroup(
                this.client.getEndpoint(),
                resourceGroupName,
                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));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<CacheInner> listByResourceGroupAsync(String resourceGroupName) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<CacheInner> listByResourceGroupAsync(String resourceGroupName, Context context) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName, context),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<CacheInner> listByResourceGroup(String resourceGroupName) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName));
    }

    /**
     * Returns all caches the user has access to under a 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 result of the request to list caches as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<CacheInner> listByResourceGroup(String resourceGroupName, Context context) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context));
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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
                        .delete(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            cacheName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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
            .delete(
                this.client.getEndpoint(),
                resourceGroupName,
                cacheName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                accept,
                context);
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName) {
        Mono<Response<Flux<ByteBuffer>>> mono = deleteWithResponseAsync(resourceGroupName, cacheName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = deleteWithResponseAsync(resourceGroupName, cacheName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName) {
        return this.beginDeleteAsync(resourceGroupName, cacheName).getSyncPoller();
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName, Context context) {
        return this.beginDeleteAsync(resourceGroupName, cacheName, context).getSyncPoller();
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName) {
        return beginDeleteAsync(resourceGroupName, cacheName).last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName, Context context) {
        return beginDeleteAsync(resourceGroupName, cacheName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName) {
        deleteAsync(resourceGroupName, cacheName).block();
    }

    /**
     * Schedules a cache for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cacheName, Context context) {
        deleteAsync(resourceGroupName, cacheName, context).block();
    }

    /**
     * Returns a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cache instance along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CacheInner>> getByResourceGroupWithResponseAsync(String resourceGroupName, String cacheName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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
                        .getByResourceGroup(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            cacheName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cache instance along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<CacheInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String cacheName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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
            .getByResourceGroup(
                this.client.getEndpoint(),
                resourceGroupName,
                cacheName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                accept,
                context);
    }

    /**
     * Returns a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cache instance on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CacheInner> getByResourceGroupAsync(String resourceGroupName, String cacheName) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, cacheName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Returns a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cache instance along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<CacheInner> getByResourceGroupWithResponse(
        String resourceGroupName, String cacheName, Context context) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, cacheName, context).block();
    }

    /**
     * Returns a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cache instance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CacheInner getByResourceGroup(String resourceGroupName, String cacheName) {
        return getByResourceGroupWithResponse(resourceGroupName, cacheName, Context.NONE).getValue();
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 cache instance along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String cacheName, CacheInner cache) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        if (cache == null) {
            return Mono.error(new IllegalArgumentException("Parameter cache is required and cannot be null."));
        } else {
            cache.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            cacheName,
                            cache,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 cache instance along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        if (cache == null) {
            return Mono.error(new IllegalArgumentException("Parameter cache is required and cannot be null."));
        } else {
            cache.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                cacheName,
                cache,
                accept,
                context);
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 a cache instance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<CacheInner>, CacheInner> beginCreateOrUpdateAsync(
        String resourceGroupName, String cacheName, CacheInner cache) {
        Mono<Response<Flux<ByteBuffer>>> mono = createOrUpdateWithResponseAsync(resourceGroupName, cacheName, cache);
        return this
            .client
            .<CacheInner, CacheInner>getLroResult(
                mono, this.client.getHttpPipeline(), CacheInner.class, CacheInner.class, this.client.getContext());
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 a cache instance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<CacheInner>, CacheInner> beginCreateOrUpdateAsync(
        String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(resourceGroupName, cacheName, cache, context);
        return this
            .client
            .<CacheInner, CacheInner>getLroResult(
                mono, this.client.getHttpPipeline(), CacheInner.class, CacheInner.class, context);
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 a cache instance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<CacheInner>, CacheInner> beginCreateOrUpdate(
        String resourceGroupName, String cacheName, CacheInner cache) {
        return this.beginCreateOrUpdateAsync(resourceGroupName, cacheName, cache).getSyncPoller();
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 a cache instance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<CacheInner>, CacheInner> beginCreateOrUpdate(
        String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        return this.beginCreateOrUpdateAsync(resourceGroupName, cacheName, cache, context).getSyncPoller();
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 cache instance on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CacheInner> createOrUpdateAsync(String resourceGroupName, String cacheName, CacheInner cache) {
        return beginCreateOrUpdateAsync(resourceGroupName, cacheName, cache)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 cache instance on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CacheInner> createOrUpdateAsync(
        String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        return beginCreateOrUpdateAsync(resourceGroupName, cacheName, cache, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 cache instance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CacheInner createOrUpdate(String resourceGroupName, String cacheName, CacheInner cache) {
        return createOrUpdateAsync(resourceGroupName, cacheName, cache).block();
    }

    /**
     * Create or update a cache.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the new cache. If read-only properties are
     *     included, they must match the existing values of those properties.
     * @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 cache instance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CacheInner createOrUpdate(String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        return createOrUpdateAsync(resourceGroupName, cacheName, cache, context).block();
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the cache. If read-only properties are included,
     *     they must match the existing values of those properties.
     * @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 cache instance along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName, String cacheName, CacheInner cache) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        if (cache != null) {
            cache.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            cacheName,
                            cache,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the cache. If read-only properties are included,
     *     they must match the existing values of those properties.
     * @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 cache instance along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        if (cache != null) {
            cache.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                cacheName,
                cache,
                accept,
                context);
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the cache. If read-only properties are included,
     *     they must match the existing values of those properties.
     * @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 a cache instance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<CacheInner>, CacheInner> beginUpdateAsync(
        String resourceGroupName, String cacheName, CacheInner cache) {
        Mono<Response<Flux<ByteBuffer>>> mono = updateWithResponseAsync(resourceGroupName, cacheName, cache);
        return this
            .client
            .<CacheInner, CacheInner>getLroResult(
                mono, this.client.getHttpPipeline(), CacheInner.class, CacheInner.class, this.client.getContext());
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 a cache instance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<CacheInner>, CacheInner> beginUpdateAsync(
        String resourceGroupName, String cacheName) {
        final CacheInner cache = null;
        Mono<Response<Flux<ByteBuffer>>> mono = updateWithResponseAsync(resourceGroupName, cacheName, cache);
        return this
            .client
            .<CacheInner, CacheInner>getLroResult(
                mono, this.client.getHttpPipeline(), CacheInner.class, CacheInner.class, this.client.getContext());
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the cache. If read-only properties are included,
     *     they must match the existing values of those properties.
     * @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 a cache instance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<CacheInner>, CacheInner> beginUpdateAsync(
        String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = updateWithResponseAsync(resourceGroupName, cacheName, cache, context);
        return this
            .client
            .<CacheInner, CacheInner>getLroResult(
                mono, this.client.getHttpPipeline(), CacheInner.class, CacheInner.class, context);
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 a cache instance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<CacheInner>, CacheInner> beginUpdate(String resourceGroupName, String cacheName) {
        final CacheInner cache = null;
        return this.beginUpdateAsync(resourceGroupName, cacheName, cache).getSyncPoller();
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the cache. If read-only properties are included,
     *     they must match the existing values of those properties.
     * @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 a cache instance.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<CacheInner>, CacheInner> beginUpdate(
        String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        return this.beginUpdateAsync(resourceGroupName, cacheName, cache, context).getSyncPoller();
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the cache. If read-only properties are included,
     *     they must match the existing values of those properties.
     * @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 cache instance on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CacheInner> updateAsync(String resourceGroupName, String cacheName, CacheInner cache) {
        return beginUpdateAsync(resourceGroupName, cacheName, cache)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cache instance on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CacheInner> updateAsync(String resourceGroupName, String cacheName) {
        final CacheInner cache = null;
        return beginUpdateAsync(resourceGroupName, cacheName, cache)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the cache. If read-only properties are included,
     *     they must match the existing values of those properties.
     * @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 cache instance on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<CacheInner> updateAsync(
        String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        return beginUpdateAsync(resourceGroupName, cacheName, cache, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 cache instance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CacheInner update(String resourceGroupName, String cacheName) {
        final CacheInner cache = null;
        return updateAsync(resourceGroupName, cacheName, cache).block();
    }

    /**
     * Update a cache instance.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param cache Object containing the user-selectable properties of the cache. If read-only properties are included,
     *     they must match the existing values of those properties.
     * @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 cache instance.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CacheInner update(String resourceGroupName, String cacheName, CacheInner cache, Context context) {
        return updateAsync(resourceGroupName, cacheName, cache, context).block();
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> debugInfoWithResponseAsync(String resourceGroupName, String cacheName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .debugInfo(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            cacheName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> debugInfoWithResponseAsync(
        String resourceGroupName, String cacheName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .debugInfo(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                cacheName,
                accept,
                context);
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginDebugInfoAsync(String resourceGroupName, String cacheName) {
        Mono<Response<Flux<ByteBuffer>>> mono = debugInfoWithResponseAsync(resourceGroupName, cacheName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginDebugInfoAsync(
        String resourceGroupName, String cacheName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = debugInfoWithResponseAsync(resourceGroupName, cacheName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginDebugInfo(String resourceGroupName, String cacheName) {
        return this.beginDebugInfoAsync(resourceGroupName, cacheName).getSyncPoller();
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginDebugInfo(
        String resourceGroupName, String cacheName, Context context) {
        return this.beginDebugInfoAsync(resourceGroupName, cacheName, context).getSyncPoller();
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> debugInfoAsync(String resourceGroupName, String cacheName) {
        return beginDebugInfoAsync(resourceGroupName, cacheName).last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> debugInfoAsync(String resourceGroupName, String cacheName, Context context) {
        return beginDebugInfoAsync(resourceGroupName, cacheName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 debugInfo(String resourceGroupName, String cacheName) {
        debugInfoAsync(resourceGroupName, cacheName).block();
    }

    /**
     * Tells a cache to write generate debug info for support to process.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 debugInfo(String resourceGroupName, String cacheName, Context context) {
        debugInfoAsync(resourceGroupName, cacheName, context).block();
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> flushWithResponseAsync(String resourceGroupName, String cacheName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .flush(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            cacheName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> flushWithResponseAsync(
        String resourceGroupName, String cacheName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .flush(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                cacheName,
                accept,
                context);
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginFlushAsync(String resourceGroupName, String cacheName) {
        Mono<Response<Flux<ByteBuffer>>> mono = flushWithResponseAsync(resourceGroupName, cacheName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginFlushAsync(
        String resourceGroupName, String cacheName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = flushWithResponseAsync(resourceGroupName, cacheName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginFlush(String resourceGroupName, String cacheName) {
        return this.beginFlushAsync(resourceGroupName, cacheName).getSyncPoller();
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginFlush(String resourceGroupName, String cacheName, Context context) {
        return this.beginFlushAsync(resourceGroupName, cacheName, context).getSyncPoller();
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> flushAsync(String resourceGroupName, String cacheName) {
        return beginFlushAsync(resourceGroupName, cacheName).last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> flushAsync(String resourceGroupName, String cacheName, Context context) {
        return beginFlushAsync(resourceGroupName, cacheName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 flush(String resourceGroupName, String cacheName) {
        flushAsync(resourceGroupName, cacheName).block();
    }

    /**
     * Tells a cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors
     * returned until the flush is complete.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 flush(String resourceGroupName, String cacheName, Context context) {
        flushAsync(resourceGroupName, cacheName, context).block();
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> startWithResponseAsync(String resourceGroupName, String cacheName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .start(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            cacheName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> startWithResponseAsync(
        String resourceGroupName, String cacheName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .start(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                cacheName,
                accept,
                context);
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStartAsync(String resourceGroupName, String cacheName) {
        Mono<Response<Flux<ByteBuffer>>> mono = startWithResponseAsync(resourceGroupName, cacheName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStartAsync(
        String resourceGroupName, String cacheName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = startWithResponseAsync(resourceGroupName, cacheName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStart(String resourceGroupName, String cacheName) {
        return this.beginStartAsync(resourceGroupName, cacheName).getSyncPoller();
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStart(String resourceGroupName, String cacheName, Context context) {
        return this.beginStartAsync(resourceGroupName, cacheName, context).getSyncPoller();
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> startAsync(String resourceGroupName, String cacheName) {
        return beginStartAsync(resourceGroupName, cacheName).last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> startAsync(String resourceGroupName, String cacheName, Context context) {
        return beginStartAsync(resourceGroupName, cacheName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 start(String resourceGroupName, String cacheName) {
        startAsync(resourceGroupName, cacheName).block();
    }

    /**
     * Tells a Stopped state cache to transition to Active state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 start(String resourceGroupName, String cacheName, Context context) {
        startAsync(resourceGroupName, cacheName, context).block();
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> stopWithResponseAsync(String resourceGroupName, String cacheName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .stop(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            cacheName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> stopWithResponseAsync(
        String resourceGroupName, String cacheName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .stop(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                cacheName,
                accept,
                context);
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStopAsync(String resourceGroupName, String cacheName) {
        Mono<Response<Flux<ByteBuffer>>> mono = stopWithResponseAsync(resourceGroupName, cacheName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStopAsync(
        String resourceGroupName, String cacheName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = stopWithResponseAsync(resourceGroupName, cacheName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStop(String resourceGroupName, String cacheName) {
        return this.beginStopAsync(resourceGroupName, cacheName).getSyncPoller();
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStop(String resourceGroupName, String cacheName, Context context) {
        return this.beginStopAsync(resourceGroupName, cacheName, context).getSyncPoller();
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> stopAsync(String resourceGroupName, String cacheName) {
        return beginStopAsync(resourceGroupName, cacheName).last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> stopAsync(String resourceGroupName, String cacheName, Context context) {
        return beginStopAsync(resourceGroupName, cacheName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 stop(String resourceGroupName, String cacheName) {
        stopAsync(resourceGroupName, cacheName).block();
    }

    /**
     * Tells an Active cache to transition to Stopped state.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 stop(String resourceGroupName, String cacheName, Context context) {
        stopAsync(resourceGroupName, cacheName, context).block();
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingjob Object containing the definition of a priming job.
     * @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>>> startPrimingJobWithResponseAsync(
        String resourceGroupName, String cacheName, PrimingJob primingjob) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        if (primingjob != null) {
            primingjob.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .startPrimingJob(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            cacheName,
                            primingjob,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingjob Object containing the definition of a priming job.
     * @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>>> startPrimingJobWithResponseAsync(
        String resourceGroupName, String cacheName, PrimingJob primingjob, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        if (primingjob != null) {
            primingjob.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .startPrimingJob(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                cacheName,
                primingjob,
                accept,
                context);
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingjob Object containing the definition of a priming job.
     * @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> beginStartPrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJob primingjob) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            startPrimingJobWithResponseAsync(resourceGroupName, cacheName, primingjob);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStartPrimingJobAsync(String resourceGroupName, String cacheName) {
        final PrimingJob primingjob = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            startPrimingJobWithResponseAsync(resourceGroupName, cacheName, primingjob);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingjob Object containing the definition of a priming job.
     * @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> beginStartPrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJob primingjob, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            startPrimingJobWithResponseAsync(resourceGroupName, cacheName, primingjob, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStartPrimingJob(String resourceGroupName, String cacheName) {
        final PrimingJob primingjob = null;
        return this.beginStartPrimingJobAsync(resourceGroupName, cacheName, primingjob).getSyncPoller();
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingjob Object containing the definition of a priming job.
     * @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> beginStartPrimingJob(
        String resourceGroupName, String cacheName, PrimingJob primingjob, Context context) {
        return this.beginStartPrimingJobAsync(resourceGroupName, cacheName, primingjob, context).getSyncPoller();
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingjob Object containing the definition of a priming job.
     * @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> startPrimingJobAsync(String resourceGroupName, String cacheName, PrimingJob primingjob) {
        return beginStartPrimingJobAsync(resourceGroupName, cacheName, primingjob)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> startPrimingJobAsync(String resourceGroupName, String cacheName) {
        final PrimingJob primingjob = null;
        return beginStartPrimingJobAsync(resourceGroupName, cacheName, primingjob)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingjob Object containing the definition of a priming job.
     * @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> startPrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJob primingjob, Context context) {
        return beginStartPrimingJobAsync(resourceGroupName, cacheName, primingjob, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 startPrimingJob(String resourceGroupName, String cacheName) {
        final PrimingJob primingjob = null;
        startPrimingJobAsync(resourceGroupName, cacheName, primingjob).block();
    }

    /**
     * Create a priming job. This operation is only allowed when the cache is healthy.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingjob Object containing the definition of a priming job.
     * @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 startPrimingJob(String resourceGroupName, String cacheName, PrimingJob primingjob, Context context) {
        startPrimingJobAsync(resourceGroupName, cacheName, primingjob, context).block();
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @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>>> stopPrimingJobWithResponseAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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 (primingJobId != null) {
            primingJobId.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .stopPrimingJob(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            cacheName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            primingJobId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> stopPrimingJobWithResponseAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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 (primingJobId != null) {
            primingJobId.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .stopPrimingJob(
                this.client.getEndpoint(),
                resourceGroupName,
                cacheName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                primingJobId,
                accept,
                context);
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @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> beginStopPrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            stopPrimingJobWithResponseAsync(resourceGroupName, cacheName, primingJobId);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStopPrimingJobAsync(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            stopPrimingJobWithResponseAsync(resourceGroupName, cacheName, primingJobId);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginStopPrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            stopPrimingJobWithResponseAsync(resourceGroupName, cacheName, primingJobId, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginStopPrimingJob(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        return this.beginStopPrimingJobAsync(resourceGroupName, cacheName, primingJobId).getSyncPoller();
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginStopPrimingJob(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        return this.beginStopPrimingJobAsync(resourceGroupName, cacheName, primingJobId, context).getSyncPoller();
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @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> stopPrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId) {
        return beginStopPrimingJobAsync(resourceGroupName, cacheName, primingJobId)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> stopPrimingJobAsync(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        return beginStopPrimingJobAsync(resourceGroupName, cacheName, primingJobId)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> stopPrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        return beginStopPrimingJobAsync(resourceGroupName, cacheName, primingJobId, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 stopPrimingJob(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        stopPrimingJobAsync(resourceGroupName, cacheName, primingJobId).block();
    }

    /**
     * Schedule a priming job for deletion.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void stopPrimingJob(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        stopPrimingJobAsync(resourceGroupName, cacheName, primingJobId, context).block();
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @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>>> pausePrimingJobWithResponseAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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 (primingJobId != null) {
            primingJobId.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .pausePrimingJob(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            cacheName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            primingJobId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> pausePrimingJobWithResponseAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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 (primingJobId != null) {
            primingJobId.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .pausePrimingJob(
                this.client.getEndpoint(),
                resourceGroupName,
                cacheName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                primingJobId,
                accept,
                context);
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @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> beginPausePrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            pausePrimingJobWithResponseAsync(resourceGroupName, cacheName, primingJobId);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginPausePrimingJobAsync(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            pausePrimingJobWithResponseAsync(resourceGroupName, cacheName, primingJobId);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginPausePrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            pausePrimingJobWithResponseAsync(resourceGroupName, cacheName, primingJobId, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginPausePrimingJob(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        return this.beginPausePrimingJobAsync(resourceGroupName, cacheName, primingJobId).getSyncPoller();
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginPausePrimingJob(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        return this.beginPausePrimingJobAsync(resourceGroupName, cacheName, primingJobId, context).getSyncPoller();
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @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> pausePrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId) {
        return beginPausePrimingJobAsync(resourceGroupName, cacheName, primingJobId)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> pausePrimingJobAsync(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        return beginPausePrimingJobAsync(resourceGroupName, cacheName, primingJobId)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> pausePrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        return beginPausePrimingJobAsync(resourceGroupName, cacheName, primingJobId, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 pausePrimingJob(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        pausePrimingJobAsync(resourceGroupName, cacheName, primingJobId).block();
    }

    /**
     * Schedule a priming job to be paused.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void pausePrimingJob(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        pausePrimingJobAsync(resourceGroupName, cacheName, primingJobId, context).block();
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @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>>> resumePrimingJobWithResponseAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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 (primingJobId != null) {
            primingJobId.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .resumePrimingJob(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            cacheName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            primingJobId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> resumePrimingJobWithResponseAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName 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 (primingJobId != null) {
            primingJobId.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .resumePrimingJob(
                this.client.getEndpoint(),
                resourceGroupName,
                cacheName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                primingJobId,
                accept,
                context);
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @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> beginResumePrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            resumePrimingJobWithResponseAsync(resourceGroupName, cacheName, primingJobId);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginResumePrimingJobAsync(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            resumePrimingJobWithResponseAsync(resourceGroupName, cacheName, primingJobId);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginResumePrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            resumePrimingJobWithResponseAsync(resourceGroupName, cacheName, primingJobId, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginResumePrimingJob(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        return this.beginResumePrimingJobAsync(resourceGroupName, cacheName, primingJobId).getSyncPoller();
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginResumePrimingJob(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        return this.beginResumePrimingJobAsync(resourceGroupName, cacheName, primingJobId, context).getSyncPoller();
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @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> resumePrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId) {
        return beginResumePrimingJobAsync(resourceGroupName, cacheName, primingJobId)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> resumePrimingJobAsync(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        return beginResumePrimingJobAsync(resourceGroupName, cacheName, primingJobId)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> resumePrimingJobAsync(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        return beginResumePrimingJobAsync(resourceGroupName, cacheName, primingJobId, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 resumePrimingJob(String resourceGroupName, String cacheName) {
        final PrimingJobIdParameter primingJobId = null;
        resumePrimingJobAsync(resourceGroupName, cacheName, primingJobId).block();
    }

    /**
     * Resumes a paused priming job.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param primingJobId Object containing the priming job ID.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void resumePrimingJob(
        String resourceGroupName, String cacheName, PrimingJobIdParameter primingJobId, Context context) {
        resumePrimingJobAsync(resourceGroupName, cacheName, primingJobId, context).block();
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> upgradeFirmwareWithResponseAsync(
        String resourceGroupName, String cacheName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .upgradeFirmware(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            cacheName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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>>> upgradeFirmwareWithResponseAsync(
        String resourceGroupName, String cacheName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .upgradeFirmware(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                cacheName,
                accept,
                context);
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginUpgradeFirmwareAsync(String resourceGroupName, String cacheName) {
        Mono<Response<Flux<ByteBuffer>>> mono = upgradeFirmwareWithResponseAsync(resourceGroupName, cacheName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginUpgradeFirmwareAsync(
        String resourceGroupName, String cacheName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = upgradeFirmwareWithResponseAsync(resourceGroupName, cacheName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginUpgradeFirmware(String resourceGroupName, String cacheName) {
        return this.beginUpgradeFirmwareAsync(resourceGroupName, cacheName).getSyncPoller();
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginUpgradeFirmware(
        String resourceGroupName, String cacheName, Context context) {
        return this.beginUpgradeFirmwareAsync(resourceGroupName, cacheName, context).getSyncPoller();
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> upgradeFirmwareAsync(String resourceGroupName, String cacheName) {
        return beginUpgradeFirmwareAsync(resourceGroupName, cacheName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> upgradeFirmwareAsync(String resourceGroupName, String cacheName, Context context) {
        return beginUpgradeFirmwareAsync(resourceGroupName, cacheName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 upgradeFirmware(String resourceGroupName, String cacheName) {
        upgradeFirmwareAsync(resourceGroupName, cacheName).block();
    }

    /**
     * Upgrade a cache's firmware if a new version is available. Otherwise, this operation has no effect.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 upgradeFirmware(String resourceGroupName, String cacheName, Context context) {
        upgradeFirmwareAsync(resourceGroupName, cacheName, context).block();
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param spaceAllocation List containing storage target cache space percentage allocations.
     * @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>>> spaceAllocationWithResponseAsync(
        String resourceGroupName, String cacheName, List<StorageTargetSpaceAllocation> spaceAllocation) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        if (spaceAllocation != null) {
            spaceAllocation.forEach(e -> e.validate());
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .spaceAllocation(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            cacheName,
                            spaceAllocation,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param spaceAllocation List containing storage target cache space percentage allocations.
     * @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>>> spaceAllocationWithResponseAsync(
        String resourceGroupName,
        String cacheName,
        List<StorageTargetSpaceAllocation> spaceAllocation,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (cacheName == null) {
            return Mono.error(new IllegalArgumentException("Parameter cacheName is required and cannot be null."));
        }
        if (spaceAllocation != null) {
            spaceAllocation.forEach(e -> e.validate());
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .spaceAllocation(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                cacheName,
                spaceAllocation,
                accept,
                context);
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param spaceAllocation List containing storage target cache space percentage allocations.
     * @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> beginSpaceAllocationAsync(
        String resourceGroupName, String cacheName, List<StorageTargetSpaceAllocation> spaceAllocation) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            spaceAllocationWithResponseAsync(resourceGroupName, cacheName, spaceAllocation);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginSpaceAllocationAsync(String resourceGroupName, String cacheName) {
        final List<StorageTargetSpaceAllocation> spaceAllocation = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            spaceAllocationWithResponseAsync(resourceGroupName, cacheName, spaceAllocation);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param spaceAllocation List containing storage target cache space percentage allocations.
     * @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> beginSpaceAllocationAsync(
        String resourceGroupName,
        String cacheName,
        List<StorageTargetSpaceAllocation> spaceAllocation,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            spaceAllocationWithResponseAsync(resourceGroupName, cacheName, spaceAllocation, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> beginSpaceAllocation(String resourceGroupName, String cacheName) {
        final List<StorageTargetSpaceAllocation> spaceAllocation = null;
        return this.beginSpaceAllocationAsync(resourceGroupName, cacheName, spaceAllocation).getSyncPoller();
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param spaceAllocation List containing storage target cache space percentage allocations.
     * @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> beginSpaceAllocation(
        String resourceGroupName,
        String cacheName,
        List<StorageTargetSpaceAllocation> spaceAllocation,
        Context context) {
        return this.beginSpaceAllocationAsync(resourceGroupName, cacheName, spaceAllocation, context).getSyncPoller();
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param spaceAllocation List containing storage target cache space percentage allocations.
     * @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> spaceAllocationAsync(
        String resourceGroupName, String cacheName, List<StorageTargetSpaceAllocation> spaceAllocation) {
        return beginSpaceAllocationAsync(resourceGroupName, cacheName, spaceAllocation)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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> spaceAllocationAsync(String resourceGroupName, String cacheName) {
        final List<StorageTargetSpaceAllocation> spaceAllocation = null;
        return beginSpaceAllocationAsync(resourceGroupName, cacheName, spaceAllocation)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param spaceAllocation List containing storage target cache space percentage allocations.
     * @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> spaceAllocationAsync(
        String resourceGroupName,
        String cacheName,
        List<StorageTargetSpaceAllocation> spaceAllocation,
        Context context) {
        return beginSpaceAllocationAsync(resourceGroupName, cacheName, spaceAllocation, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @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 spaceAllocation(String resourceGroupName, String cacheName) {
        final List<StorageTargetSpaceAllocation> spaceAllocation = null;
        spaceAllocationAsync(resourceGroupName, cacheName, spaceAllocation).block();
    }

    /**
     * Update cache space allocation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param cacheName Name of cache. Length of name must not be greater than 80 and chars must be from the
     *     [-0-9a-zA-Z_] char class.
     * @param spaceAllocation List containing storage target cache space percentage allocations.
     * @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 spaceAllocation(
        String resourceGroupName,
        String cacheName,
        List<StorageTargetSpaceAllocation> spaceAllocation,
        Context context) {
        spaceAllocationAsync(resourceGroupName, cacheName, spaceAllocation, 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 result of the request to list caches along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CacheInner>> listNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<CacheInner>>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 result of the request to list caches along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CacheInner>> listNextSinglePageAsync(String nextLink, Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * 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 result of the request to list caches along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CacheInner>> 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<CacheInner>>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 result of the request to list caches along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<CacheInner>> 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));
    }
}
