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

package com.azure.resourcemanager.deviceprovisioningservices.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.deviceprovisioningservices.fluent.IotDpsResourcesClient;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.AsyncOperationResultInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.GroupIdInformationInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.IotDpsSkuDefinitionInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.NameAvailabilityInfoInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.PrivateEndpointConnectionInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.PrivateLinkResourcesInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.ProvisioningServiceDescriptionInner;
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.SharedAccessSignatureAuthorizationRuleInner;
import com.azure.resourcemanager.deviceprovisioningservices.models.ErrorDetailsException;
import com.azure.resourcemanager.deviceprovisioningservices.models.IotDpsSkuDefinitionListResult;
import com.azure.resourcemanager.deviceprovisioningservices.models.OperationInputs;
import com.azure.resourcemanager.deviceprovisioningservices.models.ProvisioningServiceDescriptionListResult;
import com.azure.resourcemanager.deviceprovisioningservices.models.SharedAccessSignatureAuthorizationRuleListResult;
import com.azure.resourcemanager.deviceprovisioningservices.models.TagsResource;
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 IotDpsResourcesClient. */
public final class IotDpsResourcesClientImpl implements IotDpsResourcesClient {
    /** The proxy service used to perform REST calls. */
    private final IotDpsResourcesService service;

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

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

    /**
     * The interface defining all the services for IotDpsClientIotDpsResources to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "IotDpsClientIotDpsRe")
    private interface IotDpsResourcesService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<ProvisioningServiceDescriptionInner>> getByResourceGroup(
            @HostParam("$host") String endpoint,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") ProvisioningServiceDescriptionInner iotDpsDescription,
            @HeaderParam("Accept") String accept,
            Context context);

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

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

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

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<ProvisioningServiceDescriptionListResult>> 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}/operationresults/{operationId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<AsyncOperationResultInner>> getOperationResult(
            @HostParam("$host") String endpoint,
            @PathParam("operationId") String operationId,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @QueryParam("asyncinfo") String asyncinfo,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

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

        @Headers({"Content-Type: application/json"})
        @Post("/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<NameAvailabilityInfoInner>> checkProvisioningServiceNameAvailability(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") OperationInputs arguments,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}/listkeys")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<SharedAccessSignatureAuthorizationRuleListResult>> listKeys(
            @HostParam("$host") String endpoint,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<SharedAccessSignatureAuthorizationRuleInner>> listKeysForKeyName(
            @HostParam("$host") String endpoint,
            @PathParam("provisioningServiceName") String provisioningServiceName,
            @PathParam("keyName") String keyName,
            @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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{resourceName}/privateLinkResources")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<PrivateLinkResourcesInner>> listPrivateLinkResources(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("resourceName") String resourceName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{resourceName}/privateLinkResources/{groupId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<GroupIdInformationInner>> getPrivateLinkResources(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("resourceName") String resourceName,
            @PathParam("groupId") String groupId,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{resourceName}/privateEndpointConnections")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<List<PrivateEndpointConnectionInner>>> listPrivateEndpointConnections(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("resourceName") String resourceName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<PrivateEndpointConnectionInner>> getPrivateEndpointConnection(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("resourceName") String resourceName,
            @PathParam("privateEndpointConnectionName") String privateEndpointConnectionName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<Flux<ByteBuffer>>> createOrUpdatePrivateEndpointConnection(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("resourceName") String resourceName,
            @PathParam("privateEndpointConnectionName") String privateEndpointConnectionName,
            @BodyParam("application/json") PrivateEndpointConnectionInner privateEndpointConnection,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices"
                + "/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}")
        @ExpectedResponses({200, 202, 204})
        @UnexpectedResponseExceptionType(ErrorDetailsException.class)
        Mono<Response<Flux<ByteBuffer>>> deletePrivateEndpointConnection(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("resourceName") String resourceName,
            @PathParam("privateEndpointConnectionName") String privateEndpointConnectionName,
            @HeaderParam("Accept") String accept,
            Context context);

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

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

    /**
     * Get the metadata of the provisioning service without SAS keys.
     *
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Name of the provisioning service to retrieve.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the metadata of the provisioning service without SAS keys along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProvisioningServiceDescriptionInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String provisioningServiceName) {
        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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getByResourceGroup(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            provisioningServiceName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the metadata of the provisioning service without SAS keys.
     *
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Name of the provisioning service to retrieve.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the metadata of the provisioning service without SAS keys along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProvisioningServiceDescriptionInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String provisioningServiceName, 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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getByResourceGroup(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getSubscriptionId(),
                provisioningServiceName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Get the metadata of the provisioning service without SAS keys.
     *
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Name of the provisioning service to retrieve.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the metadata of the provisioning service without SAS keys on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProvisioningServiceDescriptionInner> getByResourceGroupAsync(
        String resourceGroupName, String provisioningServiceName) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, provisioningServiceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get the metadata of the provisioning service without SAS keys.
     *
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Name of the provisioning service to retrieve.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the metadata of the provisioning service without SAS keys.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProvisioningServiceDescriptionInner getByResourceGroup(
        String resourceGroupName, String provisioningServiceName) {
        return getByResourceGroupAsync(resourceGroupName, provisioningServiceName).block();
    }

    /**
     * Get the metadata of the provisioning service without SAS keys.
     *
     * @param resourceGroupName Resource group name.
     * @param provisioningServiceName Name of the provisioning service to retrieve.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the metadata of the provisioning service without SAS keys along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ProvisioningServiceDescriptionInner> getByResourceGroupWithResponse(
        String resourceGroupName, String provisioningServiceName, Context context) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, provisioningServiceName, context).block();
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the description of the provisioning service along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName,
        String provisioningServiceName,
        ProvisioningServiceDescriptionInner iotDpsDescription) {
        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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (iotDpsDescription == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter iotDpsDescription is required and cannot be null."));
        } else {
            iotDpsDescription.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            provisioningServiceName,
                            this.client.getApiVersion(),
                            iotDpsDescription,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the description of the provisioning service along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName,
        String provisioningServiceName,
        ProvisioningServiceDescriptionInner iotDpsDescription,
        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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (iotDpsDescription == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter iotDpsDescription is required and cannot be null."));
        } else {
            iotDpsDescription.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                provisioningServiceName,
                this.client.getApiVersion(),
                iotDpsDescription,
                accept,
                context);
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ProvisioningServiceDescriptionInner>, ProvisioningServiceDescriptionInner>
        beginCreateOrUpdateAsync(
            String resourceGroupName,
            String provisioningServiceName,
            ProvisioningServiceDescriptionInner iotDpsDescription) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(resourceGroupName, provisioningServiceName, iotDpsDescription);
        return this
            .client
            .<ProvisioningServiceDescriptionInner, ProvisioningServiceDescriptionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ProvisioningServiceDescriptionInner.class,
                ProvisioningServiceDescriptionInner.class,
                this.client.getContext());
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ProvisioningServiceDescriptionInner>, ProvisioningServiceDescriptionInner>
        beginCreateOrUpdateAsync(
            String resourceGroupName,
            String provisioningServiceName,
            ProvisioningServiceDescriptionInner iotDpsDescription,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(resourceGroupName, provisioningServiceName, iotDpsDescription, context);
        return this
            .client
            .<ProvisioningServiceDescriptionInner, ProvisioningServiceDescriptionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ProvisioningServiceDescriptionInner.class,
                ProvisioningServiceDescriptionInner.class,
                context);
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ProvisioningServiceDescriptionInner>, ProvisioningServiceDescriptionInner>
        beginCreateOrUpdate(
            String resourceGroupName,
            String provisioningServiceName,
            ProvisioningServiceDescriptionInner iotDpsDescription) {
        return beginCreateOrUpdateAsync(resourceGroupName, provisioningServiceName, iotDpsDescription).getSyncPoller();
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ProvisioningServiceDescriptionInner>, ProvisioningServiceDescriptionInner>
        beginCreateOrUpdate(
            String resourceGroupName,
            String provisioningServiceName,
            ProvisioningServiceDescriptionInner iotDpsDescription,
            Context context) {
        return beginCreateOrUpdateAsync(resourceGroupName, provisioningServiceName, iotDpsDescription, context)
            .getSyncPoller();
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the description of the provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProvisioningServiceDescriptionInner> createOrUpdateAsync(
        String resourceGroupName,
        String provisioningServiceName,
        ProvisioningServiceDescriptionInner iotDpsDescription) {
        return beginCreateOrUpdateAsync(resourceGroupName, provisioningServiceName, iotDpsDescription)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the description of the provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProvisioningServiceDescriptionInner> createOrUpdateAsync(
        String resourceGroupName,
        String provisioningServiceName,
        ProvisioningServiceDescriptionInner iotDpsDescription,
        Context context) {
        return beginCreateOrUpdateAsync(resourceGroupName, provisioningServiceName, iotDpsDescription, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProvisioningServiceDescriptionInner createOrUpdate(
        String resourceGroupName,
        String provisioningServiceName,
        ProvisioningServiceDescriptionInner iotDpsDescription) {
        return createOrUpdateAsync(resourceGroupName, provisioningServiceName, iotDpsDescription).block();
    }

    /**
     * Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve
     * the provisioning service metadata and security metadata, and then combine them with the modified values in a new
     * body to update the provisioning service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param iotDpsDescription Description of the provisioning service to create or update.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProvisioningServiceDescriptionInner createOrUpdate(
        String resourceGroupName,
        String provisioningServiceName,
        ProvisioningServiceDescriptionInner iotDpsDescription,
        Context context) {
        return createOrUpdateAsync(resourceGroupName, provisioningServiceName, iotDpsDescription, context).block();
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 description of the provisioning service along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName, String provisioningServiceName, TagsResource provisioningServiceTags) {
        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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (provisioningServiceTags == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceTags is required and cannot be null."));
        } else {
            provisioningServiceTags.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            provisioningServiceName,
                            this.client.getApiVersion(),
                            provisioningServiceTags,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @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 description of the provisioning service along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName,
        String provisioningServiceName,
        TagsResource provisioningServiceTags,
        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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (provisioningServiceTags == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceTags is required and cannot be null."));
        } else {
            provisioningServiceTags.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                provisioningServiceName,
                this.client.getApiVersion(),
                provisioningServiceTags,
                accept,
                context);
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ProvisioningServiceDescriptionInner>, ProvisioningServiceDescriptionInner>
        beginUpdateAsync(
            String resourceGroupName, String provisioningServiceName, TagsResource provisioningServiceTags) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, provisioningServiceName, provisioningServiceTags);
        return this
            .client
            .<ProvisioningServiceDescriptionInner, ProvisioningServiceDescriptionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ProvisioningServiceDescriptionInner.class,
                ProvisioningServiceDescriptionInner.class,
                this.client.getContext());
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @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 the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ProvisioningServiceDescriptionInner>, ProvisioningServiceDescriptionInner>
        beginUpdateAsync(
            String resourceGroupName,
            String provisioningServiceName,
            TagsResource provisioningServiceTags,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, provisioningServiceName, provisioningServiceTags, context);
        return this
            .client
            .<ProvisioningServiceDescriptionInner, ProvisioningServiceDescriptionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ProvisioningServiceDescriptionInner.class,
                ProvisioningServiceDescriptionInner.class,
                context);
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ProvisioningServiceDescriptionInner>, ProvisioningServiceDescriptionInner> beginUpdate(
        String resourceGroupName, String provisioningServiceName, TagsResource provisioningServiceTags) {
        return beginUpdateAsync(resourceGroupName, provisioningServiceName, provisioningServiceTags).getSyncPoller();
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @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 the description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ProvisioningServiceDescriptionInner>, ProvisioningServiceDescriptionInner> beginUpdate(
        String resourceGroupName,
        String provisioningServiceName,
        TagsResource provisioningServiceTags,
        Context context) {
        return beginUpdateAsync(resourceGroupName, provisioningServiceName, provisioningServiceTags, context)
            .getSyncPoller();
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 description of the provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProvisioningServiceDescriptionInner> updateAsync(
        String resourceGroupName, String provisioningServiceName, TagsResource provisioningServiceTags) {
        return beginUpdateAsync(resourceGroupName, provisioningServiceName, provisioningServiceTags)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @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 description of the provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProvisioningServiceDescriptionInner> updateAsync(
        String resourceGroupName,
        String provisioningServiceName,
        TagsResource provisioningServiceTags,
        Context context) {
        return beginUpdateAsync(resourceGroupName, provisioningServiceName, provisioningServiceTags, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProvisioningServiceDescriptionInner update(
        String resourceGroupName, String provisioningServiceName, TagsResource provisioningServiceTags) {
        return updateAsync(resourceGroupName, provisioningServiceName, provisioningServiceTags).block();
    }

    /**
     * Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to create or update.
     * @param provisioningServiceTags Updated tag information to set into the provisioning service instance.
     * @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 description of the provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProvisioningServiceDescriptionInner update(
        String resourceGroupName,
        String provisioningServiceName,
        TagsResource provisioningServiceTags,
        Context context) {
        return updateAsync(resourceGroupName, provisioningServiceName, provisioningServiceTags, context).block();
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName) {
        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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            provisioningServiceName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName, 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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                resourceGroupName,
                this.client.getSubscriptionId(),
                provisioningServiceName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName) {
        Mono<Response<Flux<ByteBuffer>>> mono = deleteWithResponseAsync(resourceGroupName, provisioningServiceName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(resourceGroupName, provisioningServiceName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName) {
        return beginDeleteAsync(resourceGroupName, provisioningServiceName).getSyncPoller();
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName, Context context) {
        return beginDeleteAsync(resourceGroupName, provisioningServiceName, context).getSyncPoller();
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName) {
        return beginDeleteAsync(resourceGroupName, provisioningServiceName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName, Context context) {
        return beginDeleteAsync(resourceGroupName, provisioningServiceName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName) {
        deleteAsync(resourceGroupName, provisioningServiceName).block();
    }

    /**
     * Deletes the Provisioning Service.
     *
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service to delete.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 provisioningServiceName, Context context) {
        deleteAsync(resourceGroupName, provisioningServiceName, context).block();
    }

    /**
     * List all the provisioning services for a given subscription id.
     *
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProvisioningServiceDescriptionInner>> 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<ProvisioningServiceDescriptionInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List all the provisioning services for a given subscription id.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProvisioningServiceDescriptionInner>> 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(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * List all the provisioning services for a given subscription id.
     *
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ProvisioningServiceDescriptionInner> listAsync() {
        return new PagedFlux<>(
            () -> listSinglePageAsync(), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink));
    }

    /**
     * List all the provisioning services for a given subscription id.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ProvisioningServiceDescriptionInner> listAsync(Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(context), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context));
    }

    /**
     * List all the provisioning services for a given subscription id.
     *
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ProvisioningServiceDescriptionInner> list() {
        return new PagedIterable<>(listAsync());
    }

    /**
     * List all the provisioning services for a given subscription id.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ProvisioningServiceDescriptionInner> list(Context context) {
        return new PagedIterable<>(listAsync(context));
    }

    /**
     * Get a list of all provisioning services in the given resource group.
     *
     * @param resourceGroupName Resource group identifier.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of all provisioning services in the given resource group along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProvisioningServiceDescriptionInner>> 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<ProvisioningServiceDescriptionInner>>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 a list of all provisioning services in the given resource group.
     *
     * @param resourceGroupName Resource group identifier.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of all provisioning services in the given resource group along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProvisioningServiceDescriptionInner>> 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(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get a list of all provisioning services in the given resource group.
     *
     * @param resourceGroupName Resource group identifier.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of all provisioning services in the given resource group as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ProvisioningServiceDescriptionInner> listByResourceGroupAsync(String resourceGroupName) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink));
    }

    /**
     * Get a list of all provisioning services in the given resource group.
     *
     * @param resourceGroupName Resource group identifier.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of all provisioning services in the given resource group as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ProvisioningServiceDescriptionInner> listByResourceGroupAsync(
        String resourceGroupName, Context context) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName, context),
            nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context));
    }

    /**
     * Get a list of all provisioning services in the given resource group.
     *
     * @param resourceGroupName Resource group identifier.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of all provisioning services in the given resource group as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ProvisioningServiceDescriptionInner> listByResourceGroup(String resourceGroupName) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName));
    }

    /**
     * Get a list of all provisioning services in the given resource group.
     *
     * @param resourceGroupName Resource group identifier.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of all provisioning services in the given resource group as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ProvisioningServiceDescriptionInner> listByResourceGroup(
        String resourceGroupName, Context context) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context));
    }

    /**
     * Gets the status of a long running operation, such as create, update or delete a provisioning service.
     *
     * @param operationId Operation id corresponding to long running operation. Use this to poll for the status.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service that the operation is running on.
     * @param asyncinfo Async header used to poll on the status of the operation, obtained while creating the long
     *     running operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the status of a long running operation, such as create, update or delete a provisioning service along
     *     with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AsyncOperationResultInner>> getOperationResultWithResponseAsync(
        String operationId, String resourceGroupName, String provisioningServiceName, String asyncinfo) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (operationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter operationId 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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (asyncinfo == null) {
            return Mono.error(new IllegalArgumentException("Parameter asyncinfo is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getOperationResult(
                            this.client.getEndpoint(),
                            operationId,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            provisioningServiceName,
                            asyncinfo,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets the status of a long running operation, such as create, update or delete a provisioning service.
     *
     * @param operationId Operation id corresponding to long running operation. Use this to poll for the status.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service that the operation is running on.
     * @param asyncinfo Async header used to poll on the status of the operation, obtained while creating the long
     *     running operation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the status of a long running operation, such as create, update or delete a provisioning service along
     *     with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AsyncOperationResultInner>> getOperationResultWithResponseAsync(
        String operationId,
        String resourceGroupName,
        String provisioningServiceName,
        String asyncinfo,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (operationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter operationId 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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (asyncinfo == null) {
            return Mono.error(new IllegalArgumentException("Parameter asyncinfo is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getOperationResult(
                this.client.getEndpoint(),
                operationId,
                this.client.getSubscriptionId(),
                resourceGroupName,
                provisioningServiceName,
                asyncinfo,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Gets the status of a long running operation, such as create, update or delete a provisioning service.
     *
     * @param operationId Operation id corresponding to long running operation. Use this to poll for the status.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service that the operation is running on.
     * @param asyncinfo Async header used to poll on the status of the operation, obtained while creating the long
     *     running operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the status of a long running operation, such as create, update or delete a provisioning service on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AsyncOperationResultInner> getOperationResultAsync(
        String operationId, String resourceGroupName, String provisioningServiceName, String asyncinfo) {
        return getOperationResultWithResponseAsync(operationId, resourceGroupName, provisioningServiceName, asyncinfo)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets the status of a long running operation, such as create, update or delete a provisioning service.
     *
     * @param operationId Operation id corresponding to long running operation. Use this to poll for the status.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service that the operation is running on.
     * @param asyncinfo Async header used to poll on the status of the operation, obtained while creating the long
     *     running operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the status of a long running operation, such as create, update or delete a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AsyncOperationResultInner getOperationResult(
        String operationId, String resourceGroupName, String provisioningServiceName, String asyncinfo) {
        return getOperationResultAsync(operationId, resourceGroupName, provisioningServiceName, asyncinfo).block();
    }

    /**
     * Gets the status of a long running operation, such as create, update or delete a provisioning service.
     *
     * @param operationId Operation id corresponding to long running operation. Use this to poll for the status.
     * @param resourceGroupName Resource group identifier.
     * @param provisioningServiceName Name of provisioning service that the operation is running on.
     * @param asyncinfo Async header used to poll on the status of the operation, obtained while creating the long
     *     running operation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the status of a long running operation, such as create, update or delete a provisioning service along
     *     with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AsyncOperationResultInner> getOperationResultWithResponse(
        String operationId,
        String resourceGroupName,
        String provisioningServiceName,
        String asyncinfo,
        Context context) {
        return getOperationResultWithResponseAsync(
                operationId, resourceGroupName, provisioningServiceName, asyncinfo, context)
            .block();
    }

    /**
     * Gets the list of valid SKUs and tiers for a provisioning service.
     *
     * @param provisioningServiceName Name of provisioning service.
     * @param resourceGroupName Name of resource group.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of valid SKUs and tiers for a provisioning service along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<IotDpsSkuDefinitionInner>> listValidSkusSinglePageAsync(
        String provisioningServiceName, String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName 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
                        .listValidSkus(
                            this.client.getEndpoint(),
                            provisioningServiceName,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .<PagedResponse<IotDpsSkuDefinitionInner>>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()));
    }

    /**
     * Gets the list of valid SKUs and tiers for a provisioning service.
     *
     * @param provisioningServiceName Name of provisioning service.
     * @param resourceGroupName Name of resource group.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of valid SKUs and tiers for a provisioning service along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<IotDpsSkuDefinitionInner>> listValidSkusSinglePageAsync(
        String provisioningServiceName, 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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName 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
            .listValidSkus(
                this.client.getEndpoint(),
                provisioningServiceName,
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Gets the list of valid SKUs and tiers for a provisioning service.
     *
     * @param provisioningServiceName Name of provisioning service.
     * @param resourceGroupName Name of resource group.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of valid SKUs and tiers for a provisioning service as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<IotDpsSkuDefinitionInner> listValidSkusAsync(
        String provisioningServiceName, String resourceGroupName) {
        return new PagedFlux<>(
            () -> listValidSkusSinglePageAsync(provisioningServiceName, resourceGroupName),
            nextLink -> listValidSkusNextSinglePageAsync(nextLink));
    }

    /**
     * Gets the list of valid SKUs and tiers for a provisioning service.
     *
     * @param provisioningServiceName Name of provisioning service.
     * @param resourceGroupName Name of resource group.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of valid SKUs and tiers for a provisioning service as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<IotDpsSkuDefinitionInner> listValidSkusAsync(
        String provisioningServiceName, String resourceGroupName, Context context) {
        return new PagedFlux<>(
            () -> listValidSkusSinglePageAsync(provisioningServiceName, resourceGroupName, context),
            nextLink -> listValidSkusNextSinglePageAsync(nextLink, context));
    }

    /**
     * Gets the list of valid SKUs and tiers for a provisioning service.
     *
     * @param provisioningServiceName Name of provisioning service.
     * @param resourceGroupName Name of resource group.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of valid SKUs and tiers for a provisioning service as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<IotDpsSkuDefinitionInner> listValidSkus(
        String provisioningServiceName, String resourceGroupName) {
        return new PagedIterable<>(listValidSkusAsync(provisioningServiceName, resourceGroupName));
    }

    /**
     * Gets the list of valid SKUs and tiers for a provisioning service.
     *
     * @param provisioningServiceName Name of provisioning service.
     * @param resourceGroupName Name of resource group.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of valid SKUs and tiers for a provisioning service as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<IotDpsSkuDefinitionInner> listValidSkus(
        String provisioningServiceName, String resourceGroupName, Context context) {
        return new PagedIterable<>(listValidSkusAsync(provisioningServiceName, resourceGroupName, context));
    }

    /**
     * Check if a provisioning service name is available. This will validate if the name is syntactically valid and if
     * the name is usable.
     *
     * @param arguments Set the name parameter in the OperationInputs structure to the name of the provisioning service
     *     to check.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of name availability along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<NameAvailabilityInfoInner>> checkProvisioningServiceNameAvailabilityWithResponseAsync(
        OperationInputs arguments) {
        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 (arguments == null) {
            return Mono.error(new IllegalArgumentException("Parameter arguments is required and cannot be null."));
        } else {
            arguments.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .checkProvisioningServiceNameAvailability(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            this.client.getApiVersion(),
                            arguments,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Check if a provisioning service name is available. This will validate if the name is syntactically valid and if
     * the name is usable.
     *
     * @param arguments Set the name parameter in the OperationInputs structure to the name of the provisioning service
     *     to check.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of name availability along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<NameAvailabilityInfoInner>> checkProvisioningServiceNameAvailabilityWithResponseAsync(
        OperationInputs arguments, 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 (arguments == null) {
            return Mono.error(new IllegalArgumentException("Parameter arguments is required and cannot be null."));
        } else {
            arguments.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .checkProvisioningServiceNameAvailability(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                this.client.getApiVersion(),
                arguments,
                accept,
                context);
    }

    /**
     * Check if a provisioning service name is available. This will validate if the name is syntactically valid and if
     * the name is usable.
     *
     * @param arguments Set the name parameter in the OperationInputs structure to the name of the provisioning service
     *     to check.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of name availability on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<NameAvailabilityInfoInner> checkProvisioningServiceNameAvailabilityAsync(OperationInputs arguments) {
        return checkProvisioningServiceNameAvailabilityWithResponseAsync(arguments)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Check if a provisioning service name is available. This will validate if the name is syntactically valid and if
     * the name is usable.
     *
     * @param arguments Set the name parameter in the OperationInputs structure to the name of the provisioning service
     *     to check.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of name availability.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NameAvailabilityInfoInner checkProvisioningServiceNameAvailability(OperationInputs arguments) {
        return checkProvisioningServiceNameAvailabilityAsync(arguments).block();
    }

    /**
     * Check if a provisioning service name is available. This will validate if the name is syntactically valid and if
     * the name is usable.
     *
     * @param arguments Set the name parameter in the OperationInputs structure to the name of the provisioning service
     *     to check.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of name availability along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<NameAvailabilityInfoInner> checkProvisioningServiceNameAvailabilityWithResponse(
        OperationInputs arguments, Context context) {
        return checkProvisioningServiceNameAvailabilityWithResponseAsync(arguments, context).block();
    }

    /**
     * List the primary and secondary keys for a provisioning service.
     *
     * @param provisioningServiceName The provisioning service name to get the shared access keys for.
     * @param resourceGroupName resource group name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of shared access keys along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<SharedAccessSignatureAuthorizationRuleInner>> listKeysSinglePageAsync(
        String provisioningServiceName, String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName 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
                        .listKeys(
                            this.client.getEndpoint(),
                            provisioningServiceName,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .<PagedResponse<SharedAccessSignatureAuthorizationRuleInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List the primary and secondary keys for a provisioning service.
     *
     * @param provisioningServiceName The provisioning service name to get the shared access keys for.
     * @param resourceGroupName resource group name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of shared access keys along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<SharedAccessSignatureAuthorizationRuleInner>> listKeysSinglePageAsync(
        String provisioningServiceName, 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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName 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
            .listKeys(
                this.client.getEndpoint(),
                provisioningServiceName,
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * List the primary and secondary keys for a provisioning service.
     *
     * @param provisioningServiceName The provisioning service name to get the shared access keys for.
     * @param resourceGroupName resource group name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of shared access keys as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<SharedAccessSignatureAuthorizationRuleInner> listKeysAsync(
        String provisioningServiceName, String resourceGroupName) {
        return new PagedFlux<>(
            () -> listKeysSinglePageAsync(provisioningServiceName, resourceGroupName),
            nextLink -> listKeysNextSinglePageAsync(nextLink));
    }

    /**
     * List the primary and secondary keys for a provisioning service.
     *
     * @param provisioningServiceName The provisioning service name to get the shared access keys for.
     * @param resourceGroupName resource group name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of shared access keys as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<SharedAccessSignatureAuthorizationRuleInner> listKeysAsync(
        String provisioningServiceName, String resourceGroupName, Context context) {
        return new PagedFlux<>(
            () -> listKeysSinglePageAsync(provisioningServiceName, resourceGroupName, context),
            nextLink -> listKeysNextSinglePageAsync(nextLink, context));
    }

    /**
     * List the primary and secondary keys for a provisioning service.
     *
     * @param provisioningServiceName The provisioning service name to get the shared access keys for.
     * @param resourceGroupName resource group name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of shared access keys as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<SharedAccessSignatureAuthorizationRuleInner> listKeys(
        String provisioningServiceName, String resourceGroupName) {
        return new PagedIterable<>(listKeysAsync(provisioningServiceName, resourceGroupName));
    }

    /**
     * List the primary and secondary keys for a provisioning service.
     *
     * @param provisioningServiceName The provisioning service name to get the shared access keys for.
     * @param resourceGroupName resource group name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of shared access keys as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<SharedAccessSignatureAuthorizationRuleInner> listKeys(
        String provisioningServiceName, String resourceGroupName, Context context) {
        return new PagedIterable<>(listKeysAsync(provisioningServiceName, resourceGroupName, context));
    }

    /**
     * List primary and secondary keys for a specific key name.
     *
     * @param provisioningServiceName Name of the provisioning service.
     * @param keyName Logical key name to get key-values for.
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the shared access key along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SharedAccessSignatureAuthorizationRuleInner>> listKeysForKeyNameWithResponseAsync(
        String provisioningServiceName, String keyName, String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (keyName == null) {
            return Mono.error(new IllegalArgumentException("Parameter keyName 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
                        .listKeysForKeyName(
                            this.client.getEndpoint(),
                            provisioningServiceName,
                            keyName,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List primary and secondary keys for a specific key name.
     *
     * @param provisioningServiceName Name of the provisioning service.
     * @param keyName Logical key name to get key-values for.
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the shared access key along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SharedAccessSignatureAuthorizationRuleInner>> listKeysForKeyNameWithResponseAsync(
        String provisioningServiceName, String keyName, 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 (provisioningServiceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter provisioningServiceName is required and cannot be null."));
        }
        if (keyName == null) {
            return Mono.error(new IllegalArgumentException("Parameter keyName 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
            .listKeysForKeyName(
                this.client.getEndpoint(),
                provisioningServiceName,
                keyName,
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * List primary and secondary keys for a specific key name.
     *
     * @param provisioningServiceName Name of the provisioning service.
     * @param keyName Logical key name to get key-values for.
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the shared access key on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SharedAccessSignatureAuthorizationRuleInner> listKeysForKeyNameAsync(
        String provisioningServiceName, String keyName, String resourceGroupName) {
        return listKeysForKeyNameWithResponseAsync(provisioningServiceName, keyName, resourceGroupName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * List primary and secondary keys for a specific key name.
     *
     * @param provisioningServiceName Name of the provisioning service.
     * @param keyName Logical key name to get key-values for.
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the shared access key.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SharedAccessSignatureAuthorizationRuleInner listKeysForKeyName(
        String provisioningServiceName, String keyName, String resourceGroupName) {
        return listKeysForKeyNameAsync(provisioningServiceName, keyName, resourceGroupName).block();
    }

    /**
     * List primary and secondary keys for a specific key name.
     *
     * @param provisioningServiceName Name of the provisioning service.
     * @param keyName Logical key name to get key-values for.
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return description of the shared access key along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SharedAccessSignatureAuthorizationRuleInner> listKeysForKeyNameWithResponse(
        String provisioningServiceName, String keyName, String resourceGroupName, Context context) {
        return listKeysForKeyNameWithResponseAsync(provisioningServiceName, keyName, resourceGroupName, context)
            .block();
    }

    /**
     * List private link resources for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the available private link resources for a provisioning service along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<PrivateLinkResourcesInner>> listPrivateLinkResourcesWithResponseAsync(
        String resourceGroupName, String resourceName) {
        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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listPrivateLinkResources(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            resourceName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List private link resources for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the available private link resources for a provisioning service along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<PrivateLinkResourcesInner>> listPrivateLinkResourcesWithResponseAsync(
        String resourceGroupName, String resourceName, 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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listPrivateLinkResources(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                resourceName,
                accept,
                context);
    }

    /**
     * List private link resources for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the available private link resources for a provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PrivateLinkResourcesInner> listPrivateLinkResourcesAsync(
        String resourceGroupName, String resourceName) {
        return listPrivateLinkResourcesWithResponseAsync(resourceGroupName, resourceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * List private link resources for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the available private link resources for a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PrivateLinkResourcesInner listPrivateLinkResources(String resourceGroupName, String resourceName) {
        return listPrivateLinkResourcesAsync(resourceGroupName, resourceName).block();
    }

    /**
     * List private link resources for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the available private link resources for a provisioning service along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<PrivateLinkResourcesInner> listPrivateLinkResourcesWithResponse(
        String resourceGroupName, String resourceName, Context context) {
        return listPrivateLinkResourcesWithResponseAsync(resourceGroupName, resourceName, context).block();
    }

    /**
     * Get the specified private link resource for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param groupId The name of the private link resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the specified private link resource for the given provisioning service along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<GroupIdInformationInner>> getPrivateLinkResourcesWithResponseAsync(
        String resourceGroupName, String resourceName, String groupId) {
        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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (groupId == null) {
            return Mono.error(new IllegalArgumentException("Parameter groupId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getPrivateLinkResources(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            resourceName,
                            groupId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the specified private link resource for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param groupId The name of the private link resource.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the specified private link resource for the given provisioning service along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<GroupIdInformationInner>> getPrivateLinkResourcesWithResponseAsync(
        String resourceGroupName, String resourceName, String groupId, 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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (groupId == null) {
            return Mono.error(new IllegalArgumentException("Parameter groupId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getPrivateLinkResources(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                resourceName,
                groupId,
                accept,
                context);
    }

    /**
     * Get the specified private link resource for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param groupId The name of the private link resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the specified private link resource for the given provisioning service on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<GroupIdInformationInner> getPrivateLinkResourcesAsync(
        String resourceGroupName, String resourceName, String groupId) {
        return getPrivateLinkResourcesWithResponseAsync(resourceGroupName, resourceName, groupId)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get the specified private link resource for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param groupId The name of the private link resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the specified private link resource for the given provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public GroupIdInformationInner getPrivateLinkResources(
        String resourceGroupName, String resourceName, String groupId) {
        return getPrivateLinkResourcesAsync(resourceGroupName, resourceName, groupId).block();
    }

    /**
     * Get the specified private link resource for the given provisioning service.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param groupId The name of the private link resource.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the specified private link resource for the given provisioning service along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<GroupIdInformationInner> getPrivateLinkResourcesWithResponse(
        String resourceGroupName, String resourceName, String groupId, Context context) {
        return getPrivateLinkResourcesWithResponseAsync(resourceGroupName, resourceName, groupId, context).block();
    }

    /**
     * List private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of private endpoint connections for a provisioning service along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<List<PrivateEndpointConnectionInner>>> listPrivateEndpointConnectionsWithResponseAsync(
        String resourceGroupName, String resourceName) {
        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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listPrivateEndpointConnections(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            resourceName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of private endpoint connections for a provisioning service along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<List<PrivateEndpointConnectionInner>>> listPrivateEndpointConnectionsWithResponseAsync(
        String resourceGroupName, String resourceName, 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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listPrivateEndpointConnections(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                resourceName,
                accept,
                context);
    }

    /**
     * List private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of private endpoint connections for a provisioning service on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<List<PrivateEndpointConnectionInner>> listPrivateEndpointConnectionsAsync(
        String resourceGroupName, String resourceName) {
        return listPrivateEndpointConnectionsWithResponseAsync(resourceGroupName, resourceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * List private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of private endpoint connections for a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public List<PrivateEndpointConnectionInner> listPrivateEndpointConnections(
        String resourceGroupName, String resourceName) {
        return listPrivateEndpointConnectionsAsync(resourceGroupName, resourceName).block();
    }

    /**
     * List private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of private endpoint connections for a provisioning service along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<List<PrivateEndpointConnectionInner>> listPrivateEndpointConnectionsWithResponse(
        String resourceGroupName, String resourceName, Context context) {
        return listPrivateEndpointConnectionsWithResponseAsync(resourceGroupName, resourceName, context).block();
    }

    /**
     * Get private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return private endpoint connection properties along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<PrivateEndpointConnectionInner>> getPrivateEndpointConnectionWithResponseAsync(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName) {
        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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (privateEndpointConnectionName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter privateEndpointConnectionName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getPrivateEndpointConnection(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            resourceName,
                            privateEndpointConnectionName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return private endpoint connection properties along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<PrivateEndpointConnectionInner>> getPrivateEndpointConnectionWithResponseAsync(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName, 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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (privateEndpointConnectionName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter privateEndpointConnectionName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getPrivateEndpointConnection(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                resourceName,
                privateEndpointConnectionName,
                accept,
                context);
    }

    /**
     * Get private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return private endpoint connection properties on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PrivateEndpointConnectionInner> getPrivateEndpointConnectionAsync(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName) {
        return getPrivateEndpointConnectionWithResponseAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return private endpoint connection properties.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PrivateEndpointConnectionInner getPrivateEndpointConnection(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName) {
        return getPrivateEndpointConnectionAsync(resourceGroupName, resourceName, privateEndpointConnectionName)
            .block();
    }

    /**
     * Get private endpoint connection properties.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return private endpoint connection properties along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<PrivateEndpointConnectionInner> getPrivateEndpointConnectionWithResponse(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName, Context context) {
        return getPrivateEndpointConnectionWithResponseAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, context)
            .block();
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdatePrivateEndpointConnectionWithResponseAsync(
        String resourceGroupName,
        String resourceName,
        String privateEndpointConnectionName,
        PrivateEndpointConnectionInner privateEndpointConnection) {
        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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (privateEndpointConnectionName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter privateEndpointConnectionName is required and cannot be null."));
        }
        if (privateEndpointConnection == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter privateEndpointConnection is required and cannot be null."));
        } else {
            privateEndpointConnection.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdatePrivateEndpointConnection(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            resourceName,
                            privateEndpointConnectionName,
                            privateEndpointConnection,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdatePrivateEndpointConnectionWithResponseAsync(
        String resourceGroupName,
        String resourceName,
        String privateEndpointConnectionName,
        PrivateEndpointConnectionInner privateEndpointConnection,
        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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (privateEndpointConnectionName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter privateEndpointConnectionName is required and cannot be null."));
        }
        if (privateEndpointConnection == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter privateEndpointConnection is required and cannot be null."));
        } else {
            privateEndpointConnection.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdatePrivateEndpointConnection(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                resourceName,
                privateEndpointConnectionName,
                privateEndpointConnection,
                accept,
                context);
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<PrivateEndpointConnectionInner>, PrivateEndpointConnectionInner>
        beginCreateOrUpdatePrivateEndpointConnectionAsync(
            String resourceGroupName,
            String resourceName,
            String privateEndpointConnectionName,
            PrivateEndpointConnectionInner privateEndpointConnection) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdatePrivateEndpointConnectionWithResponseAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection);
        return this
            .client
            .<PrivateEndpointConnectionInner, PrivateEndpointConnectionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                PrivateEndpointConnectionInner.class,
                PrivateEndpointConnectionInner.class,
                this.client.getContext());
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<PrivateEndpointConnectionInner>, PrivateEndpointConnectionInner>
        beginCreateOrUpdatePrivateEndpointConnectionAsync(
            String resourceGroupName,
            String resourceName,
            String privateEndpointConnectionName,
            PrivateEndpointConnectionInner privateEndpointConnection,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdatePrivateEndpointConnectionWithResponseAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection, context);
        return this
            .client
            .<PrivateEndpointConnectionInner, PrivateEndpointConnectionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                PrivateEndpointConnectionInner.class,
                PrivateEndpointConnectionInner.class,
                context);
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<PrivateEndpointConnectionInner>, PrivateEndpointConnectionInner>
        beginCreateOrUpdatePrivateEndpointConnection(
            String resourceGroupName,
            String resourceName,
            String privateEndpointConnectionName,
            PrivateEndpointConnectionInner privateEndpointConnection) {
        return beginCreateOrUpdatePrivateEndpointConnectionAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection)
            .getSyncPoller();
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<PrivateEndpointConnectionInner>, PrivateEndpointConnectionInner>
        beginCreateOrUpdatePrivateEndpointConnection(
            String resourceGroupName,
            String resourceName,
            String privateEndpointConnectionName,
            PrivateEndpointConnectionInner privateEndpointConnection,
            Context context) {
        return beginCreateOrUpdatePrivateEndpointConnectionAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection, context)
            .getSyncPoller();
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PrivateEndpointConnectionInner> createOrUpdatePrivateEndpointConnectionAsync(
        String resourceGroupName,
        String resourceName,
        String privateEndpointConnectionName,
        PrivateEndpointConnectionInner privateEndpointConnection) {
        return beginCreateOrUpdatePrivateEndpointConnectionAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PrivateEndpointConnectionInner> createOrUpdatePrivateEndpointConnectionAsync(
        String resourceGroupName,
        String resourceName,
        String privateEndpointConnectionName,
        PrivateEndpointConnectionInner privateEndpointConnection,
        Context context) {
        return beginCreateOrUpdatePrivateEndpointConnectionAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PrivateEndpointConnectionInner createOrUpdatePrivateEndpointConnection(
        String resourceGroupName,
        String resourceName,
        String privateEndpointConnectionName,
        PrivateEndpointConnectionInner privateEndpointConnection) {
        return createOrUpdatePrivateEndpointConnectionAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection)
            .block();
    }

    /**
     * Create or update the status of a private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param privateEndpointConnection The private endpoint connection with updated properties.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PrivateEndpointConnectionInner createOrUpdatePrivateEndpointConnection(
        String resourceGroupName,
        String resourceName,
        String privateEndpointConnectionName,
        PrivateEndpointConnectionInner privateEndpointConnection,
        Context context) {
        return createOrUpdatePrivateEndpointConnectionAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection, context)
            .block();
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> deletePrivateEndpointConnectionWithResponseAsync(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName) {
        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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (privateEndpointConnectionName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter privateEndpointConnectionName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .deletePrivateEndpointConnection(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            resourceName,
                            privateEndpointConnectionName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> deletePrivateEndpointConnectionWithResponseAsync(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName, 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 (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (privateEndpointConnectionName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter privateEndpointConnectionName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .deletePrivateEndpointConnection(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                resourceName,
                privateEndpointConnectionName,
                accept,
                context);
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<PrivateEndpointConnectionInner>, PrivateEndpointConnectionInner>
        beginDeletePrivateEndpointConnectionAsync(
            String resourceGroupName, String resourceName, String privateEndpointConnectionName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            deletePrivateEndpointConnectionWithResponseAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName);
        return this
            .client
            .<PrivateEndpointConnectionInner, PrivateEndpointConnectionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                PrivateEndpointConnectionInner.class,
                PrivateEndpointConnectionInner.class,
                this.client.getContext());
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<PrivateEndpointConnectionInner>, PrivateEndpointConnectionInner>
        beginDeletePrivateEndpointConnectionAsync(
            String resourceGroupName, String resourceName, String privateEndpointConnectionName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            deletePrivateEndpointConnectionWithResponseAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, context);
        return this
            .client
            .<PrivateEndpointConnectionInner, PrivateEndpointConnectionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                PrivateEndpointConnectionInner.class,
                PrivateEndpointConnectionInner.class,
                context);
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<PrivateEndpointConnectionInner>, PrivateEndpointConnectionInner>
        beginDeletePrivateEndpointConnection(
            String resourceGroupName, String resourceName, String privateEndpointConnectionName) {
        return beginDeletePrivateEndpointConnectionAsync(resourceGroupName, resourceName, privateEndpointConnectionName)
            .getSyncPoller();
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException 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 the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<PrivateEndpointConnectionInner>, PrivateEndpointConnectionInner>
        beginDeletePrivateEndpointConnection(
            String resourceGroupName, String resourceName, String privateEndpointConnectionName, Context context) {
        return beginDeletePrivateEndpointConnectionAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, context)
            .getSyncPoller();
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PrivateEndpointConnectionInner> deletePrivateEndpointConnectionAsync(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName) {
        return beginDeletePrivateEndpointConnectionAsync(resourceGroupName, resourceName, privateEndpointConnectionName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PrivateEndpointConnectionInner> deletePrivateEndpointConnectionAsync(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName, Context context) {
        return beginDeletePrivateEndpointConnectionAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PrivateEndpointConnectionInner deletePrivateEndpointConnection(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName) {
        return deletePrivateEndpointConnectionAsync(resourceGroupName, resourceName, privateEndpointConnectionName)
            .block();
    }

    /**
     * Delete private endpoint connection with the specified name.
     *
     * @param resourceGroupName The name of the resource group that contains the provisioning service.
     * @param resourceName The name of the provisioning service.
     * @param privateEndpointConnectionName The name of the private endpoint connection.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the private endpoint connection of a provisioning service.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PrivateEndpointConnectionInner deletePrivateEndpointConnection(
        String resourceGroupName, String resourceName, String privateEndpointConnectionName, Context context) {
        return deletePrivateEndpointConnectionAsync(
                resourceGroupName, resourceName, privateEndpointConnectionName, context)
            .block();
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProvisioningServiceDescriptionInner>> listBySubscriptionNextSinglePageAsync(
        String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<ProvisioningServiceDescriptionInner>>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 nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProvisioningServiceDescriptionInner>> listBySubscriptionNextSinglePageAsync(
        String nextLink, Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProvisioningServiceDescriptionInner>> 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<ProvisioningServiceDescriptionInner>>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 nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of provisioning service descriptions along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProvisioningServiceDescriptionInner>> 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));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of available SKUs along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<IotDpsSkuDefinitionInner>> listValidSkusNextSinglePageAsync(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.listValidSkusNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<IotDpsSkuDefinitionInner>>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 nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of available SKUs along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<IotDpsSkuDefinitionInner>> listValidSkusNextSinglePageAsync(
        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
            .listValidSkusNext(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 nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of shared access keys along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<SharedAccessSignatureAuthorizationRuleInner>> listKeysNextSinglePageAsync(
        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.listKeysNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<SharedAccessSignatureAuthorizationRuleInner>>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 nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorDetailsException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of shared access keys along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<SharedAccessSignatureAuthorizationRuleInner>> listKeysNextSinglePageAsync(
        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
            .listKeysNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }
}
