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

package tsptest.armlegacy.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.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.util.Context;
import com.azure.core.util.FluxUtil;
import reactor.core.publisher.Mono;
import tsptest.armlegacy.fluent.SkusClient;
import tsptest.armlegacy.fluent.models.SkuResourceInner;

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

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

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

    /**
     * The interface defining all the services for ArmLegacyClientSkus to be used by the proxy service to perform REST
     * calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "ArmLegacyClientSkus")
    public interface SkusService {
        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SkuResourceInner>> getNested(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<SkuResourceInner> getNestedSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku,
            @HeaderParam("Accept") String accept, Context context);

        @Put("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SkuResourceInner>> createNested(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku,
            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
            @BodyParam("application/json") SkuResourceInner resource, Context context);

        @Put("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<SkuResourceInner> createNestedSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku,
            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
            @BodyParam("application/json") SkuResourceInner resource, Context context);

        @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}")
        @ExpectedResponses({ 200, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Void>> deleteNested(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku,
            Context context);

        @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}")
        @ExpectedResponses({ 200, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<Void> deleteNestedSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SkuResourceInner>> getRoot(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("sku") String sku, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<SkuResourceInner> getRootSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("sku") String sku, @HeaderParam("Accept") String accept, Context context);

        @Put("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SkuResourceInner>> createRoot(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("sku") String sku, @HeaderParam("Content-Type") String contentType,
            @HeaderParam("Accept") String accept, @BodyParam("application/json") SkuResourceInner resource,
            Context context);

        @Put("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<SkuResourceInner> createRootSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("sku") String sku, @HeaderParam("Content-Type") String contentType,
            @HeaderParam("Accept") String accept, @BodyParam("application/json") SkuResourceInner resource,
            Context context);

        @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}")
        @ExpectedResponses({ 200, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Void>> deleteRoot(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("sku") String sku, Context context);

        @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/providers/TspTest.ArmLegacy/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}")
        @ExpectedResponses({ 200, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<Void> deleteRootSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType,
            @PathParam("sku") String sku, Context context);
    }

    /**
     * Get a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @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 SkuResource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SkuResourceInner>> getNestedWithResponseAsync(String providerNamespace, String resourceType,
        String nestedResourceTypeFirst, String sku) {
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getNested(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, accept,
                context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @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 SkuResource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SkuResourceInner> getNestedAsync(String providerNamespace, String resourceType,
        String nestedResourceTypeFirst, String sku) {
        return getNestedWithResponseAsync(providerNamespace, resourceType, nestedResourceTypeFirst, sku)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @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 SkuResource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SkuResourceInner> getNestedWithResponse(String providerNamespace, String resourceType,
        String nestedResourceTypeFirst, String sku, Context context) {
        final String accept = "application/json";
        return service.getNestedSync(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, accept,
            context);
    }

    /**
     * Get a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @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 SkuResource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SkuResourceInner getNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst,
        String sku) {
        return getNestedWithResponse(providerNamespace, resourceType, nestedResourceTypeFirst, sku, Context.NONE)
            .getValue();
    }

    /**
     * Create a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @param resource Resource create parameters.
     * @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 concrete proxy resource types can be created by aliasing this type using a specific property type along
     * with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SkuResourceInner>> createNestedWithResponseAsync(String providerNamespace,
        String resourceType, String nestedResourceTypeFirst, String sku, SkuResourceInner resource) {
        final String contentType = "application/json";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.createNested(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku,
                contentType, accept, resource, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @param resource Resource create parameters.
     * @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 concrete proxy resource types can be created by aliasing this type using a specific property type on
     * successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SkuResourceInner> createNestedAsync(String providerNamespace, String resourceType,
        String nestedResourceTypeFirst, String sku, SkuResourceInner resource) {
        return createNestedWithResponseAsync(providerNamespace, resourceType, nestedResourceTypeFirst, sku, resource)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Create a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @param resource Resource create parameters.
     * @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 concrete proxy resource types can be created by aliasing this type using a specific property type along
     * with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SkuResourceInner> createNestedWithResponse(String providerNamespace, String resourceType,
        String nestedResourceTypeFirst, String sku, SkuResourceInner resource, Context context) {
        final String contentType = "application/json";
        final String accept = "application/json";
        return service.createNestedSync(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, contentType,
            accept, resource, context);
    }

    /**
     * Create a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @param resource Resource create parameters.
     * @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 concrete proxy resource types can be created by aliasing this type using a specific property type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SkuResourceInner createNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst,
        String sku, SkuResourceInner resource) {
        return createNestedWithResponse(providerNamespace, resourceType, nestedResourceTypeFirst, sku, resource,
            Context.NONE).getValue();
    }

    /**
     * Delete a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteNestedWithResponseAsync(String providerNamespace, String resourceType,
        String nestedResourceTypeFirst, String sku) {
        return FluxUtil
            .withContext(context -> service.deleteNested(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku,
                context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @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> deleteNestedAsync(String providerNamespace, String resourceType, String nestedResourceTypeFirst,
        String sku) {
        return deleteNestedWithResponseAsync(providerNamespace, resourceType, nestedResourceTypeFirst, sku)
            .flatMap(ignored -> Mono.empty());
    }

    /**
     * Delete a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteNestedWithResponse(String providerNamespace, String resourceType,
        String nestedResourceTypeFirst, String sku, Context context) {
        return service.deleteNestedSync(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, context);
    }

    /**
     * Delete a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param nestedResourceTypeFirst The first child resource type.
     * @param sku The SKU.
     * @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 deleteNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst,
        String sku) {
        deleteNestedWithResponse(providerNamespace, resourceType, nestedResourceTypeFirst, sku, Context.NONE);
    }

    /**
     * Get a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @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 SkuResource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SkuResourceInner>> getRootWithResponseAsync(String providerNamespace, String resourceType,
        String sku) {
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getRoot(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), providerNamespace, resourceType, sku, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @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 SkuResource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SkuResourceInner> getRootAsync(String providerNamespace, String resourceType, String sku) {
        return getRootWithResponseAsync(providerNamespace, resourceType, sku)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @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 SkuResource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SkuResourceInner> getRootWithResponse(String providerNamespace, String resourceType, String sku,
        Context context) {
        final String accept = "application/json";
        return service.getRootSync(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), providerNamespace, resourceType, sku, accept, context);
    }

    /**
     * Get a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @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 SkuResource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SkuResourceInner getRoot(String providerNamespace, String resourceType, String sku) {
        return getRootWithResponse(providerNamespace, resourceType, sku, Context.NONE).getValue();
    }

    /**
     * Create a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @param resource Resource create parameters.
     * @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 concrete proxy resource types can be created by aliasing this type using a specific property type along
     * with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SkuResourceInner>> createRootWithResponseAsync(String providerNamespace, String resourceType,
        String sku, SkuResourceInner resource) {
        final String contentType = "application/json";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.createRoot(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), providerNamespace, resourceType, sku, contentType, accept, resource,
                context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @param resource Resource create parameters.
     * @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 concrete proxy resource types can be created by aliasing this type using a specific property type on
     * successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SkuResourceInner> createRootAsync(String providerNamespace, String resourceType, String sku,
        SkuResourceInner resource) {
        return createRootWithResponseAsync(providerNamespace, resourceType, sku, resource)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Create a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @param resource Resource create parameters.
     * @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 concrete proxy resource types can be created by aliasing this type using a specific property type along
     * with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SkuResourceInner> createRootWithResponse(String providerNamespace, String resourceType, String sku,
        SkuResourceInner resource, Context context) {
        final String contentType = "application/json";
        final String accept = "application/json";
        return service.createRootSync(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), providerNamespace, resourceType, sku, contentType, accept, resource,
            context);
    }

    /**
     * Create a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @param resource Resource create parameters.
     * @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 concrete proxy resource types can be created by aliasing this type using a specific property type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SkuResourceInner createRoot(String providerNamespace, String resourceType, String sku,
        SkuResourceInner resource) {
        return createRootWithResponse(providerNamespace, resourceType, sku, resource, Context.NONE).getValue();
    }

    /**
     * Delete a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteRootWithResponseAsync(String providerNamespace, String resourceType,
        String sku) {
        return FluxUtil
            .withContext(context -> service.deleteRoot(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), providerNamespace, resourceType, sku, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @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> deleteRootAsync(String providerNamespace, String resourceType, String sku) {
        return deleteRootWithResponseAsync(providerNamespace, resourceType, sku).flatMap(ignored -> Mono.empty());
    }

    /**
     * Delete a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteRootWithResponse(String providerNamespace, String resourceType, String sku,
        Context context) {
        return service.deleteRootSync(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), providerNamespace, resourceType, sku, context);
    }

    /**
     * Delete a SkuResource.
     * 
     * @param providerNamespace The name of the resource provider hosted within ProviderHub.
     * @param resourceType The resource type.
     * @param sku The SKU.
     * @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 deleteRoot(String providerNamespace, String resourceType, String sku) {
        deleteRootWithResponse(providerNamespace, resourceType, sku, Context.NONE);
    }
}
