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

package tsptest.armresourceprovider.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import tsptest.armresourceprovider.fluent.ChildExtensionResourceInterfacesClient;
import tsptest.armresourceprovider.fluent.models.ChildExtensionResourceInner;
import tsptest.armresourceprovider.implementation.models.ChildExtensionResourceListResult;
import tsptest.armresourceprovider.models.ChildExtensionResourceUpdate;

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

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

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

    /**
     * The interface defining all the services for ArmResourceProviderClientChildExtensionResourceInterfaces to be used
     * by the proxy service to perform REST calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "ArmResourceProviderC")
    public interface ChildExtensionResourceInterfacesService {
        @Headers({ "Content-Type: application/json" })
        @Get("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ChildExtensionResourceInner>> get(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName,
            @PathParam("childExtensionResourceName") String childExtensionResourceName,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<ChildExtensionResourceInner> getSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName,
            @PathParam("childExtensionResourceName") String childExtensionResourceName,
            @HeaderParam("Accept") String accept, Context context);

        @Put("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> createOrUpdate(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName,
            @PathParam("childExtensionResourceName") String childExtensionResourceName,
            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
            @BodyParam("application/json") ChildExtensionResourceInner resource, Context context);

        @Put("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<BinaryData> createOrUpdateSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName,
            @PathParam("childExtensionResourceName") String childExtensionResourceName,
            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
            @BodyParam("application/json") ChildExtensionResourceInner resource, Context context);

        @Patch("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ChildExtensionResourceInner>> update(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName,
            @PathParam("childExtensionResourceName") String childExtensionResourceName,
            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
            @BodyParam("application/json") ChildExtensionResourceUpdate properties, Context context);

        @Patch("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<ChildExtensionResourceInner> updateSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName,
            @PathParam("childExtensionResourceName") String childExtensionResourceName,
            @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept,
            @BodyParam("application/json") ChildExtensionResourceUpdate properties, Context context);

        @Headers({ "Content-Type: application/json" })
        @Delete("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}")
        @ExpectedResponses({ 200, 202, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> delete(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName,
            @PathParam("childExtensionResourceName") String childExtensionResourceName,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Delete("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}")
        @ExpectedResponses({ 200, 202, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<BinaryData> deleteSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName,
            @PathParam("childExtensionResourceName") String childExtensionResourceName,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ChildExtensionResourceListResult>> listByTopLevelArmResource(
            @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/{resourceUri}/providers/TspTest.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Response<ChildExtensionResourceListResult> listByTopLevelArmResourceSync(@HostParam("endpoint") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam(value = "resourceUri", encoded = true) String resourceUri,
            @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept,
            Context context);

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

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

    /**
     * Get a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 ChildExtensionResource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ChildExtensionResourceInner>> getWithResponseAsync(String resourceUri,
        String topLevelArmResourceName, String childExtensionResourceName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
                topLevelArmResourceName, childExtensionResourceName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 ChildExtensionResource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ChildExtensionResourceInner> getAsync(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName) {
        return getWithResponseAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 ChildExtensionResource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ChildExtensionResourceInner> getWithResponse(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, Context context) {
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter childExtensionResourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return service.getSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
            topLevelArmResourceName, childExtensionResourceName, accept, context);
    }

    /**
     * Get a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 ChildExtensionResource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ChildExtensionResourceInner get(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName) {
        return getWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, Context.NONE)
            .getValue();
    }

    /**
     * Create a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 extensionResource of Top Level Arm Resource along with {@link Response} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(String resourceUri,
        String topLevelArmResourceName, String childExtensionResourceName, ChildExtensionResourceInner resource) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null."));
        }
        if (resource == null) {
            return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String contentType = "application/json";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
                    topLevelArmResourceName, childExtensionResourceName, contentType, accept, resource, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 extensionResource of Top Level Arm Resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Response<BinaryData> createOrUpdateWithResponse(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, ChildExtensionResourceInner resource) {
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter childExtensionResourceName is required and cannot be null."));
        }
        if (resource == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String contentType = "application/json";
        final String accept = "application/json";
        return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
            topLevelArmResourceName, childExtensionResourceName, contentType, accept, resource, Context.NONE);
    }

    /**
     * Create a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 extensionResource of Top Level Arm Resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Response<BinaryData> createOrUpdateWithResponse(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, ChildExtensionResourceInner resource, Context context) {
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter childExtensionResourceName is required and cannot be null."));
        }
        if (resource == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String contentType = "application/json";
        final String accept = "application/json";
        return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
            topLevelArmResourceName, childExtensionResourceName, contentType, accept, resource, context);
    }

    /**
     * Create a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 the {@link PollerFlux} for polling of extensionResource of Top Level Arm Resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ChildExtensionResourceInner>, ChildExtensionResourceInner> beginCreateOrUpdateAsync(
        String resourceUri, String topLevelArmResourceName, String childExtensionResourceName,
        ChildExtensionResourceInner resource) {
        Mono<Response<Flux<ByteBuffer>>> mono = createOrUpdateWithResponseAsync(resourceUri, topLevelArmResourceName,
            childExtensionResourceName, resource);
        return this.client.<ChildExtensionResourceInner, ChildExtensionResourceInner>getLroResult(mono,
            this.client.getHttpPipeline(), ChildExtensionResourceInner.class, ChildExtensionResourceInner.class,
            this.client.getContext());
    }

    /**
     * Create a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 the {@link SyncPoller} for polling of extensionResource of Top Level Arm Resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ChildExtensionResourceInner>, ChildExtensionResourceInner> beginCreateOrUpdate(
        String resourceUri, String topLevelArmResourceName, String childExtensionResourceName,
        ChildExtensionResourceInner resource) {
        Response<BinaryData> response
            = createOrUpdateWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource);
        return this.client.<ChildExtensionResourceInner, ChildExtensionResourceInner>getLroResult(response,
            ChildExtensionResourceInner.class, ChildExtensionResourceInner.class, Context.NONE);
    }

    /**
     * Create a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 the {@link SyncPoller} for polling of extensionResource of Top Level Arm Resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ChildExtensionResourceInner>, ChildExtensionResourceInner> beginCreateOrUpdate(
        String resourceUri, String topLevelArmResourceName, String childExtensionResourceName,
        ChildExtensionResourceInner resource, Context context) {
        Response<BinaryData> response = createOrUpdateWithResponse(resourceUri, topLevelArmResourceName,
            childExtensionResourceName, resource, context);
        return this.client.<ChildExtensionResourceInner, ChildExtensionResourceInner>getLroResult(response,
            ChildExtensionResourceInner.class, ChildExtensionResourceInner.class, context);
    }

    /**
     * Create a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 extensionResource of Top Level Arm Resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ChildExtensionResourceInner> createOrUpdateAsync(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, ChildExtensionResourceInner resource) {
        return beginCreateOrUpdateAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 extensionResource of Top Level Arm Resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ChildExtensionResourceInner createOrUpdate(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, ChildExtensionResourceInner resource) {
        return beginCreateOrUpdate(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource)
            .getFinalResult();
    }

    /**
     * Create a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 extensionResource of Top Level Arm Resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ChildExtensionResourceInner createOrUpdate(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, ChildExtensionResourceInner resource, Context context) {
        return beginCreateOrUpdate(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource, context)
            .getFinalResult();
    }

    /**
     * Update a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @param properties The resource properties to be updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return extensionResource of Top Level Arm Resource along with {@link Response} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ChildExtensionResourceInner>> updateWithResponseAsync(String resourceUri,
        String topLevelArmResourceName, String childExtensionResourceName, ChildExtensionResourceUpdate properties) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null."));
        }
        if (properties == null) {
            return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null."));
        } else {
            properties.validate();
        }
        final String contentType = "application/json";
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
                topLevelArmResourceName, childExtensionResourceName, contentType, accept, properties, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @param properties The resource properties to be updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return extensionResource of Top Level Arm Resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ChildExtensionResourceInner> updateAsync(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, ChildExtensionResourceUpdate properties) {
        return updateWithResponseAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, properties)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Update a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @param properties The resource properties to be updated.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return extensionResource of Top Level Arm Resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ChildExtensionResourceInner> updateWithResponse(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, ChildExtensionResourceUpdate properties, Context context) {
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter childExtensionResourceName is required and cannot be null."));
        }
        if (properties == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter properties is required and cannot be null."));
        } else {
            properties.validate();
        }
        final String contentType = "application/json";
        final String accept = "application/json";
        return service.updateSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
            topLevelArmResourceName, childExtensionResourceName, contentType, accept, properties, context);
    }

    /**
     * Update a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @param properties The resource properties to be updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return extensionResource of Top Level Arm Resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ChildExtensionResourceInner update(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, ChildExtensionResourceUpdate properties) {
        return updateWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, properties,
            Context.NONE).getValue();
    }

    /**
     * Delete a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
                topLevelArmResourceName, childExtensionResourceName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Delete a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 response body along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Response<BinaryData> deleteWithResponse(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName) {
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter childExtensionResourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
            topLevelArmResourceName, childExtensionResourceName, accept, Context.NONE);
    }

    /**
     * Delete a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @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 response body along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Response<BinaryData> deleteWithResponse(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, Context context) {
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        if (childExtensionResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter childExtensionResourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
            topLevelArmResourceName, childExtensionResourceName, accept, context);
    }

    /**
     * Delete a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName) {
        Mono<Response<Flux<ByteBuffer>>> mono
            = deleteWithResponseAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName);
        return this.client.<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            this.client.getContext());
    }

    /**
     * Delete a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName) {
        Response<BinaryData> response
            = deleteWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName);
        return this.client.<Void, Void>getLroResult(response, Void.class, Void.class, Context.NONE);
    }

    /**
     * Delete a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName, Context context) {
        Response<BinaryData> response
            = deleteWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, context);
        return this.client.<Void, Void>getLroResult(response, Void.class, Void.class, context);
    }

    /**
     * Delete a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(String resourceUri, String topLevelArmResourceName,
        String childExtensionResourceName) {
        return beginDeleteAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String resourceUri, String topLevelArmResourceName, String childExtensionResourceName) {
        beginDelete(resourceUri, topLevelArmResourceName, childExtensionResourceName).getFinalResult();
    }

    /**
     * Delete a ChildExtensionResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @param childExtensionResourceName ChildExtensionResources.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String resourceUri, String topLevelArmResourceName, String childExtensionResourceName,
        Context context) {
        beginDelete(resourceUri, topLevelArmResourceName, childExtensionResourceName, context).getFinalResult();
    }

    /**
     * List ChildExtensionResource resources by TopLevelArmResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @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 response of a ChildExtensionResource list operation along with {@link PagedResponse} on successful
     * completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ChildExtensionResourceInner>>
        listByTopLevelArmResourceSinglePageAsync(String resourceUri, String topLevelArmResourceName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listByTopLevelArmResource(this.client.getEndpoint(),
                this.client.getApiVersion(), resourceUri, topLevelArmResourceName, accept, context))
            .<PagedResponse<ChildExtensionResourceInner>>map(res -> new PagedResponseBase<>(res.getRequest(),
                res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * List ChildExtensionResource resources by TopLevelArmResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @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 response of a ChildExtensionResource list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ChildExtensionResourceInner> listByTopLevelArmResourceAsync(String resourceUri,
        String topLevelArmResourceName) {
        return new PagedFlux<>(() -> listByTopLevelArmResourceSinglePageAsync(resourceUri, topLevelArmResourceName),
            nextLink -> listByTopLevelArmResourceNextSinglePageAsync(nextLink));
    }

    /**
     * List ChildExtensionResource resources by TopLevelArmResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @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 response of a ChildExtensionResource list operation along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<ChildExtensionResourceInner> listByTopLevelArmResourceSinglePage(String resourceUri,
        String topLevelArmResourceName) {
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        Response<ChildExtensionResourceListResult> res
            = service.listByTopLevelArmResourceSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
                topLevelArmResourceName, accept, Context.NONE);
        return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(),
            res.getValue().nextLink(), null);
    }

    /**
     * List ChildExtensionResource resources by TopLevelArmResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @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 response of a ChildExtensionResource list operation along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<ChildExtensionResourceInner> listByTopLevelArmResourceSinglePage(String resourceUri,
        String topLevelArmResourceName, Context context) {
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceUri == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter resourceUri is required and cannot be null."));
        }
        if (topLevelArmResourceName == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null."));
        }
        final String accept = "application/json";
        Response<ChildExtensionResourceListResult> res
            = service.listByTopLevelArmResourceSync(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri,
                topLevelArmResourceName, accept, context);
        return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(),
            res.getValue().nextLink(), null);
    }

    /**
     * List ChildExtensionResource resources by TopLevelArmResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @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 response of a ChildExtensionResource list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ChildExtensionResourceInner> listByTopLevelArmResource(String resourceUri,
        String topLevelArmResourceName) {
        return new PagedIterable<>(() -> listByTopLevelArmResourceSinglePage(resourceUri, topLevelArmResourceName),
            nextLink -> listByTopLevelArmResourceNextSinglePage(nextLink));
    }

    /**
     * List ChildExtensionResource resources by TopLevelArmResource.
     * 
     * @param resourceUri The fully qualified Azure Resource manager identifier of the resource.
     * @param topLevelArmResourceName arm resource name for path.
     * @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 response of a ChildExtensionResource list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ChildExtensionResourceInner> listByTopLevelArmResource(String resourceUri,
        String topLevelArmResourceName, Context context) {
        return new PagedIterable<>(
            () -> listByTopLevelArmResourceSinglePage(resourceUri, topLevelArmResourceName, context),
            nextLink -> listByTopLevelArmResourceNextSinglePage(nextLink, context));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @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 response of a ChildExtensionResource list operation along with {@link PagedResponse} on successful
     * completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ChildExtensionResourceInner>>
        listByTopLevelArmResourceNextSinglePageAsync(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.listByTopLevelArmResourceNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<ChildExtensionResourceInner>>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.
     * @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 response of a ChildExtensionResource list operation along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<ChildExtensionResourceInner> listByTopLevelArmResourceNextSinglePage(String nextLink) {
        if (nextLink == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        Response<ChildExtensionResourceListResult> res
            = service.listByTopLevelArmResourceNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE);
        return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(),
            res.getValue().nextLink(), null);
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @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 response of a ChildExtensionResource list operation along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<ChildExtensionResourceInner> listByTopLevelArmResourceNextSinglePage(String nextLink,
        Context context) {
        if (nextLink == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        Response<ChildExtensionResourceListResult> res
            = service.listByTopLevelArmResourceNextSync(nextLink, this.client.getEndpoint(), accept, context);
        return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(),
            res.getValue().nextLink(), null);
    }

    private static final ClientLogger LOGGER = new ClientLogger(ChildExtensionResourceInterfacesClientImpl.class);
}
