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

package com.azure.resourcemanager.mobilenetwork.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.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.mobilenetwork.fluent.AttachedDataNetworksClient;
import com.azure.resourcemanager.mobilenetwork.fluent.models.AttachedDataNetworkInner;
import com.azure.resourcemanager.mobilenetwork.models.AttachedDataNetworkListResult;
import com.azure.resourcemanager.mobilenetwork.models.TagsObject;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

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

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

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

    /**
     * The interface defining all the services for MobileNetworkManagementClientAttachedDataNetworks to be used by the
     * proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "MobileNetworkManagem")
    public interface AttachedDataNetworksService {
        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork"
                + "/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"
                + "/attachedDataNetworks/{attachedDataNetworkName}")
        @ExpectedResponses({200, 202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> delete(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("packetCoreControlPlaneName") String packetCoreControlPlaneName,
            @PathParam("packetCoreDataPlaneName") String packetCoreDataPlaneName,
            @PathParam("attachedDataNetworkName") String attachedDataNetworkName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork"
                + "/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"
                + "/attachedDataNetworks/{attachedDataNetworkName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AttachedDataNetworkInner>> get(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("packetCoreControlPlaneName") String packetCoreControlPlaneName,
            @PathParam("packetCoreDataPlaneName") String packetCoreDataPlaneName,
            @PathParam("attachedDataNetworkName") String attachedDataNetworkName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork"
                + "/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"
                + "/attachedDataNetworks/{attachedDataNetworkName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("packetCoreControlPlaneName") String packetCoreControlPlaneName,
            @PathParam("packetCoreDataPlaneName") String packetCoreDataPlaneName,
            @PathParam("attachedDataNetworkName") String attachedDataNetworkName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") AttachedDataNetworkInner parameters,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork"
                + "/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"
                + "/attachedDataNetworks/{attachedDataNetworkName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AttachedDataNetworkInner>> updateTags(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("packetCoreControlPlaneName") String packetCoreControlPlaneName,
            @PathParam("packetCoreDataPlaneName") String packetCoreDataPlaneName,
            @PathParam("attachedDataNetworkName") String attachedDataNetworkName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") TagsObject parameters,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork"
                + "/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}"
                + "/attachedDataNetworks")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AttachedDataNetworkListResult>> listByPacketCoreDataPlane(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("packetCoreControlPlaneName") String packetCoreControlPlaneName,
            @PathParam("packetCoreDataPlaneName") String packetCoreDataPlaneName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        if (attachedDataNetworkName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter attachedDataNetworkName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            packetCoreControlPlaneName,
                            packetCoreDataPlaneName,
                            attachedDataNetworkName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        if (attachedDataNetworkName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter attachedDataNetworkName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(
                resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName) {
        return this
            .beginDeleteAsync(
                resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName)
            .getSyncPoller();
    }

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        Context context) {
        return this
            .beginDeleteAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                context)
            .getSyncPoller();
    }

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName) {
        return beginDeleteAsync(
                resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        Context context) {
        return beginDeleteAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName) {
        deleteAsync(resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName)
            .block();
    }

    /**
     * Deletes the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        Context context) {
        deleteAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                context)
            .block();
    }

    /**
     * Gets information about the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @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 information about the specified attached data network along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AttachedDataNetworkInner>> getWithResponseAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        if (attachedDataNetworkName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter attachedDataNetworkName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            packetCoreControlPlaneName,
                            packetCoreDataPlaneName,
                            attachedDataNetworkName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets information about the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @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 information about the specified attached data network along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AttachedDataNetworkInner>> getWithResponseAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        if (attachedDataNetworkName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter attachedDataNetworkName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .get(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Gets information about the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @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 information about the specified attached data network on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AttachedDataNetworkInner> getAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName) {
        return getWithResponseAsync(
                resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, attachedDataNetworkName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets information about the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @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 information about the specified attached data network along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AttachedDataNetworkInner> getWithResponse(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        Context context) {
        return getWithResponseAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                context)
            .block();
    }

    /**
     * Gets information about the specified attached data network.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @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 information about the specified attached data network.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AttachedDataNetworkInner get(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName) {
        return getWithResponse(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                Context.NONE)
            .getValue();
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network 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 attached data network resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        if (attachedDataNetworkName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter attachedDataNetworkName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            packetCoreControlPlaneName,
                            packetCoreDataPlaneName,
                            attachedDataNetworkName,
                            this.client.getApiVersion(),
                            parameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network operation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return attached data network resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        if (attachedDataNetworkName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter attachedDataNetworkName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                this.client.getApiVersion(),
                parameters,
                accept,
                context);
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of attached data network resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<AttachedDataNetworkInner>, AttachedDataNetworkInner> beginCreateOrUpdateAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters);
        return this
            .client
            .<AttachedDataNetworkInner, AttachedDataNetworkInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                AttachedDataNetworkInner.class,
                AttachedDataNetworkInner.class,
                this.client.getContext());
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network operation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of attached data network resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<AttachedDataNetworkInner>, AttachedDataNetworkInner> beginCreateOrUpdateAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters,
                context);
        return this
            .client
            .<AttachedDataNetworkInner, AttachedDataNetworkInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                AttachedDataNetworkInner.class,
                AttachedDataNetworkInner.class,
                context);
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network 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 attached data network resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<AttachedDataNetworkInner>, AttachedDataNetworkInner> beginCreateOrUpdate(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters) {
        return this
            .beginCreateOrUpdateAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters)
            .getSyncPoller();
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network operation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of attached data network resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<AttachedDataNetworkInner>, AttachedDataNetworkInner> beginCreateOrUpdate(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters,
        Context context) {
        return this
            .beginCreateOrUpdateAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters,
                context)
            .getSyncPoller();
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network 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 attached data network resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AttachedDataNetworkInner> createOrUpdateAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters) {
        return beginCreateOrUpdateAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network operation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return attached data network resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AttachedDataNetworkInner> createOrUpdateAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters,
        Context context) {
        return beginCreateOrUpdateAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network 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 attached data network resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AttachedDataNetworkInner createOrUpdate(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters) {
        return createOrUpdateAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters)
            .block();
    }

    /**
     * Creates or updates an attached data network. Must be created in the same location as its parent packet core data
     * plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to the create or update attached data network operation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return attached data network resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AttachedDataNetworkInner createOrUpdate(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        AttachedDataNetworkInner parameters,
        Context context) {
        return createOrUpdateAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters,
                context)
            .block();
    }

    /**
     * Updates an attached data network tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to update attached data network tags.
     * @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 attached data network resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AttachedDataNetworkInner>> updateTagsWithResponseAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        TagsObject parameters) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        if (attachedDataNetworkName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter attachedDataNetworkName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .updateTags(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            packetCoreControlPlaneName,
                            packetCoreDataPlaneName,
                            attachedDataNetworkName,
                            this.client.getApiVersion(),
                            parameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates an attached data network tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to update attached data network tags.
     * @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 attached data network resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AttachedDataNetworkInner>> updateTagsWithResponseAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        TagsObject parameters,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        if (attachedDataNetworkName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter attachedDataNetworkName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .updateTags(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                this.client.getApiVersion(),
                parameters,
                accept,
                context);
    }

    /**
     * Updates an attached data network tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to update attached data network tags.
     * @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 attached data network resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AttachedDataNetworkInner> updateTagsAsync(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        TagsObject parameters) {
        return updateTagsWithResponseAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Updates an attached data network tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to update attached data network tags.
     * @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 attached data network resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AttachedDataNetworkInner> updateTagsWithResponse(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        TagsObject parameters,
        Context context) {
        return updateTagsWithResponseAsync(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters,
                context)
            .block();
    }

    /**
     * Updates an attached data network tags.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @param attachedDataNetworkName The name of the attached data network.
     * @param parameters Parameters supplied to update attached data network tags.
     * @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 attached data network resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AttachedDataNetworkInner updateTags(
        String resourceGroupName,
        String packetCoreControlPlaneName,
        String packetCoreDataPlaneName,
        String attachedDataNetworkName,
        TagsObject parameters) {
        return updateTagsWithResponse(
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                attachedDataNetworkName,
                parameters,
                Context.NONE)
            .getValue();
    }

    /**
     * Gets all the attached data networks associated with a packet core data plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @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 all the attached data networks associated with a packet core data plane along with {@link PagedResponse}
     *     on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AttachedDataNetworkInner>> listByPacketCoreDataPlaneSinglePageAsync(
        String resourceGroupName, String packetCoreControlPlaneName, String packetCoreDataPlaneName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByPacketCoreDataPlane(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            packetCoreControlPlaneName,
                            packetCoreDataPlaneName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .<PagedResponse<AttachedDataNetworkInner>>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()));
    }

    /**
     * Gets all the attached data networks associated with a packet core data plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @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 all the attached data networks associated with a packet core data plane along with {@link PagedResponse}
     *     on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AttachedDataNetworkInner>> listByPacketCoreDataPlaneSinglePageAsync(
        String resourceGroupName, String packetCoreControlPlaneName, String packetCoreDataPlaneName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (packetCoreControlPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter packetCoreControlPlaneName is required and cannot be null."));
        }
        if (packetCoreDataPlaneName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter packetCoreDataPlaneName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByPacketCoreDataPlane(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                packetCoreControlPlaneName,
                packetCoreDataPlaneName,
                this.client.getApiVersion(),
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Gets all the attached data networks associated with a packet core data plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @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 all the attached data networks associated with a packet core data plane as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AttachedDataNetworkInner> listByPacketCoreDataPlaneAsync(
        String resourceGroupName, String packetCoreControlPlaneName, String packetCoreDataPlaneName) {
        return new PagedFlux<>(
            () ->
                listByPacketCoreDataPlaneSinglePageAsync(
                    resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName),
            nextLink -> listByPacketCoreDataPlaneNextSinglePageAsync(nextLink));
    }

    /**
     * Gets all the attached data networks associated with a packet core data plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @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 all the attached data networks associated with a packet core data plane as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AttachedDataNetworkInner> listByPacketCoreDataPlaneAsync(
        String resourceGroupName, String packetCoreControlPlaneName, String packetCoreDataPlaneName, Context context) {
        return new PagedFlux<>(
            () ->
                listByPacketCoreDataPlaneSinglePageAsync(
                    resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, context),
            nextLink -> listByPacketCoreDataPlaneNextSinglePageAsync(nextLink, context));
    }

    /**
     * Gets all the attached data networks associated with a packet core data plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @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 all the attached data networks associated with a packet core data plane as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AttachedDataNetworkInner> listByPacketCoreDataPlane(
        String resourceGroupName, String packetCoreControlPlaneName, String packetCoreDataPlaneName) {
        return new PagedIterable<>(
            listByPacketCoreDataPlaneAsync(resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName));
    }

    /**
     * Gets all the attached data networks associated with a packet core data plane.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param packetCoreControlPlaneName The name of the packet core control plane.
     * @param packetCoreDataPlaneName The name of the packet core data plane.
     * @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 all the attached data networks associated with a packet core data plane as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AttachedDataNetworkInner> listByPacketCoreDataPlane(
        String resourceGroupName, String packetCoreControlPlaneName, String packetCoreDataPlaneName, Context context) {
        return new PagedIterable<>(
            listByPacketCoreDataPlaneAsync(
                resourceGroupName, packetCoreControlPlaneName, packetCoreDataPlaneName, context));
    }

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

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