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

package com.azure.resourcemanager.managednetworkfabric.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.Post;
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.managednetworkfabric.fluent.NetworkInterfacesClient;
import com.azure.resourcemanager.managednetworkfabric.fluent.models.InterfaceStatusInner;
import com.azure.resourcemanager.managednetworkfabric.fluent.models.NetworkInterfaceInner;
import com.azure.resourcemanager.managednetworkfabric.models.NetworkInterfacePatch;
import com.azure.resourcemanager.managednetworkfabric.models.NetworkInterfacesList;
import com.azure.resourcemanager.managednetworkfabric.models.UpdateAdministrativeState;
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 NetworkInterfacesClient. */
public final class NetworkInterfacesClientImpl implements NetworkInterfacesClient {
    /** The proxy service used to perform REST calls. */
    private final NetworkInterfacesService service;

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

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

    /**
     * The interface defining all the services for AzureNetworkFabricManagementServiceApiNetworkInterfaces to be used by
     * the proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "AzureNetworkFabricMa")
    public interface NetworkInterfacesService {
        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkDevices/{networkDeviceName}/networkInterfaces/{networkInterfaceName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> create(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("networkDeviceName") String networkDeviceName,
            @PathParam("networkInterfaceName") String networkInterfaceName,
            @BodyParam("application/json") NetworkInterfaceInner body,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkDevices/{networkDeviceName}/networkInterfaces/{networkInterfaceName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<NetworkInterfaceInner>> get(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("networkDeviceName") String networkDeviceName,
            @PathParam("networkInterfaceName") String networkInterfaceName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkDevices/{networkDeviceName}/networkInterfaces/{networkInterfaceName}")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> update(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("networkDeviceName") String networkDeviceName,
            @PathParam("networkInterfaceName") String networkInterfaceName,
            @BodyParam("application/json") NetworkInterfacePatch body,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkDevices/{networkDeviceName}/networkInterfaces/{networkInterfaceName}")
        @ExpectedResponses({200, 202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> delete(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("networkDeviceName") String networkDeviceName,
            @PathParam("networkInterfaceName") String networkInterfaceName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkDevices/{networkDeviceName}/networkInterfaces")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<NetworkInterfacesList>> list(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("networkDeviceName") String networkDeviceName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkDevices/{networkDeviceName}/networkInterfaces/{networkInterfaceName}/getStatus")
        @ExpectedResponses({202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> getStatus(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("networkDeviceName") String networkDeviceName,
            @PathParam("networkInterfaceName") String networkInterfaceName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkDevices/{networkDeviceName}/networkInterfaces/{networkInterfaceName}/updateAdministrativeState")
        @ExpectedResponses({202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> updateAdministrativeState(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @PathParam("networkDeviceName") String networkDeviceName,
            @PathParam("networkInterfaceName") String networkInterfaceName,
            @BodyParam("application/json") UpdateAdministrativeState body,
            @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createWithResponseAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfaceInner body) {
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        if (body == null) {
            return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null."));
        } else {
            body.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .create(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            networkDeviceName,
                            networkInterfaceName,
                            body,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createWithResponseAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfaceInner body,
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        if (body == null) {
            return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null."));
        } else {
            body.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .create(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                networkDeviceName,
                networkInterfaceName,
                body,
                accept,
                context);
    }

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<NetworkInterfaceInner>, NetworkInterfaceInner> beginCreateAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfaceInner body) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body);
        return this
            .client
            .<NetworkInterfaceInner, NetworkInterfaceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                NetworkInterfaceInner.class,
                NetworkInterfaceInner.class,
                this.client.getContext());
    }

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<NetworkInterfaceInner>, NetworkInterfaceInner> beginCreateAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfaceInner body,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body, context);
        return this
            .client
            .<NetworkInterfaceInner, NetworkInterfaceInner>getLroResult(
                mono, this.client.getHttpPipeline(), NetworkInterfaceInner.class, NetworkInterfaceInner.class, context);
    }

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<NetworkInterfaceInner>, NetworkInterfaceInner> beginCreate(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfaceInner body) {
        return this.beginCreateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body).getSyncPoller();
    }

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<NetworkInterfaceInner>, NetworkInterfaceInner> beginCreate(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfaceInner body,
        Context context) {
        return this
            .beginCreateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body, context)
            .getSyncPoller();
    }

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<NetworkInterfaceInner> createAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfaceInner body) {
        return beginCreateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<NetworkInterfaceInner> createAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfaceInner body,
        Context context) {
        return beginCreateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NetworkInterfaceInner create(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfaceInner body) {
        return createAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body).block();
    }

    /**
     * Create NetworkInterface.
     *
     * <p>Create a Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NetworkInterfaceInner create(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfaceInner body,
        Context context) {
        return createAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body, context).block();
    }

    /**
     * Gets a NetworkInterface.
     *
     * <p>Get the Network Interface resource details.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 Network Interface resource details along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<NetworkInterfaceInner>> getWithResponseAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName) {
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            networkDeviceName,
                            networkInterfaceName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets a NetworkInterface.
     *
     * <p>Get the Network Interface resource details.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 Network Interface resource details along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<NetworkInterfaceInner>> getWithResponseAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, 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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName 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,
                this.client.getApiVersion(),
                networkDeviceName,
                networkInterfaceName,
                accept,
                context);
    }

    /**
     * Gets a NetworkInterface.
     *
     * <p>Get the Network Interface resource details.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 Network Interface resource details on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<NetworkInterfaceInner> getAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName) {
        return getWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets a NetworkInterface.
     *
     * <p>Get the Network Interface resource details.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 Network Interface resource details along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<NetworkInterfaceInner> getWithResponse(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, Context context) {
        return getWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName, context).block();
    }

    /**
     * Gets a NetworkInterface.
     *
     * <p>Get the Network Interface resource details.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 Network Interface resource details.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NetworkInterfaceInner get(String resourceGroupName, String networkDeviceName, String networkInterfaceName) {
        return getWithResponse(resourceGroupName, networkDeviceName, networkInterfaceName, Context.NONE).getValue();
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfacePatch body) {
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        if (body == null) {
            return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null."));
        } else {
            body.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            networkDeviceName,
                            networkInterfaceName,
                            body,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfacePatch body,
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        if (body == null) {
            return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null."));
        } else {
            body.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                networkDeviceName,
                networkInterfaceName,
                body,
                accept,
                context);
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<NetworkInterfaceInner>, NetworkInterfaceInner> beginUpdateAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfacePatch body) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body);
        return this
            .client
            .<NetworkInterfaceInner, NetworkInterfaceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                NetworkInterfaceInner.class,
                NetworkInterfaceInner.class,
                this.client.getContext());
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<NetworkInterfaceInner>, NetworkInterfaceInner> beginUpdateAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfacePatch body,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body, context);
        return this
            .client
            .<NetworkInterfaceInner, NetworkInterfaceInner>getLroResult(
                mono, this.client.getHttpPipeline(), NetworkInterfaceInner.class, NetworkInterfaceInner.class, context);
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<NetworkInterfaceInner>, NetworkInterfaceInner> beginUpdate(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfacePatch body) {
        return this.beginUpdateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body).getSyncPoller();
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<NetworkInterfaceInner>, NetworkInterfaceInner> beginUpdate(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfacePatch body,
        Context context) {
        return this
            .beginUpdateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body, context)
            .getSyncPoller();
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<NetworkInterfaceInner> updateAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfacePatch body) {
        return beginUpdateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<NetworkInterfaceInner> updateAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfacePatch body,
        Context context) {
        return beginUpdateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NetworkInterfaceInner update(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, NetworkInterfacePatch body) {
        return updateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body).block();
    }

    /**
     * Updates a NetworkInterface.
     *
     * <p>Update certain properties of the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @param body NetworkInterface properties to update. Only tags are supported.
     * @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 defines the NetworkInterface resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NetworkInterfaceInner update(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        NetworkInterfacePatch body,
        Context context) {
        return updateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body, context).block();
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName) {
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            networkDeviceName,
                            networkInterfaceName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName, 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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName 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,
                this.client.getApiVersion(),
                networkDeviceName,
                networkInterfaceName,
                accept,
                context);
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName) {
        return this.beginDeleteAsync(resourceGroupName, networkDeviceName, networkInterfaceName).getSyncPoller();
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName, Context context) {
        return this
            .beginDeleteAsync(resourceGroupName, networkDeviceName, networkInterfaceName, context)
            .getSyncPoller();
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName) {
        return beginDeleteAsync(resourceGroupName, networkDeviceName, networkInterfaceName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName, Context context) {
        return beginDeleteAsync(resourceGroupName, networkDeviceName, networkInterfaceName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName) {
        deleteAsync(resourceGroupName, networkDeviceName, networkInterfaceName).block();
    }

    /**
     * Deletes a NetworkInterface.
     *
     * <p>Delete the Network Interface resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterfaceName.
     * @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 networkDeviceName, String networkInterfaceName, Context context) {
        deleteAsync(resourceGroupName, networkDeviceName, networkInterfaceName, context).block();
    }

    /**
     * List all Network Interfaces that are available using an Network Device.
     *
     * <p>List all the Network Interface resources in a given resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @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 list of NetworkInterfaces along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<NetworkInterfaceInner>> listSinglePageAsync(
        String resourceGroupName, String networkDeviceName) {
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .list(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            networkDeviceName,
                            accept,
                            context))
            .<PagedResponse<NetworkInterfaceInner>>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 all Network Interfaces that are available using an Network Device.
     *
     * <p>List all the Network Interface resources in a given resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @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 list of NetworkInterfaces along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<NetworkInterfaceInner>> listSinglePageAsync(
        String resourceGroupName, String networkDeviceName, 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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                networkDeviceName,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * List all Network Interfaces that are available using an Network Device.
     *
     * <p>List all the Network Interface resources in a given resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @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 list of NetworkInterfaces as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<NetworkInterfaceInner> listAsync(String resourceGroupName, String networkDeviceName) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceGroupName, networkDeviceName),
            nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * List all Network Interfaces that are available using an Network Device.
     *
     * <p>List all the Network Interface resources in a given resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @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 list of NetworkInterfaces as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<NetworkInterfaceInner> listAsync(
        String resourceGroupName, String networkDeviceName, Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceGroupName, networkDeviceName, context),
            nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * List all Network Interfaces that are available using an Network Device.
     *
     * <p>List all the Network Interface resources in a given resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @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 list of NetworkInterfaces as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<NetworkInterfaceInner> list(String resourceGroupName, String networkDeviceName) {
        return new PagedIterable<>(listAsync(resourceGroupName, networkDeviceName));
    }

    /**
     * List all Network Interfaces that are available using an Network Device.
     *
     * <p>List all the Network Interface resources in a given resource group.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @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 list of NetworkInterfaces as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<NetworkInterfaceInner> list(
        String resourceGroupName, String networkDeviceName, Context context) {
        return new PagedIterable<>(listAsync(resourceGroupName, networkDeviceName, context));
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @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 running status of the Network Interface along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> getStatusWithResponseAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName) {
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getStatus(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            networkDeviceName,
                            networkInterfaceName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @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 running status of the Network Interface along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> getStatusWithResponseAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, 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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getStatus(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                networkDeviceName,
                networkInterfaceName,
                accept,
                context);
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the running status of the Network Interface.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<InterfaceStatusInner>, InterfaceStatusInner> beginGetStatusAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            getStatusWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName);
        return this
            .client
            .<InterfaceStatusInner, InterfaceStatusInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                InterfaceStatusInner.class,
                InterfaceStatusInner.class,
                this.client.getContext());
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the running status of the Network Interface.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<InterfaceStatusInner>, InterfaceStatusInner> beginGetStatusAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            getStatusWithResponseAsync(resourceGroupName, networkDeviceName, networkInterfaceName, context);
        return this
            .client
            .<InterfaceStatusInner, InterfaceStatusInner>getLroResult(
                mono, this.client.getHttpPipeline(), InterfaceStatusInner.class, InterfaceStatusInner.class, context);
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the running status of the Network Interface.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<InterfaceStatusInner>, InterfaceStatusInner> beginGetStatus(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName) {
        return this.beginGetStatusAsync(resourceGroupName, networkDeviceName, networkInterfaceName).getSyncPoller();
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the running status of the Network Interface.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<InterfaceStatusInner>, InterfaceStatusInner> beginGetStatus(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, Context context) {
        return this
            .beginGetStatusAsync(resourceGroupName, networkDeviceName, networkInterfaceName, context)
            .getSyncPoller();
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @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 running status of the Network Interface on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<InterfaceStatusInner> getStatusAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName) {
        return beginGetStatusAsync(resourceGroupName, networkDeviceName, networkInterfaceName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @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 running status of the Network Interface on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<InterfaceStatusInner> getStatusAsync(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, Context context) {
        return beginGetStatusAsync(resourceGroupName, networkDeviceName, networkInterfaceName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @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 running status of the Network Interface.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public InterfaceStatusInner getStatus(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName) {
        return getStatusAsync(resourceGroupName, networkDeviceName, networkInterfaceName).block();
    }

    /**
     * Implements the operation to the underlying resources.
     *
     * <p>Get the running status of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @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 running status of the Network Interface.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public InterfaceStatusInner getStatus(
        String resourceGroupName, String networkDeviceName, String networkInterfaceName, Context context) {
        return getStatusAsync(resourceGroupName, networkDeviceName, networkInterfaceName, context).block();
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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>>> updateAdministrativeStateWithResponseAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body) {
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        if (body == null) {
            return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null."));
        } else {
            body.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .updateAdministrativeState(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            this.client.getApiVersion(),
                            networkDeviceName,
                            networkInterfaceName,
                            body,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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>>> updateAdministrativeStateWithResponseAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body,
        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 (networkDeviceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkDeviceName is required and cannot be null."));
        }
        if (networkInterfaceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter networkInterfaceName is required and cannot be null."));
        }
        if (body == null) {
            return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null."));
        } else {
            body.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .updateAdministrativeState(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                this.client.getApiVersion(),
                networkDeviceName,
                networkInterfaceName,
                body,
                accept,
                context);
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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> beginUpdateAdministrativeStateAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateAdministrativeStateWithResponseAsync(
                resourceGroupName, networkDeviceName, networkInterfaceName, body);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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> beginUpdateAdministrativeStateAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateAdministrativeStateWithResponseAsync(
                resourceGroupName, networkDeviceName, networkInterfaceName, body, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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> beginUpdateAdministrativeState(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body) {
        return this
            .beginUpdateAdministrativeStateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body)
            .getSyncPoller();
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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> beginUpdateAdministrativeState(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body,
        Context context) {
        return this
            .beginUpdateAdministrativeStateAsync(
                resourceGroupName, networkDeviceName, networkInterfaceName, body, context)
            .getSyncPoller();
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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> updateAdministrativeStateAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body) {
        return beginUpdateAdministrativeStateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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> updateAdministrativeStateAsync(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body,
        Context context) {
        return beginUpdateAdministrativeStateAsync(
                resourceGroupName, networkDeviceName, networkInterfaceName, body, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 updateAdministrativeState(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body) {
        updateAdministrativeStateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body).block();
    }

    /**
     * Updates the admin state of the network interface.
     *
     * <p>Update the admin state of the Network Interface.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param networkDeviceName Name of the NetworkDevice.
     * @param networkInterfaceName Name of the NetworkInterface.
     * @param body Request payload.
     * @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 updateAdministrativeState(
        String resourceGroupName,
        String networkDeviceName,
        String networkInterfaceName,
        UpdateAdministrativeState body,
        Context context) {
        updateAdministrativeStateAsync(resourceGroupName, networkDeviceName, networkInterfaceName, body, context)
            .block();
    }

    /**
     * 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 list of NetworkInterfaces along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<NetworkInterfaceInner>> listNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<NetworkInterfaceInner>>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 list of NetworkInterfaces along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<NetworkInterfaceInner>> listNextSinglePageAsync(String nextLink, Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }
}
