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

package com.azure.resourcemanager.powerbidedicated.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.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.powerbidedicated.fluent.AutoScaleVCoresClient;
import com.azure.resourcemanager.powerbidedicated.fluent.models.AutoScaleVCoreInner;
import com.azure.resourcemanager.powerbidedicated.models.AutoScaleVCoreListResult;
import com.azure.resourcemanager.powerbidedicated.models.AutoScaleVCoreUpdateParameters;
import reactor.core.publisher.Mono;

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

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

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

    /**
     * The interface defining all the services for PowerBIDedicatedAutoScaleVCores to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "PowerBIDedicatedAuto")
    public interface AutoScaleVCoresService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated"
                + "/autoScaleVCores/{vcoreName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AutoScaleVCoreInner>> getByResourceGroup(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("vcoreName") String vcoreName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated"
                + "/autoScaleVCores/{vcoreName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AutoScaleVCoreInner>> create(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("vcoreName") String vcoreName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") AutoScaleVCoreInner vCoreParameters,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated"
                + "/autoScaleVCores/{vcoreName}")
        @ExpectedResponses({200, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Void>> delete(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("vcoreName") String vcoreName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated"
                + "/autoScaleVCores/{vcoreName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AutoScaleVCoreInner>> update(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("vcoreName") String vcoreName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") AutoScaleVCoreUpdateParameters vCoreUpdateParameters,
            @HeaderParam("Accept") String accept,
            Context context);

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

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

    /**
     * Gets details about the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return details about the specified auto scale v-core along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AutoScaleVCoreInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String vcoreName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (vcoreName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vcoreName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getByResourceGroup(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            vcoreName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets details about the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @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 details about the specified auto scale v-core along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AutoScaleVCoreInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String vcoreName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (vcoreName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vcoreName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getByResourceGroup(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                vcoreName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Gets details about the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return details about the specified auto scale v-core on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AutoScaleVCoreInner> getByResourceGroupAsync(String resourceGroupName, String vcoreName) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, vcoreName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets details about the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @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 details about the specified auto scale v-core along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AutoScaleVCoreInner> getByResourceGroupWithResponse(
        String resourceGroupName, String vcoreName, Context context) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, vcoreName, context).block();
    }

    /**
     * Gets details about the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return details about the specified auto scale v-core.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AutoScaleVCoreInner getByResourceGroup(String resourceGroupName, String vcoreName) {
        return getByResourceGroupWithResponse(resourceGroupName, vcoreName, Context.NONE).getValue();
    }

    /**
     * Provisions the specified auto scale v-core based on the configuration specified in the request.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreParameters Contains the information used to provision the auto scale v-core.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return represents an instance of an auto scale v-core resource along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AutoScaleVCoreInner>> createWithResponseAsync(
        String resourceGroupName, String vcoreName, AutoScaleVCoreInner vCoreParameters) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (vcoreName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vcoreName is required and cannot be null."));
        }
        if (vCoreParameters == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter vCoreParameters is required and cannot be null."));
        } else {
            vCoreParameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .create(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            vcoreName,
                            this.client.getApiVersion(),
                            vCoreParameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Provisions the specified auto scale v-core based on the configuration specified in the request.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreParameters Contains the information used to provision the auto scale v-core.
     * @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 represents an instance of an auto scale v-core resource along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AutoScaleVCoreInner>> createWithResponseAsync(
        String resourceGroupName, String vcoreName, AutoScaleVCoreInner vCoreParameters, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (vcoreName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vcoreName is required and cannot be null."));
        }
        if (vCoreParameters == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter vCoreParameters is required and cannot be null."));
        } else {
            vCoreParameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .create(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                vcoreName,
                this.client.getApiVersion(),
                vCoreParameters,
                accept,
                context);
    }

    /**
     * Provisions the specified auto scale v-core based on the configuration specified in the request.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreParameters Contains the information used to provision the auto scale v-core.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return represents an instance of an auto scale v-core resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AutoScaleVCoreInner> createAsync(
        String resourceGroupName, String vcoreName, AutoScaleVCoreInner vCoreParameters) {
        return createWithResponseAsync(resourceGroupName, vcoreName, vCoreParameters)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Provisions the specified auto scale v-core based on the configuration specified in the request.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreParameters Contains the information used to provision the auto scale v-core.
     * @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 represents an instance of an auto scale v-core resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AutoScaleVCoreInner> createWithResponse(
        String resourceGroupName, String vcoreName, AutoScaleVCoreInner vCoreParameters, Context context) {
        return createWithResponseAsync(resourceGroupName, vcoreName, vCoreParameters, context).block();
    }

    /**
     * Provisions the specified auto scale v-core based on the configuration specified in the request.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreParameters Contains the information used to provision the auto scale v-core.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return represents an instance of an auto scale v-core resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AutoScaleVCoreInner create(String resourceGroupName, String vcoreName, AutoScaleVCoreInner vCoreParameters) {
        return createWithResponse(resourceGroupName, vcoreName, vCoreParameters, Context.NONE).getValue();
    }

    /**
     * Deletes the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(String resourceGroupName, String vcoreName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (vcoreName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vcoreName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            vcoreName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(String resourceGroupName, String vcoreName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (vcoreName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vcoreName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                vcoreName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Deletes the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 vcoreName) {
        return deleteWithResponseAsync(resourceGroupName, vcoreName).flatMap(ignored -> Mono.empty());
    }

    /**
     * Deletes the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteWithResponse(String resourceGroupName, String vcoreName, Context context) {
        return deleteWithResponseAsync(resourceGroupName, vcoreName, context).block();
    }

    /**
     * Deletes the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @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 vcoreName) {
        deleteWithResponse(resourceGroupName, vcoreName, Context.NONE);
    }

    /**
     * Updates the current state of the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreUpdateParameters Request object that contains the updated information for the auto scale v-core.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return represents an instance of an auto scale v-core resource along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AutoScaleVCoreInner>> updateWithResponseAsync(
        String resourceGroupName, String vcoreName, AutoScaleVCoreUpdateParameters vCoreUpdateParameters) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (vcoreName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vcoreName is required and cannot be null."));
        }
        if (vCoreUpdateParameters == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter vCoreUpdateParameters is required and cannot be null."));
        } else {
            vCoreUpdateParameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            vcoreName,
                            this.client.getApiVersion(),
                            vCoreUpdateParameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the current state of the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreUpdateParameters Request object that contains the updated information for the auto scale v-core.
     * @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 represents an instance of an auto scale v-core resource along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AutoScaleVCoreInner>> updateWithResponseAsync(
        String resourceGroupName,
        String vcoreName,
        AutoScaleVCoreUpdateParameters vCoreUpdateParameters,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (vcoreName == null) {
            return Mono.error(new IllegalArgumentException("Parameter vcoreName is required and cannot be null."));
        }
        if (vCoreUpdateParameters == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter vCoreUpdateParameters is required and cannot be null."));
        } else {
            vCoreUpdateParameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                vcoreName,
                this.client.getApiVersion(),
                vCoreUpdateParameters,
                accept,
                context);
    }

    /**
     * Updates the current state of the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreUpdateParameters Request object that contains the updated information for the auto scale v-core.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return represents an instance of an auto scale v-core resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AutoScaleVCoreInner> updateAsync(
        String resourceGroupName, String vcoreName, AutoScaleVCoreUpdateParameters vCoreUpdateParameters) {
        return updateWithResponseAsync(resourceGroupName, vcoreName, vCoreUpdateParameters)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Updates the current state of the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreUpdateParameters Request object that contains the updated information for the auto scale v-core.
     * @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 represents an instance of an auto scale v-core resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AutoScaleVCoreInner> updateWithResponse(
        String resourceGroupName,
        String vcoreName,
        AutoScaleVCoreUpdateParameters vCoreUpdateParameters,
        Context context) {
        return updateWithResponseAsync(resourceGroupName, vcoreName, vCoreUpdateParameters, context).block();
    }

    /**
     * Updates the current state of the specified auto scale v-core.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @param vcoreName The name of the auto scale v-core. It must be a minimum of 3 characters, and a maximum of 63.
     * @param vCoreUpdateParameters Request object that contains the updated information for the auto scale v-core.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return represents an instance of an auto scale v-core resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AutoScaleVCoreInner update(
        String resourceGroupName, String vcoreName, AutoScaleVCoreUpdateParameters vCoreUpdateParameters) {
        return updateWithResponse(resourceGroupName, vcoreName, vCoreUpdateParameters, Context.NONE).getValue();
    }

    /**
     * Gets all the auto scale v-cores for the given resource group.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all the auto scale v-cores for the given resource group along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AutoScaleVCoreInner>> listByResourceGroupSinglePageAsync(String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByResourceGroup(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .<PagedResponse<AutoScaleVCoreInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets all the auto scale v-cores for the given resource group.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @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 all the auto scale v-cores for the given resource group along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AutoScaleVCoreInner>> listByResourceGroupSinglePageAsync(
        String resourceGroupName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByResourceGroup(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null));
    }

    /**
     * Gets all the auto scale v-cores for the given resource group.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all the auto scale v-cores for the given resource group as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AutoScaleVCoreInner> listByResourceGroupAsync(String resourceGroupName) {
        return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName));
    }

    /**
     * Gets all the auto scale v-cores for the given resource group.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @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 all the auto scale v-cores for the given resource group as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AutoScaleVCoreInner> listByResourceGroupAsync(String resourceGroupName, Context context) {
        return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, context));
    }

    /**
     * Gets all the auto scale v-cores for the given resource group.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return all the auto scale v-cores for the given resource group as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AutoScaleVCoreInner> listByResourceGroup(String resourceGroupName) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName));
    }

    /**
     * Gets all the auto scale v-cores for the given resource group.
     *
     * @param resourceGroupName The name of the Azure Resource group of which a given PowerBIDedicated capacity is part.
     *     This name must be at least 1 character in length, and no more than 90.
     * @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 all the auto scale v-cores for the given resource group as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AutoScaleVCoreInner> listByResourceGroup(String resourceGroupName, Context context) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context));
    }

    /**
     * Lists all the auto scale v-cores for the given subscription.
     *
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an array of auto scale v-core resources along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AutoScaleVCoreInner>> 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.getSubscriptionId(),
                            this.client.getApiVersion(),
                            accept,
                            context))
            .<PagedResponse<AutoScaleVCoreInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Lists all the auto scale v-cores for the given 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 an array of auto scale v-core resources along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AutoScaleVCoreInner>> 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.getSubscriptionId(),
                this.client.getApiVersion(),
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null));
    }

    /**
     * Lists all the auto scale v-cores for the given subscription.
     *
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an array of auto scale v-core resources as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AutoScaleVCoreInner> listAsync() {
        return new PagedFlux<>(() -> listSinglePageAsync());
    }

    /**
     * Lists all the auto scale v-cores for the given 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 an array of auto scale v-core resources as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AutoScaleVCoreInner> listAsync(Context context) {
        return new PagedFlux<>(() -> listSinglePageAsync(context));
    }

    /**
     * Lists all the auto scale v-cores for the given subscription.
     *
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an array of auto scale v-core resources as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AutoScaleVCoreInner> list() {
        return new PagedIterable<>(listAsync());
    }

    /**
     * Lists all the auto scale v-cores for the given 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 an array of auto scale v-core resources as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AutoScaleVCoreInner> list(Context context) {
        return new PagedIterable<>(listAsync(context));
    }
}
