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

package com.azure.resourcemanager.chaos.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.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.chaos.fluent.ExperimentsClient;
import com.azure.resourcemanager.chaos.fluent.models.ExperimentCancelOperationResultInner;
import com.azure.resourcemanager.chaos.fluent.models.ExperimentExecutionDetailsInner;
import com.azure.resourcemanager.chaos.fluent.models.ExperimentInner;
import com.azure.resourcemanager.chaos.fluent.models.ExperimentStartOperationResultInner;
import com.azure.resourcemanager.chaos.fluent.models.ExperimentStatusInner;
import com.azure.resourcemanager.chaos.models.ExperimentExecutionDetailsListResult;
import com.azure.resourcemanager.chaos.models.ExperimentListResult;
import com.azure.resourcemanager.chaos.models.ExperimentStatusListResult;
import com.azure.resourcemanager.chaos.models.ExperimentUpdate;
import reactor.core.publisher.Mono;

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

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

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

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

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

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

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

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ExperimentInner>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("experimentName") String experimentName,
            @BodyParam("application/json") ExperimentInner experiment,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ExperimentInner>> update(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("experimentName") String experimentName,
            @BodyParam("application/json") ExperimentUpdate experiment,
            @HeaderParam("Accept") String accept,
            Context context);

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

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

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

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

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

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

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

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

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

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

    /**
     * Get a list of Experiment resources in a subscription.
     *
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a subscription along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentInner>> listSinglePageAsync(Boolean running, String continuationToken) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .list(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            running,
                            continuationToken,
                            accept,
                            context))
            .<PagedResponse<ExperimentInner>>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 Experiment resources in a subscription.
     *
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a subscription along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentInner>> listSinglePageAsync(
        Boolean running, String continuationToken, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                running,
                continuationToken,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get a list of Experiment resources in a subscription.
     *
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a subscription as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentInner> listAsync(Boolean running, String continuationToken) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(running, continuationToken), nextLink -> listAllNextSinglePageAsync(nextLink));
    }

    /**
     * Get a list of Experiment resources in a subscription.
     *
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a subscription as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentInner> listAsync() {
        final Boolean running = null;
        final String continuationToken = null;
        return new PagedFlux<>(
            () -> listSinglePageAsync(running, continuationToken), nextLink -> listAllNextSinglePageAsync(nextLink));
    }

    /**
     * Get a list of Experiment resources in a subscription.
     *
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a subscription as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentInner> listAsync(Boolean running, String continuationToken, Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(running, continuationToken, context),
            nextLink -> listAllNextSinglePageAsync(nextLink, context));
    }

    /**
     * Get a list of Experiment resources in a subscription.
     *
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a subscription as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ExperimentInner> list() {
        final Boolean running = null;
        final String continuationToken = null;
        return new PagedIterable<>(listAsync(running, continuationToken));
    }

    /**
     * Get a list of Experiment resources in a subscription.
     *
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a subscription as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ExperimentInner> list(Boolean running, String continuationToken, Context context) {
        return new PagedIterable<>(listAsync(running, continuationToken, context));
    }

    /**
     * Get a list of Experiment resources in a resource group.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a resource group along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentInner>> listByResourceGroupSinglePageAsync(
        String resourceGroupName, Boolean running, String continuationToken) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByResourceGroup(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            running,
                            continuationToken,
                            accept,
                            context))
            .<PagedResponse<ExperimentInner>>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 Experiment resources in a resource group.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a resource group along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentInner>> listByResourceGroupSinglePageAsync(
        String resourceGroupName, Boolean running, String continuationToken, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByResourceGroup(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                running,
                continuationToken,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get a list of Experiment resources in a resource group.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a resource group as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentInner> listByResourceGroupAsync(
        String resourceGroupName, Boolean running, String continuationToken) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName, running, continuationToken),
            nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * Get a list of Experiment resources in a resource group.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a resource group as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentInner> listByResourceGroupAsync(String resourceGroupName) {
        final Boolean running = null;
        final String continuationToken = null;
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName, running, continuationToken),
            nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * Get a list of Experiment resources in a resource group.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a resource group as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentInner> listByResourceGroupAsync(
        String resourceGroupName, Boolean running, String continuationToken, Context context) {
        return new PagedFlux<>(
            () -> listByResourceGroupSinglePageAsync(resourceGroupName, running, continuationToken, context),
            nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * Get a list of Experiment resources in a resource group.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a resource group as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ExperimentInner> listByResourceGroup(String resourceGroupName) {
        final Boolean running = null;
        final String continuationToken = null;
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, running, continuationToken));
    }

    /**
     * Get a list of Experiment resources in a resource group.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param running Optional value that indicates whether to filter results based on if the Experiment is currently
     *     running. If null, then the results will not be filtered.
     * @param continuationToken String that sets the continuation token.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of Experiment resources in a resource group as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ExperimentInner> listByResourceGroup(
        String resourceGroupName, Boolean running, String continuationToken, Context context) {
        return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, running, continuationToken, context));
    }

    /**
     * Delete a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(String resourceGroupName, String experimentName) {
        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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            experimentName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

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

    /**
     * Delete a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(String resourceGroupName, String experimentName) {
        return deleteWithResponseAsync(resourceGroupName, experimentName).flatMap(ignored -> Mono.empty());
    }

    /**
     * Delete a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteWithResponse(String resourceGroupName, String experimentName, Context context) {
        return deleteWithResponseAsync(resourceGroupName, experimentName, context).block();
    }

    /**
     * Delete a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String resourceGroupName, String experimentName) {
        deleteWithResponse(resourceGroupName, experimentName, Context.NONE);
    }

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

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

    /**
     * Get a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Experiment resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ExperimentInner> getByResourceGroupAsync(String resourceGroupName, String experimentName) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, experimentName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Experiment resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ExperimentInner> getByResourceGroupWithResponse(
        String resourceGroupName, String experimentName, Context context) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, experimentName, context).block();
    }

    /**
     * Get a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Experiment resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ExperimentInner getByResourceGroup(String resourceGroupName, String experimentName) {
        return getByResourceGroupWithResponse(resourceGroupName, experimentName, Context.NONE).getValue();
    }

    /**
     * Create or update a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Experiment resource to be created or updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a Experiment resource along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentInner>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String experimentName, ExperimentInner experiment) {
        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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        if (experiment == null) {
            return Mono.error(new IllegalArgumentException("Parameter experiment is required and cannot be null."));
        } else {
            experiment.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            experimentName,
                            experiment,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create or update a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Experiment resource to be created or updated.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a Experiment resource along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentInner>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String experimentName, ExperimentInner experiment, 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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        if (experiment == null) {
            return Mono.error(new IllegalArgumentException("Parameter experiment is required and cannot be null."));
        } else {
            experiment.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                experimentName,
                experiment,
                accept,
                context);
    }

    /**
     * Create or update a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Experiment resource to be created or updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a Experiment resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ExperimentInner> createOrUpdateAsync(
        String resourceGroupName, String experimentName, ExperimentInner experiment) {
        return createOrUpdateWithResponseAsync(resourceGroupName, experimentName, experiment)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Create or update a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Experiment resource to be created or updated.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a Experiment resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ExperimentInner> createOrUpdateWithResponse(
        String resourceGroupName, String experimentName, ExperimentInner experiment, Context context) {
        return createOrUpdateWithResponseAsync(resourceGroupName, experimentName, experiment, context).block();
    }

    /**
     * Create or update a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Experiment resource to be created or updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a Experiment resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ExperimentInner createOrUpdate(String resourceGroupName, String experimentName, ExperimentInner experiment) {
        return createOrUpdateWithResponse(resourceGroupName, experimentName, experiment, Context.NONE).getValue();
    }

    /**
     * The operation to update an experiment.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Parameters supplied to the Update experiment 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 model that represents a Experiment resource along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentInner>> updateWithResponseAsync(
        String resourceGroupName, String experimentName, ExperimentUpdate experiment) {
        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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        if (experiment == null) {
            return Mono.error(new IllegalArgumentException("Parameter experiment is required and cannot be null."));
        } else {
            experiment.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            experimentName,
                            experiment,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * The operation to update an experiment.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Parameters supplied to the Update experiment operation.
     * @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 model that represents a Experiment resource along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentInner>> updateWithResponseAsync(
        String resourceGroupName, String experimentName, ExperimentUpdate experiment, 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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        if (experiment == null) {
            return Mono.error(new IllegalArgumentException("Parameter experiment is required and cannot be null."));
        } else {
            experiment.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                experimentName,
                experiment,
                accept,
                context);
    }

    /**
     * The operation to update an experiment.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Parameters supplied to the Update experiment 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 model that represents a Experiment resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ExperimentInner> updateAsync(
        String resourceGroupName, String experimentName, ExperimentUpdate experiment) {
        return updateWithResponseAsync(resourceGroupName, experimentName, experiment)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * The operation to update an experiment.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Parameters supplied to the Update experiment operation.
     * @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 model that represents a Experiment resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ExperimentInner> updateWithResponse(
        String resourceGroupName, String experimentName, ExperimentUpdate experiment, Context context) {
        return updateWithResponseAsync(resourceGroupName, experimentName, experiment, context).block();
    }

    /**
     * The operation to update an experiment.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param experiment Parameters supplied to the Update experiment 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 model that represents a Experiment resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ExperimentInner update(String resourceGroupName, String experimentName, ExperimentUpdate experiment) {
        return updateWithResponse(resourceGroupName, experimentName, experiment, Context.NONE).getValue();
    }

    /**
     * Cancel a running Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a cancel Experiment operation along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentCancelOperationResultInner>> cancelWithResponseAsync(
        String resourceGroupName, String experimentName) {
        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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .cancel(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            experimentName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Cancel a running Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a cancel Experiment operation along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentCancelOperationResultInner>> cancelWithResponseAsync(
        String resourceGroupName, String experimentName, 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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .cancel(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                experimentName,
                accept,
                context);
    }

    /**
     * Cancel a running Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a cancel Experiment operation on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ExperimentCancelOperationResultInner> cancelAsync(String resourceGroupName, String experimentName) {
        return cancelWithResponseAsync(resourceGroupName, experimentName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Cancel a running Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a cancel Experiment operation along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ExperimentCancelOperationResultInner> cancelWithResponse(
        String resourceGroupName, String experimentName, Context context) {
        return cancelWithResponseAsync(resourceGroupName, experimentName, context).block();
    }

    /**
     * Cancel a running Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a cancel Experiment operation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ExperimentCancelOperationResultInner cancel(String resourceGroupName, String experimentName) {
        return cancelWithResponse(resourceGroupName, experimentName, Context.NONE).getValue();
    }

    /**
     * Start a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a start Experiment operation along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentStartOperationResultInner>> startWithResponseAsync(
        String resourceGroupName, String experimentName) {
        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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .start(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            experimentName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Start a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a start Experiment operation along with {@link Response} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentStartOperationResultInner>> startWithResponseAsync(
        String resourceGroupName, String experimentName, 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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .start(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                experimentName,
                accept,
                context);
    }

    /**
     * Start a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a start Experiment operation on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ExperimentStartOperationResultInner> startAsync(String resourceGroupName, String experimentName) {
        return startWithResponseAsync(resourceGroupName, experimentName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Start a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a start Experiment operation along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ExperimentStartOperationResultInner> startWithResponse(
        String resourceGroupName, String experimentName, Context context) {
        return startWithResponseAsync(resourceGroupName, experimentName, context).block();
    }

    /**
     * Start a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents the result of a start Experiment operation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ExperimentStartOperationResultInner start(String resourceGroupName, String experimentName) {
        return startWithResponse(resourceGroupName, experimentName, Context.NONE).getValue();
    }

    /**
     * Get a list of statuses of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of statuses of a Experiment resource along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentStatusInner>> listAllStatusesSinglePageAsync(
        String resourceGroupName, String experimentName) {
        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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listAllStatuses(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            experimentName,
                            accept,
                            context))
            .<PagedResponse<ExperimentStatusInner>>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 statuses of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of statuses of a Experiment resource along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentStatusInner>> listAllStatusesSinglePageAsync(
        String resourceGroupName, String experimentName, 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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listAllStatuses(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                experimentName,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get a list of statuses of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of statuses of a Experiment resource as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentStatusInner> listAllStatusesAsync(String resourceGroupName, String experimentName) {
        return new PagedFlux<>(
            () -> listAllStatusesSinglePageAsync(resourceGroupName, experimentName),
            nextLink -> listAllStatusesNextSinglePageAsync(nextLink));
    }

    /**
     * Get a list of statuses of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of statuses of a Experiment resource as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentStatusInner> listAllStatusesAsync(
        String resourceGroupName, String experimentName, Context context) {
        return new PagedFlux<>(
            () -> listAllStatusesSinglePageAsync(resourceGroupName, experimentName, context),
            nextLink -> listAllStatusesNextSinglePageAsync(nextLink, context));
    }

    /**
     * Get a list of statuses of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of statuses of a Experiment resource as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ExperimentStatusInner> listAllStatuses(String resourceGroupName, String experimentName) {
        return new PagedIterable<>(listAllStatusesAsync(resourceGroupName, experimentName));
    }

    /**
     * Get a list of statuses of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of statuses of a Experiment resource as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ExperimentStatusInner> listAllStatuses(
        String resourceGroupName, String experimentName, Context context) {
        return new PagedIterable<>(listAllStatusesAsync(resourceGroupName, experimentName, context));
    }

    /**
     * Get a status of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param statusId GUID that represents a Experiment status.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a status of a Experiment resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentStatusInner>> getStatusWithResponseAsync(
        String resourceGroupName, String experimentName, String statusId) {
        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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        if (statusId == null) {
            return Mono.error(new IllegalArgumentException("Parameter statusId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getStatus(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            experimentName,
                            statusId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get a status of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param statusId GUID that represents a Experiment status.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a status of a Experiment resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentStatusInner>> getStatusWithResponseAsync(
        String resourceGroupName, String experimentName, String statusId, 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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        if (statusId == null) {
            return Mono.error(new IllegalArgumentException("Parameter statusId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getStatus(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                experimentName,
                statusId,
                accept,
                context);
    }

    /**
     * Get a status of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param statusId GUID that represents a Experiment status.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a status of a Experiment resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ExperimentStatusInner> getStatusAsync(
        String resourceGroupName, String experimentName, String statusId) {
        return getStatusWithResponseAsync(resourceGroupName, experimentName, statusId)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get a status of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param statusId GUID that represents a Experiment status.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a status of a Experiment resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ExperimentStatusInner> getStatusWithResponse(
        String resourceGroupName, String experimentName, String statusId, Context context) {
        return getStatusWithResponseAsync(resourceGroupName, experimentName, statusId, context).block();
    }

    /**
     * Get a status of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param statusId GUID that represents a Experiment status.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a status of a Experiment resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ExperimentStatusInner getStatus(String resourceGroupName, String experimentName, String statusId) {
        return getStatusWithResponse(resourceGroupName, experimentName, statusId, Context.NONE).getValue();
    }

    /**
     * Get a list of execution details of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of execution details of a Experiment resource along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentExecutionDetailsInner>> listExecutionDetailsSinglePageAsync(
        String resourceGroupName, String experimentName) {
        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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listExecutionDetails(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            experimentName,
                            accept,
                            context))
            .<PagedResponse<ExperimentExecutionDetailsInner>>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 execution details of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of execution details of a Experiment resource along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentExecutionDetailsInner>> listExecutionDetailsSinglePageAsync(
        String resourceGroupName, String experimentName, 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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listExecutionDetails(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                experimentName,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get a list of execution details of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of execution details of a Experiment resource as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentExecutionDetailsInner> listExecutionDetailsAsync(
        String resourceGroupName, String experimentName) {
        return new PagedFlux<>(
            () -> listExecutionDetailsSinglePageAsync(resourceGroupName, experimentName),
            nextLink -> listExecutionDetailsNextSinglePageAsync(nextLink));
    }

    /**
     * Get a list of execution details of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of execution details of a Experiment resource as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ExperimentExecutionDetailsInner> listExecutionDetailsAsync(
        String resourceGroupName, String experimentName, Context context) {
        return new PagedFlux<>(
            () -> listExecutionDetailsSinglePageAsync(resourceGroupName, experimentName, context),
            nextLink -> listExecutionDetailsNextSinglePageAsync(nextLink, context));
    }

    /**
     * Get a list of execution details of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of execution details of a Experiment resource as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ExperimentExecutionDetailsInner> listExecutionDetails(
        String resourceGroupName, String experimentName) {
        return new PagedIterable<>(listExecutionDetailsAsync(resourceGroupName, experimentName));
    }

    /**
     * Get a list of execution details of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of execution details of a Experiment resource as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ExperimentExecutionDetailsInner> listExecutionDetails(
        String resourceGroupName, String experimentName, Context context) {
        return new PagedIterable<>(listExecutionDetailsAsync(resourceGroupName, experimentName, context));
    }

    /**
     * Get an execution detail of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param executionDetailsId GUID that represents a Experiment execution detail.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an execution detail of a Experiment resource along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentExecutionDetailsInner>> getExecutionDetailsWithResponseAsync(
        String resourceGroupName, String experimentName, String executionDetailsId) {
        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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        if (executionDetailsId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter executionDetailsId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getExecutionDetails(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            experimentName,
                            executionDetailsId,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get an execution detail of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param executionDetailsId GUID that represents a Experiment execution detail.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an execution detail of a Experiment resource along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExperimentExecutionDetailsInner>> getExecutionDetailsWithResponseAsync(
        String resourceGroupName, String experimentName, String executionDetailsId, 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 (experimentName == null) {
            return Mono.error(new IllegalArgumentException("Parameter experimentName is required and cannot be null."));
        }
        if (executionDetailsId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter executionDetailsId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getExecutionDetails(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                experimentName,
                executionDetailsId,
                accept,
                context);
    }

    /**
     * Get an execution detail of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param executionDetailsId GUID that represents a Experiment execution detail.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an execution detail of a Experiment resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ExperimentExecutionDetailsInner> getExecutionDetailsAsync(
        String resourceGroupName, String experimentName, String executionDetailsId) {
        return getExecutionDetailsWithResponseAsync(resourceGroupName, experimentName, executionDetailsId)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get an execution detail of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param executionDetailsId GUID that represents a Experiment execution detail.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an execution detail of a Experiment resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ExperimentExecutionDetailsInner> getExecutionDetailsWithResponse(
        String resourceGroupName, String experimentName, String executionDetailsId, Context context) {
        return getExecutionDetailsWithResponseAsync(resourceGroupName, experimentName, executionDetailsId, context)
            .block();
    }

    /**
     * Get an execution detail of a Experiment resource.
     *
     * @param resourceGroupName String that represents an Azure resource group.
     * @param experimentName String that represents a Experiment resource name.
     * @param executionDetailsId GUID that represents a Experiment execution detail.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an execution detail of a Experiment resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ExperimentExecutionDetailsInner getExecutionDetails(
        String resourceGroupName, String experimentName, String executionDetailsId) {
        return getExecutionDetailsWithResponse(resourceGroupName, experimentName, executionDetailsId, Context.NONE)
            .getValue();
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a list of Experiment resources and a link for pagination along with {@link
     *     PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentInner>> listAllNextSinglePageAsync(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.listAllNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<ExperimentInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a list of Experiment resources and a link for pagination along with {@link
     *     PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentInner>> listAllNextSinglePageAsync(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
            .listAllNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a list of Experiment resources and a link for pagination along with {@link
     *     PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentInner>> listNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<ExperimentInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a list of Experiment resources and a link for pagination along with {@link
     *     PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentInner>> listNextSinglePageAsync(String nextLink, Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a list of Experiment statuses and a link for pagination along with {@link
     *     PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentStatusInner>> listAllStatusesNextSinglePageAsync(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.listAllStatusesNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<ExperimentStatusInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a list of Experiment statuses and a link for pagination along with {@link
     *     PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentStatusInner>> listAllStatusesNextSinglePageAsync(
        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
            .listAllStatusesNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a list of Experiment execution details and a link for pagination along with {@link
     *     PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentExecutionDetailsInner>> listExecutionDetailsNextSinglePageAsync(
        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.listExecutionDetailsNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<ExperimentExecutionDetailsInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return model that represents a list of Experiment execution details and a link for pagination along with {@link
     *     PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ExperimentExecutionDetailsInner>> listExecutionDetailsNextSinglePageAsync(
        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
            .listExecutionDetailsNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }
}
