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

package com.azure.resourcemanager.servicenetworking.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.servicenetworking.fluent.AssociationsInterfacesClient;
import com.azure.resourcemanager.servicenetworking.fluent.models.AssociationInner;
import com.azure.resourcemanager.servicenetworking.models.AssociationListResult;
import com.azure.resourcemanager.servicenetworking.models.AssociationUpdate;
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 AssociationsInterfacesClient. */
public final class AssociationsInterfacesClientImpl implements AssociationsInterfacesClient {
    /** The proxy service used to perform REST calls. */
    private final AssociationsInterfacesService service;

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

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

    /**
     * The interface defining all the services for TrafficControllerManagementClientAssociationsInterfaces to be used by
     * the proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "TrafficControllerMan")
    public interface AssociationsInterfacesService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AssociationListResult>> listByTrafficController(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("trafficControllerName") String trafficControllerName,
            @HeaderParam("Accept") String accept,
            Context context);

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

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("trafficControllerName") String trafficControllerName,
            @PathParam("associationName") String associationName,
            @BodyParam("application/json") AssociationInner resource,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AssociationInner>> update(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("trafficControllerName") String trafficControllerName,
            @PathParam("associationName") String associationName,
            @BodyParam("application/json") AssociationUpdate properties,
            @HeaderParam("Accept") String accept,
            Context context);

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

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

    /**
     * List Association resources by TrafficController.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a Association list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AssociationInner>> listByTrafficControllerSinglePageAsync(
        String resourceGroupName, String trafficControllerName) {
        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 (trafficControllerName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter trafficControllerName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByTrafficController(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            trafficControllerName,
                            accept,
                            context))
            .<PagedResponse<AssociationInner>>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 Association resources by TrafficController.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a Association list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AssociationInner>> listByTrafficControllerSinglePageAsync(
        String resourceGroupName, String trafficControllerName, 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 (trafficControllerName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter trafficControllerName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByTrafficController(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                trafficControllerName,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * List Association resources by TrafficController.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a Association list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AssociationInner> listByTrafficControllerAsync(
        String resourceGroupName, String trafficControllerName) {
        return new PagedFlux<>(
            () -> listByTrafficControllerSinglePageAsync(resourceGroupName, trafficControllerName),
            nextLink -> listByTrafficControllerNextSinglePageAsync(nextLink));
    }

    /**
     * List Association resources by TrafficController.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a Association list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AssociationInner> listByTrafficControllerAsync(
        String resourceGroupName, String trafficControllerName, Context context) {
        return new PagedFlux<>(
            () -> listByTrafficControllerSinglePageAsync(resourceGroupName, trafficControllerName, context),
            nextLink -> listByTrafficControllerNextSinglePageAsync(nextLink, context));
    }

    /**
     * List Association resources by TrafficController.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a Association list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AssociationInner> listByTrafficController(
        String resourceGroupName, String trafficControllerName) {
        return new PagedIterable<>(listByTrafficControllerAsync(resourceGroupName, trafficControllerName));
    }

    /**
     * List Association resources by TrafficController.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a Association list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AssociationInner> listByTrafficController(
        String resourceGroupName, String trafficControllerName, Context context) {
        return new PagedIterable<>(listByTrafficControllerAsync(resourceGroupName, trafficControllerName, context));
    }

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

    /**
     * Get a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 Association along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AssociationInner>> getWithResponseAsync(
        String resourceGroupName, String trafficControllerName, String associationName, 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 (trafficControllerName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter trafficControllerName is required and cannot be null."));
        }
        if (associationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associationName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .get(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                trafficControllerName,
                associationName,
                accept,
                context);
    }

    /**
     * Get a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 Association on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AssociationInner> getAsync(
        String resourceGroupName, String trafficControllerName, String associationName) {
        return getWithResponseAsync(resourceGroupName, trafficControllerName, associationName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 Association along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AssociationInner> getWithResponse(
        String resourceGroupName, String trafficControllerName, String associationName, Context context) {
        return getWithResponseAsync(resourceGroupName, trafficControllerName, associationName, context).block();
    }

    /**
     * Get a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 Association.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AssociationInner get(String resourceGroupName, String trafficControllerName, String associationName) {
        return getWithResponse(resourceGroupName, trafficControllerName, associationName, Context.NONE).getValue();
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName, String trafficControllerName, String associationName, AssociationInner resource) {
        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 (trafficControllerName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter trafficControllerName is required and cannot be null."));
        }
        if (associationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associationName is required and cannot be null."));
        }
        if (resource == null) {
            return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            trafficControllerName,
                            associationName,
                            resource,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String resourceGroupName,
        String trafficControllerName,
        String associationName,
        AssociationInner resource,
        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 (trafficControllerName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter trafficControllerName is required and cannot be null."));
        }
        if (associationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associationName is required and cannot be null."));
        }
        if (resource == null) {
            return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                trafficControllerName,
                associationName,
                resource,
                accept,
                context);
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of association Subresource of Traffic Controller.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<AssociationInner>, AssociationInner> beginCreateOrUpdateAsync(
        String resourceGroupName, String trafficControllerName, String associationName, AssociationInner resource) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(resourceGroupName, trafficControllerName, associationName, resource);
        return this
            .client
            .<AssociationInner, AssociationInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                AssociationInner.class,
                AssociationInner.class,
                this.client.getContext());
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of association Subresource of Traffic Controller.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<AssociationInner>, AssociationInner> beginCreateOrUpdateAsync(
        String resourceGroupName,
        String trafficControllerName,
        String associationName,
        AssociationInner resource,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(
                resourceGroupName, trafficControllerName, associationName, resource, context);
        return this
            .client
            .<AssociationInner, AssociationInner>getLroResult(
                mono, this.client.getHttpPipeline(), AssociationInner.class, AssociationInner.class, context);
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of association Subresource of Traffic Controller.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<AssociationInner>, AssociationInner> beginCreateOrUpdate(
        String resourceGroupName, String trafficControllerName, String associationName, AssociationInner resource) {
        return this
            .beginCreateOrUpdateAsync(resourceGroupName, trafficControllerName, associationName, resource)
            .getSyncPoller();
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of association Subresource of Traffic Controller.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<AssociationInner>, AssociationInner> beginCreateOrUpdate(
        String resourceGroupName,
        String trafficControllerName,
        String associationName,
        AssociationInner resource,
        Context context) {
        return this
            .beginCreateOrUpdateAsync(resourceGroupName, trafficControllerName, associationName, resource, context)
            .getSyncPoller();
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AssociationInner> createOrUpdateAsync(
        String resourceGroupName, String trafficControllerName, String associationName, AssociationInner resource) {
        return beginCreateOrUpdateAsync(resourceGroupName, trafficControllerName, associationName, resource)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AssociationInner> createOrUpdateAsync(
        String resourceGroupName,
        String trafficControllerName,
        String associationName,
        AssociationInner resource,
        Context context) {
        return beginCreateOrUpdateAsync(resourceGroupName, trafficControllerName, associationName, resource, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AssociationInner createOrUpdate(
        String resourceGroupName, String trafficControllerName, String associationName, AssociationInner resource) {
        return createOrUpdateAsync(resourceGroupName, trafficControllerName, associationName, resource).block();
    }

    /**
     * Create a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AssociationInner createOrUpdate(
        String resourceGroupName,
        String trafficControllerName,
        String associationName,
        AssociationInner resource,
        Context context) {
        return createOrUpdateAsync(resourceGroupName, trafficControllerName, associationName, resource, context)
            .block();
    }

    /**
     * Update a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param properties The resource properties to be updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AssociationInner>> updateWithResponseAsync(
        String resourceGroupName, String trafficControllerName, String associationName, AssociationUpdate properties) {
        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 (trafficControllerName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter trafficControllerName is required and cannot be null."));
        }
        if (associationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associationName is required and cannot be null."));
        }
        if (properties == null) {
            return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null."));
        } else {
            properties.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            trafficControllerName,
                            associationName,
                            properties,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param properties The resource properties to be updated.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AssociationInner>> updateWithResponseAsync(
        String resourceGroupName,
        String trafficControllerName,
        String associationName,
        AssociationUpdate properties,
        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 (trafficControllerName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter trafficControllerName is required and cannot be null."));
        }
        if (associationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associationName is required and cannot be null."));
        }
        if (properties == null) {
            return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null."));
        } else {
            properties.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                trafficControllerName,
                associationName,
                properties,
                accept,
                context);
    }

    /**
     * Update a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param properties The resource properties to be updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AssociationInner> updateAsync(
        String resourceGroupName, String trafficControllerName, String associationName, AssociationUpdate properties) {
        return updateWithResponseAsync(resourceGroupName, trafficControllerName, associationName, properties)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Update a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param properties The resource properties to be updated.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AssociationInner> updateWithResponse(
        String resourceGroupName,
        String trafficControllerName,
        String associationName,
        AssociationUpdate properties,
        Context context) {
        return updateWithResponseAsync(resourceGroupName, trafficControllerName, associationName, properties, context)
            .block();
    }

    /**
     * Update a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @param properties The resource properties to be updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return association Subresource of Traffic Controller.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AssociationInner update(
        String resourceGroupName, String trafficControllerName, String associationName, AssociationUpdate properties) {
        return updateWithResponse(resourceGroupName, trafficControllerName, associationName, properties, Context.NONE)
            .getValue();
    }

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

    /**
     * Delete a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 trafficControllerName, String associationName, 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 (trafficControllerName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter trafficControllerName is required and cannot be null."));
        }
        if (associationName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associationName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                trafficControllerName,
                associationName,
                accept,
                context);
    }

    /**
     * Delete a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 trafficControllerName, String associationName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(resourceGroupName, trafficControllerName, associationName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Delete a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 trafficControllerName, String associationName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(resourceGroupName, trafficControllerName, associationName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Delete a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 trafficControllerName, String associationName) {
        return this.beginDeleteAsync(resourceGroupName, trafficControllerName, associationName).getSyncPoller();
    }

    /**
     * Delete a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 trafficControllerName, String associationName, Context context) {
        return this
            .beginDeleteAsync(resourceGroupName, trafficControllerName, associationName, context)
            .getSyncPoller();
    }

    /**
     * Delete a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 trafficControllerName, String associationName) {
        return beginDeleteAsync(resourceGroupName, trafficControllerName, associationName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 trafficControllerName, String associationName, Context context) {
        return beginDeleteAsync(resourceGroupName, trafficControllerName, associationName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Delete a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 trafficControllerName, String associationName) {
        deleteAsync(resourceGroupName, trafficControllerName, associationName).block();
    }

    /**
     * Delete a Association.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param trafficControllerName traffic controller name for path.
     * @param associationName Name of Association.
     * @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 trafficControllerName, String associationName, Context context) {
        deleteAsync(resourceGroupName, trafficControllerName, associationName, 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 the response of a Association list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AssociationInner>> listByTrafficControllerNextSinglePageAsync(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.listByTrafficControllerNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<AssociationInner>>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 the response of a Association list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AssociationInner>> listByTrafficControllerNextSinglePageAsync(
        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
            .listByTrafficControllerNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }
}
