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

package com.azure.resourcemanager.azurestack.implementation;

import com.azure.core.annotation.BodyParam;
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.PathParam;
import com.azure.core.annotation.Post;
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.azurestack.fluent.ProductsClient;
import com.azure.resourcemanager.azurestack.fluent.models.ExtendedProductInner;
import com.azure.resourcemanager.azurestack.fluent.models.ProductInner;
import com.azure.resourcemanager.azurestack.fluent.models.ProductListInner;
import com.azure.resourcemanager.azurestack.fluent.models.ProductLogInner;
import com.azure.resourcemanager.azurestack.models.DeviceConfiguration;
import com.azure.resourcemanager.azurestack.models.MarketplaceProductLogUpdate;
import reactor.core.publisher.Mono;

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

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

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

    /**
     * The interface defining all the services for AzureStackManagementClientProducts to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "AzureStackManagement")
    public interface ProductsService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack"
                + "/registrations/{registrationName}/products")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ProductListInner>> list(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroup") String resourceGroup,
            @PathParam("registrationName") String registrationName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack"
                + "/registrations/{registrationName}/products/{productName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ProductInner>> get(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroup") String resourceGroup,
            @PathParam("registrationName") String registrationName,
            @PathParam("productName") String productName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack"
                + "/registrations/{registrationName}/products/{productName}/listDetails")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ExtendedProductInner>> listDetails(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroup") String resourceGroup,
            @PathParam("registrationName") String registrationName,
            @PathParam("productName") String productName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack"
                + "/registrations/{registrationName}/products/{productName}/listProducts")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ProductListInner>> listProducts(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroup") String resourceGroup,
            @PathParam("registrationName") String registrationName,
            @PathParam("productName") String productName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") DeviceConfiguration deviceConfiguration,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack"
                + "/registrations/{registrationName}/products/{productName}/getProducts")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ProductListInner>> getProducts(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroup") String resourceGroup,
            @PathParam("registrationName") String registrationName,
            @PathParam("productName") String productName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") DeviceConfiguration deviceConfiguration,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack"
                + "/registrations/{registrationName}/products/{productName}/getProduct")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ProductInner>> getProduct(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroup") String resourceGroup,
            @PathParam("registrationName") String registrationName,
            @PathParam("productName") String productName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") DeviceConfiguration deviceConfiguration,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack"
                + "/registrations/{registrationName}/products/{productName}/uploadProductLog")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ProductLogInner>> uploadLog(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroup") String resourceGroup,
            @PathParam("registrationName") String registrationName,
            @PathParam("productName") String productName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") MarketplaceProductLogUpdate marketplaceProductLogUpdate,
            @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return pageable list of products along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProductInner>> listSinglePageAsync(String resourceGroup, String registrationName) {
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .list(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroup,
                            registrationName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .<PagedResponse<ProductInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @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 pageable list of products along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProductInner>> listSinglePageAsync(
        String resourceGroup, String registrationName, 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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroup,
                registrationName,
                this.client.getApiVersion(),
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return pageable list of products as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ProductInner> listAsync(String resourceGroup, String registrationName) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceGroup, registrationName), nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @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 pageable list of products as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ProductInner> listAsync(String resourceGroup, String registrationName, Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceGroup, registrationName, context),
            nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return pageable list of products as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ProductInner> list(String resourceGroup, String registrationName) {
        return new PagedIterable<>(listAsync(resourceGroup, registrationName));
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @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 pageable list of products as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ProductInner> list(String resourceGroup, String registrationName, Context context) {
        return new PagedIterable<>(listAsync(resourceGroup, registrationName, context));
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return product information along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductInner>> getWithResponseAsync(
        String resourceGroup, String registrationName, String productName) {
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroup,
                            registrationName,
                            productName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @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 product information along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductInner>> getWithResponseAsync(
        String resourceGroup, String registrationName, String productName, 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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .get(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroup,
                registrationName,
                productName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return product information on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProductInner> getAsync(String resourceGroup, String registrationName, String productName) {
        return getWithResponseAsync(resourceGroup, registrationName, productName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @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 product information along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ProductInner> getWithResponse(
        String resourceGroup, String registrationName, String productName, Context context) {
        return getWithResponseAsync(resourceGroup, registrationName, productName, context).block();
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return product information.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProductInner get(String resourceGroup, String registrationName, String productName) {
        return getWithResponse(resourceGroup, registrationName, productName, Context.NONE).getValue();
    }

    /**
     * Returns the extended properties of a product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return extended description about the product required for installing it into Azure Stack along with {@link
     *     Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExtendedProductInner>> listDetailsWithResponseAsync(
        String resourceGroup, String registrationName, String productName) {
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listDetails(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroup,
                            registrationName,
                            productName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns the extended properties of a product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @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 extended description about the product required for installing it into Azure Stack along with {@link
     *     Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ExtendedProductInner>> listDetailsWithResponseAsync(
        String resourceGroup, String registrationName, String productName, 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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listDetails(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroup,
                registrationName,
                productName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Returns the extended properties of a product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return extended description about the product required for installing it into Azure Stack on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ExtendedProductInner> listDetailsAsync(
        String resourceGroup, String registrationName, String productName) {
        return listDetailsWithResponseAsync(resourceGroup, registrationName, productName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Returns the extended properties of a product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @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 extended description about the product required for installing it into Azure Stack along with {@link
     *     Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ExtendedProductInner> listDetailsWithResponse(
        String resourceGroup, String registrationName, String productName, Context context) {
        return listDetailsWithResponseAsync(resourceGroup, registrationName, productName, context).block();
    }

    /**
     * Returns the extended properties of a product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return extended description about the product required for installing it into Azure Stack.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ExtendedProductInner listDetails(String resourceGroup, String registrationName, String productName) {
        return listDetailsWithResponse(resourceGroup, registrationName, productName, Context.NONE).getValue();
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param deviceConfiguration Device configuration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return pageable list of products along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductListInner>> listProductsWithResponseAsync(
        String resourceGroup, String registrationName, String productName, DeviceConfiguration deviceConfiguration) {
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        if (deviceConfiguration != null) {
            deviceConfiguration.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listProducts(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroup,
                            registrationName,
                            productName,
                            this.client.getApiVersion(),
                            deviceConfiguration,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param deviceConfiguration Device configuration.
     * @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 pageable list of products along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductListInner>> listProductsWithResponseAsync(
        String resourceGroup,
        String registrationName,
        String productName,
        DeviceConfiguration deviceConfiguration,
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        if (deviceConfiguration != null) {
            deviceConfiguration.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listProducts(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroup,
                registrationName,
                productName,
                this.client.getApiVersion(),
                deviceConfiguration,
                accept,
                context);
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return pageable list of products on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProductListInner> listProductsAsync(
        String resourceGroup, String registrationName, String productName) {
        final DeviceConfiguration deviceConfiguration = null;
        return listProductsWithResponseAsync(resourceGroup, registrationName, productName, deviceConfiguration)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param deviceConfiguration Device configuration.
     * @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 pageable list of products along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ProductListInner> listProductsWithResponse(
        String resourceGroup,
        String registrationName,
        String productName,
        DeviceConfiguration deviceConfiguration,
        Context context) {
        return listProductsWithResponseAsync(resourceGroup, registrationName, productName, deviceConfiguration, context)
            .block();
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return pageable list of products.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProductListInner listProducts(String resourceGroup, String registrationName, String productName) {
        final DeviceConfiguration deviceConfiguration = null;
        return listProductsWithResponse(resourceGroup, registrationName, productName, deviceConfiguration, Context.NONE)
            .getValue();
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param deviceConfiguration Device configuration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return pageable list of products along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductListInner>> getProductsWithResponseAsync(
        String resourceGroup, String registrationName, String productName, DeviceConfiguration deviceConfiguration) {
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        if (deviceConfiguration != null) {
            deviceConfiguration.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getProducts(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroup,
                            registrationName,
                            productName,
                            this.client.getApiVersion(),
                            deviceConfiguration,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param deviceConfiguration Device configuration.
     * @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 pageable list of products along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductListInner>> getProductsWithResponseAsync(
        String resourceGroup,
        String registrationName,
        String productName,
        DeviceConfiguration deviceConfiguration,
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        if (deviceConfiguration != null) {
            deviceConfiguration.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getProducts(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroup,
                registrationName,
                productName,
                this.client.getApiVersion(),
                deviceConfiguration,
                accept,
                context);
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return pageable list of products on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProductListInner> getProductsAsync(String resourceGroup, String registrationName, String productName) {
        final DeviceConfiguration deviceConfiguration = null;
        return getProductsWithResponseAsync(resourceGroup, registrationName, productName, deviceConfiguration)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param deviceConfiguration Device configuration.
     * @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 pageable list of products along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ProductListInner> getProductsWithResponse(
        String resourceGroup,
        String registrationName,
        String productName,
        DeviceConfiguration deviceConfiguration,
        Context context) {
        return getProductsWithResponseAsync(resourceGroup, registrationName, productName, deviceConfiguration, context)
            .block();
    }

    /**
     * Returns a list of products.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return pageable list of products.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProductListInner getProducts(String resourceGroup, String registrationName, String productName) {
        final DeviceConfiguration deviceConfiguration = null;
        return getProductsWithResponse(resourceGroup, registrationName, productName, deviceConfiguration, Context.NONE)
            .getValue();
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param deviceConfiguration Device configuration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return product information along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductInner>> getProductWithResponseAsync(
        String resourceGroup, String registrationName, String productName, DeviceConfiguration deviceConfiguration) {
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        if (deviceConfiguration != null) {
            deviceConfiguration.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getProduct(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroup,
                            registrationName,
                            productName,
                            this.client.getApiVersion(),
                            deviceConfiguration,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param deviceConfiguration Device configuration.
     * @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 product information along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductInner>> getProductWithResponseAsync(
        String resourceGroup,
        String registrationName,
        String productName,
        DeviceConfiguration deviceConfiguration,
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        if (deviceConfiguration != null) {
            deviceConfiguration.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getProduct(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroup,
                registrationName,
                productName,
                this.client.getApiVersion(),
                deviceConfiguration,
                accept,
                context);
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return product information on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProductInner> getProductAsync(String resourceGroup, String registrationName, String productName) {
        final DeviceConfiguration deviceConfiguration = null;
        return getProductWithResponseAsync(resourceGroup, registrationName, productName, deviceConfiguration)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param deviceConfiguration Device configuration.
     * @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 product information along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ProductInner> getProductWithResponse(
        String resourceGroup,
        String registrationName,
        String productName,
        DeviceConfiguration deviceConfiguration,
        Context context) {
        return getProductWithResponseAsync(resourceGroup, registrationName, productName, deviceConfiguration, context)
            .block();
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return product information.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProductInner getProduct(String resourceGroup, String registrationName, String productName) {
        final DeviceConfiguration deviceConfiguration = null;
        return getProductWithResponse(resourceGroup, registrationName, productName, deviceConfiguration, Context.NONE)
            .getValue();
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param marketplaceProductLogUpdate Update details for product log.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return product action log along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductLogInner>> uploadLogWithResponseAsync(
        String resourceGroup,
        String registrationName,
        String productName,
        MarketplaceProductLogUpdate marketplaceProductLogUpdate) {
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        if (marketplaceProductLogUpdate != null) {
            marketplaceProductLogUpdate.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .uploadLog(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroup,
                            registrationName,
                            productName,
                            this.client.getApiVersion(),
                            marketplaceProductLogUpdate,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param marketplaceProductLogUpdate Update details for product log.
     * @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 product action log along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ProductLogInner>> uploadLogWithResponseAsync(
        String resourceGroup,
        String registrationName,
        String productName,
        MarketplaceProductLogUpdate marketplaceProductLogUpdate,
        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 (resourceGroup == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceGroup is required and cannot be null."));
        }
        if (registrationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter registrationName is required and cannot be null."));
        }
        if (productName == null) {
            return Mono.error(new IllegalArgumentException("Parameter productName is required and cannot be null."));
        }
        if (marketplaceProductLogUpdate != null) {
            marketplaceProductLogUpdate.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .uploadLog(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroup,
                registrationName,
                productName,
                this.client.getApiVersion(),
                marketplaceProductLogUpdate,
                accept,
                context);
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return product action log on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ProductLogInner> uploadLogAsync(String resourceGroup, String registrationName, String productName) {
        final MarketplaceProductLogUpdate marketplaceProductLogUpdate = null;
        return uploadLogWithResponseAsync(resourceGroup, registrationName, productName, marketplaceProductLogUpdate)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @param marketplaceProductLogUpdate Update details for product log.
     * @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 product action log along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ProductLogInner> uploadLogWithResponse(
        String resourceGroup,
        String registrationName,
        String productName,
        MarketplaceProductLogUpdate marketplaceProductLogUpdate,
        Context context) {
        return uploadLogWithResponseAsync(
                resourceGroup, registrationName, productName, marketplaceProductLogUpdate, context)
            .block();
    }

    /**
     * Returns the specified product.
     *
     * @param resourceGroup Name of the resource group.
     * @param registrationName Name of the Azure Stack registration.
     * @param productName Name of the product.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return product action log.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ProductLogInner uploadLog(String resourceGroup, String registrationName, String productName) {
        final MarketplaceProductLogUpdate marketplaceProductLogUpdate = null;
        return uploadLogWithResponse(
                resourceGroup, registrationName, productName, marketplaceProductLogUpdate, 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 pageable list of products along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProductInner>> 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<ProductInner>>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 pageable list of products along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ProductInner>> 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));
    }
}
