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

package com.azure.resourcemanager.operationsmanagement.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.operationsmanagement.fluent.SolutionsClient;
import com.azure.resourcemanager.operationsmanagement.fluent.models.SolutionInner;
import com.azure.resourcemanager.operationsmanagement.fluent.models.SolutionPropertiesListInner;
import com.azure.resourcemanager.operationsmanagement.models.SolutionPatch;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

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

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

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

    /**
     * The interface defining all the services for OperationsManagementClientSolutions to be used by the proxy service
     * to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "OperationsManagement")
    public interface SolutionsService {
        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers"
                + "/Microsoft.OperationsManagement/solutions/{solutionName}")
        @ExpectedResponses({201})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("solutionName") String solutionName,
            @BodyParam("application/json") SolutionInner parameters,
            @HeaderParam("Accept") String accept,
            Context context);

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

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

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

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

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

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 container for solution along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String solutionName, SolutionInner parameters) {
        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 (solutionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter solutionName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            solutionName,
                            parameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @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 container for solution along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String solutionName, SolutionInner parameters, 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 (solutionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter solutionName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                solutionName,
                parameters,
                accept,
                context);
    }

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the container for solution.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SolutionInner>, SolutionInner> beginCreateOrUpdateAsync(
        String resourceGroupName, String solutionName, SolutionInner parameters) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(resourceGroupName, solutionName, parameters);
        return this
            .client
            .<SolutionInner, SolutionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                SolutionInner.class,
                SolutionInner.class,
                this.client.getContext());
    }

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the container for solution.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SolutionInner>, SolutionInner> beginCreateOrUpdateAsync(
        String resourceGroupName, String solutionName, SolutionInner parameters, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(resourceGroupName, solutionName, parameters, context);
        return this
            .client
            .<SolutionInner, SolutionInner>getLroResult(
                mono, this.client.getHttpPipeline(), SolutionInner.class, SolutionInner.class, context);
    }

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the container for solution.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<SolutionInner>, SolutionInner> beginCreateOrUpdate(
        String resourceGroupName, String solutionName, SolutionInner parameters) {
        return this.beginCreateOrUpdateAsync(resourceGroupName, solutionName, parameters).getSyncPoller();
    }

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the container for solution.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<SolutionInner>, SolutionInner> beginCreateOrUpdate(
        String resourceGroupName, String solutionName, SolutionInner parameters, Context context) {
        return this.beginCreateOrUpdateAsync(resourceGroupName, solutionName, parameters, context).getSyncPoller();
    }

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 container for solution on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SolutionInner> createOrUpdateAsync(
        String resourceGroupName, String solutionName, SolutionInner parameters) {
        return beginCreateOrUpdateAsync(resourceGroupName, solutionName, parameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @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 container for solution on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SolutionInner> createOrUpdateAsync(
        String resourceGroupName, String solutionName, SolutionInner parameters, Context context) {
        return beginCreateOrUpdateAsync(resourceGroupName, solutionName, parameters, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 container for solution.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SolutionInner createOrUpdate(String resourceGroupName, String solutionName, SolutionInner parameters) {
        return createOrUpdateAsync(resourceGroupName, solutionName, parameters).block();
    }

    /**
     * Create/Update Solution.
     *
     * <p>Creates or updates the Solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to create OMS Solution.
     * @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 container for solution.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SolutionInner createOrUpdate(
        String resourceGroupName, String solutionName, SolutionInner parameters, Context context) {
        return createOrUpdateAsync(resourceGroupName, solutionName, parameters, context).block();
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 container for solution along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName, String solutionName, SolutionPatch parameters) {
        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 (solutionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter solutionName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            solutionName,
                            parameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @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 container for solution along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName, String solutionName, SolutionPatch parameters, 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 (solutionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter solutionName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                solutionName,
                parameters,
                accept,
                context);
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the container for solution.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SolutionInner>, SolutionInner> beginUpdateAsync(
        String resourceGroupName, String solutionName, SolutionPatch parameters) {
        Mono<Response<Flux<ByteBuffer>>> mono = updateWithResponseAsync(resourceGroupName, solutionName, parameters);
        return this
            .client
            .<SolutionInner, SolutionInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                SolutionInner.class,
                SolutionInner.class,
                this.client.getContext());
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the container for solution.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SolutionInner>, SolutionInner> beginUpdateAsync(
        String resourceGroupName, String solutionName, SolutionPatch parameters, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, solutionName, parameters, context);
        return this
            .client
            .<SolutionInner, SolutionInner>getLroResult(
                mono, this.client.getHttpPipeline(), SolutionInner.class, SolutionInner.class, context);
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the container for solution.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<SolutionInner>, SolutionInner> beginUpdate(
        String resourceGroupName, String solutionName, SolutionPatch parameters) {
        return this.beginUpdateAsync(resourceGroupName, solutionName, parameters).getSyncPoller();
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the container for solution.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<SolutionInner>, SolutionInner> beginUpdate(
        String resourceGroupName, String solutionName, SolutionPatch parameters, Context context) {
        return this.beginUpdateAsync(resourceGroupName, solutionName, parameters, context).getSyncPoller();
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 container for solution on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SolutionInner> updateAsync(String resourceGroupName, String solutionName, SolutionPatch parameters) {
        return beginUpdateAsync(resourceGroupName, solutionName, parameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @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 container for solution on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SolutionInner> updateAsync(
        String resourceGroupName, String solutionName, SolutionPatch parameters, Context context) {
        return beginUpdateAsync(resourceGroupName, solutionName, parameters, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 container for solution.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SolutionInner update(String resourceGroupName, String solutionName, SolutionPatch parameters) {
        return updateAsync(resourceGroupName, solutionName, parameters).block();
    }

    /**
     * Patch a Solution.
     *
     * <p>Patch a Solution. Only updating tags supported.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution Name.
     * @param parameters The parameters required to patch a Solution.
     * @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 container for solution.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SolutionInner update(
        String resourceGroupName, String solutionName, SolutionPatch parameters, Context context) {
        return updateAsync(resourceGroupName, solutionName, parameters, context).block();
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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<Flux<ByteBuffer>>> deleteWithResponseAsync(String resourceGroupName, String solutionName) {
        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 (solutionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter solutionName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            solutionName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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<Flux<ByteBuffer>>> deleteWithResponseAsync(
        String resourceGroupName, String solutionName, 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 (solutionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter solutionName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                solutionName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(String resourceGroupName, String solutionName) {
        Mono<Response<Flux<ByteBuffer>>> mono = deleteWithResponseAsync(resourceGroupName, solutionName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(
        String resourceGroupName, String solutionName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono = deleteWithResponseAsync(resourceGroupName, solutionName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(String resourceGroupName, String solutionName) {
        return this.beginDeleteAsync(resourceGroupName, solutionName).getSyncPoller();
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(
        String resourceGroupName, String solutionName, Context context) {
        return this.beginDeleteAsync(resourceGroupName, solutionName, context).getSyncPoller();
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 solutionName) {
        return beginDeleteAsync(resourceGroupName, solutionName).last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(String resourceGroupName, String solutionName, Context context) {
        return beginDeleteAsync(resourceGroupName, solutionName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 solutionName) {
        deleteAsync(resourceGroupName, solutionName).block();
    }

    /**
     * Deletes the solution
     *
     * <p>Deletes the solution in the subscription.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String resourceGroupName, String solutionName, Context context) {
        deleteAsync(resourceGroupName, solutionName, context).block();
    }

    /**
     * Retrieve solution.
     *
     * <p>Retrieves the user solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 container for solution along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SolutionInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String solutionName) {
        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 (solutionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter solutionName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getByResourceGroup(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            solutionName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Retrieve solution.
     *
     * <p>Retrieves the user solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 container for solution along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SolutionInner>> getByResourceGroupWithResponseAsync(
        String resourceGroupName, String solutionName, 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 (solutionName == null) {
            return Mono.error(new IllegalArgumentException("Parameter solutionName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getByResourceGroup(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                solutionName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Retrieve solution.
     *
     * <p>Retrieves the user solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 container for solution on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SolutionInner> getByResourceGroupAsync(String resourceGroupName, String solutionName) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, solutionName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Retrieve solution.
     *
     * <p>Retrieves the user solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 container for solution along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SolutionInner> getByResourceGroupWithResponse(
        String resourceGroupName, String solutionName, Context context) {
        return getByResourceGroupWithResponseAsync(resourceGroupName, solutionName, context).block();
    }

    /**
     * Retrieve solution.
     *
     * <p>Retrieves the user solution.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param solutionName User Solution 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 container for solution.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SolutionInner getByResourceGroup(String resourceGroupName, String solutionName) {
        return getByResourceGroupWithResponse(resourceGroupName, solutionName, Context.NONE).getValue();
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of solution response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SolutionPropertiesListInner>> listByResourceGroupWithResponseAsync(String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByResourceGroup(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of solution response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SolutionPropertiesListInner>> listByResourceGroupWithResponseAsync(
        String resourceGroupName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByResourceGroup(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of solution response on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SolutionPropertiesListInner> listByResourceGroupAsync(String resourceGroupName) {
        return listByResourceGroupWithResponseAsync(resourceGroupName).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of solution response along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SolutionPropertiesListInner> listByResourceGroupWithResponse(
        String resourceGroupName, Context context) {
        return listByResourceGroupWithResponseAsync(resourceGroupName, context).block();
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @param resourceGroupName The name of the resource group to get. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of solution response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SolutionPropertiesListInner listByResourceGroup(String resourceGroupName) {
        return listByResourceGroupWithResponse(resourceGroupName, Context.NONE).getValue();
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @throws 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 list of solution response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SolutionPropertiesListInner>> listBySubscriptionWithResponseAsync() {
        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
                        .listBySubscription(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @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 list of solution response along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SolutionPropertiesListInner>> listBySubscriptionWithResponseAsync(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
            .listBySubscription(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @throws 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 list of solution response on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SolutionPropertiesListInner> listBySubscriptionAsync() {
        return listBySubscriptionWithResponseAsync().flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @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 list of solution response along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SolutionPropertiesListInner> listBySubscriptionWithResponse(Context context) {
        return listBySubscriptionWithResponseAsync(context).block();
    }

    /**
     * Retrieves the solution list for the subscription
     *
     * <p>Retrieves the solution list. It will retrieve both first party and third party solutions.
     *
     * @throws 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 list of solution response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SolutionPropertiesListInner listBySubscription() {
        return listBySubscriptionWithResponse(Context.NONE).getValue();
    }
}
