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

package com.azure.resourcemanager.recoveryservicessiterecovery.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.recoveryservicessiterecovery.fluent.ReplicationProtectedItemsClient;
import com.azure.resourcemanager.recoveryservicessiterecovery.fluent.models.ReplicationProtectedItemInner;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.AddDisksInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.ApplyRecoveryPointInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.DisableProtectionInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.EnableProtectionInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.PlannedFailoverInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.RemoveDisksInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.ReplicationProtectedItemCollection;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.ResolveHealthInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.ReverseReplicationInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.SwitchProviderInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.TestFailoverCleanupInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.TestFailoverInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.UnplannedFailoverInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.UpdateApplianceForReplicationProtectedItemInput;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.UpdateMobilityServiceRequest;
import com.azure.resourcemanager.recoveryservicessiterecovery.models.UpdateReplicationProtectedItemInput;
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 ReplicationProtectedItemsClient. */
public final class ReplicationProtectedItemsClientImpl implements ReplicationProtectedItemsClient {
    /** The proxy service used to perform REST calls. */
    private final ReplicationProtectedItemsService service;

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

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

    /**
     * The interface defining all the services for SiteRecoveryManagementClientReplicationProtectedItems to be used by
     * the proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "SiteRecoveryManageme")
    public interface ReplicationProtectedItemsService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ReplicationProtectedItemCollection>> listByReplicationProtectionContainers(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ReplicationProtectedItemInner>> get(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> create(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") EnableProtectionInput input,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}")
        @ExpectedResponses({202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> purge(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> update(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") UpdateReplicationProtectedItemInput updateProtectionInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/addDisks")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> addDisks(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") AddDisksInput addDisksInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}"
                + "/applyRecoveryPoint")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> applyRecoveryPoint(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") ApplyRecoveryPointInput applyRecoveryPointInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/failoverCancel")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> failoverCancel(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/failoverCommit")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> failoverCommit(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/plannedFailover")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> plannedFailover(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") PlannedFailoverInput failoverInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/remove")
        @ExpectedResponses({202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> delete(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") DisableProtectionInput disableProtectionInput,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/removeDisks")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> removeDisks(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") RemoveDisksInput removeDisksInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}"
                + "/repairReplication")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> repairReplication(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/reProtect")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> reprotect(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") ReverseReplicationInput reprotectInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}"
                + "/resolveHealthErrors")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> resolveHealthErrors(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") ResolveHealthInput resolveHealthInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/switchProvider")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> switchProvider(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") SwitchProviderInput switchProviderInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/testFailover")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> testFailover(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") TestFailoverInput testfailoverInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}"
                + "/testFailoverCleanup")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> testFailoverCleanup(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") TestFailoverCleanupInput cleanupInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}"
                + "/unplannedFailover")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> unplannedFailover(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") UnplannedFailoverInput failoverInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/updateAppliance")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> updateAppliance(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers"
                + "/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}"
                + "/updateMobilityService")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> updateMobilityService(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("fabricName") String fabricName,
            @PathParam("protectionContainerName") String protectionContainerName,
            @PathParam("replicatedProtectedItemName") String replicatedProtectedItemName,
            @BodyParam("application/json") UpdateMobilityServiceRequest updateMobilityServiceRequest,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices"
                + "/vaults/{resourceName}/replicationProtectedItems")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<ReplicationProtectedItemCollection>> list(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("resourceName") String resourceName,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("subscriptionId") String subscriptionId,
            @QueryParam("skipToken") String skipToken,
            @QueryParam("$filter") String filter,
            @HeaderParam("Accept") String accept,
            Context context);

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

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

    /**
     * Gets the list of Replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the protection container.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @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 list of ASR replication protected items in the protection container along with {@link PagedResponse}
     *     on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ReplicationProtectedItemInner>> listByReplicationProtectionContainersSinglePageAsync(
        String resourceName, String resourceGroupName, String fabricName, String protectionContainerName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByReplicationProtectionContainers(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            accept,
                            context))
            .<PagedResponse<ReplicationProtectedItemInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets the list of Replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the protection container.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @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 list of ASR replication protected items in the protection container along with {@link PagedResponse}
     *     on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ReplicationProtectedItemInner>> listByReplicationProtectionContainersSinglePageAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByReplicationProtectionContainers(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Gets the list of Replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the protection container.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @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 list of ASR replication protected items in the protection container as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ReplicationProtectedItemInner> listByReplicationProtectionContainersAsync(
        String resourceName, String resourceGroupName, String fabricName, String protectionContainerName) {
        return new PagedFlux<>(
            () ->
                listByReplicationProtectionContainersSinglePageAsync(
                    resourceName, resourceGroupName, fabricName, protectionContainerName),
            nextLink -> listByReplicationProtectionContainersNextSinglePageAsync(nextLink));
    }

    /**
     * Gets the list of Replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the protection container.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @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 list of ASR replication protected items in the protection container as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ReplicationProtectedItemInner> listByReplicationProtectionContainersAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        Context context) {
        return new PagedFlux<>(
            () ->
                listByReplicationProtectionContainersSinglePageAsync(
                    resourceName, resourceGroupName, fabricName, protectionContainerName, context),
            nextLink -> listByReplicationProtectionContainersNextSinglePageAsync(nextLink, context));
    }

    /**
     * Gets the list of Replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the protection container.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @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 list of ASR replication protected items in the protection container as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ReplicationProtectedItemInner> listByReplicationProtectionContainers(
        String resourceName, String resourceGroupName, String fabricName, String protectionContainerName) {
        return new PagedIterable<>(
            listByReplicationProtectionContainersAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName));
    }

    /**
     * Gets the list of Replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the protection container.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @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 list of ASR replication protected items in the protection container as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ReplicationProtectedItemInner> listByReplicationProtectionContainers(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        Context context) {
        return new PagedIterable<>(
            listByReplicationProtectionContainersAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, context));
    }

    /**
     * Gets the details of a Replication protected item.
     *
     * <p>Gets the details of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric unique name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 details of an ASR replication protected item along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ReplicationProtectedItemInner>> getWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets the details of a Replication protected item.
     *
     * <p>Gets the details of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric unique name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 details of an ASR replication protected item along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<ReplicationProtectedItemInner>> getWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName 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(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                accept,
                context);
    }

    /**
     * Gets the details of a Replication protected item.
     *
     * <p>Gets the details of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric unique name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 details of an ASR replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> getAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return getWithResponseAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets the details of a Replication protected item.
     *
     * <p>Gets the details of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric unique name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 details of an ASR replication protected item along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<ReplicationProtectedItemInner> getWithResponse(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return getWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .block();
    }

    /**
     * Gets the details of a Replication protected item.
     *
     * <p>Gets the details of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric unique name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 details of an ASR replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner get(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return getWithResponse(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                Context.NONE)
            .getValue();
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (input == null) {
            return Mono.error(new IllegalArgumentException("Parameter input is required and cannot be null."));
        } else {
            input.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .create(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            input,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (input == null) {
            return Mono.error(new IllegalArgumentException("Parameter input is required and cannot be null."));
        } else {
            input.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .create(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                input,
                accept,
                context);
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginCreateAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                input);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginCreateAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                input,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginCreate(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input) {
        return this
            .beginCreateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                input)
            .getSyncPoller();
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginCreate(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input,
        Context context) {
        return this
            .beginCreateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                input,
                context)
            .getSyncPoller();
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> createAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input) {
        return beginCreateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                input)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> createAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input,
        Context context) {
        return beginCreateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                input,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner create(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input) {
        return createAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                input)
            .block();
    }

    /**
     * Enables protection.
     *
     * <p>The operation to create an ASR replication protected item (Enable replication).
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Name of the fabric.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName A name for the replication protected item.
     * @param input Enable Protection Input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner create(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        EnableProtectionInput input,
        Context context) {
        return createAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                input,
                context)
            .block();
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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>>> purgeWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        return FluxUtil
            .withContext(
                context ->
                    service
                        .purge(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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>>> purgeWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        context = this.client.mergeContext(context);
        return service
            .purge(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context);
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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> beginPurgeAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            purgeWithResponseAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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> beginPurgeAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            purgeWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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> beginPurge(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return this
            .beginPurgeAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .getSyncPoller();
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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> beginPurge(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return this
            .beginPurgeAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .getSyncPoller();
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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> purgeAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return beginPurgeAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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> purgeAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return beginPurgeAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 purge(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        purgeAsync(resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .block();
    }

    /**
     * Purges protection.
     *
     * <p>The operation to delete or purge a replication protected item. This operation will force delete the
     * replication protected item. Use the remove operation on replication protected item to perform a clean disable
     * replication for the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 purge(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        purgeAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .block();
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (updateProtectionInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter updateProtectionInput is required and cannot be null."));
        } else {
            updateProtectionInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            updateProtectionInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (updateProtectionInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter updateProtectionInput is required and cannot be null."));
        } else {
            updateProtectionInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateProtectionInput,
                accept,
                context);
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginUpdateAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateProtectionInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginUpdateAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateProtectionInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginUpdate(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput) {
        return this
            .beginUpdateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateProtectionInput)
            .getSyncPoller();
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginUpdate(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput,
        Context context) {
        return this
            .beginUpdateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateProtectionInput,
                context)
            .getSyncPoller();
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> updateAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput) {
        return beginUpdateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateProtectionInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> updateAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput,
        Context context) {
        return beginUpdateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateProtectionInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner update(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput) {
        return updateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateProtectionInput)
            .block();
    }

    /**
     * Updates the replication protected item settings.
     *
     * <p>The operation to update the recovery settings of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param updateProtectionInput Update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner update(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateReplicationProtectedItemInput updateProtectionInput,
        Context context) {
        return updateAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateProtectionInput,
                context)
            .block();
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> addDisksWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (addDisksInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter addDisksInput is required and cannot be null."));
        } else {
            addDisksInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .addDisks(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            addDisksInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> addDisksWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (addDisksInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter addDisksInput is required and cannot be null."));
        } else {
            addDisksInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .addDisks(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                addDisksInput,
                accept,
                context);
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginAddDisksAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            addDisksWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                addDisksInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginAddDisksAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            addDisksWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                addDisksInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginAddDisks(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput) {
        return this
            .beginAddDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                addDisksInput)
            .getSyncPoller();
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginAddDisks(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput,
        Context context) {
        return this
            .beginAddDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                addDisksInput,
                context)
            .getSyncPoller();
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> addDisksAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput) {
        return beginAddDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                addDisksInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> addDisksAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput,
        Context context) {
        return beginAddDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                addDisksInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner addDisks(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput) {
        return addDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                addDisksInput)
            .block();
    }

    /**
     * Add disk(s) for protection.
     *
     * <p>Operation to add disks(s) to the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param addDisksInput Add disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner addDisks(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        AddDisksInput addDisksInput,
        Context context) {
        return addDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                addDisksInput,
                context)
            .block();
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> applyRecoveryPointWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ApplyRecoveryPointInput applyRecoveryPointInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (applyRecoveryPointInput == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter applyRecoveryPointInput is required and cannot be null."));
        } else {
            applyRecoveryPointInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .applyRecoveryPoint(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            applyRecoveryPointInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> applyRecoveryPointWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ApplyRecoveryPointInput applyRecoveryPointInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (applyRecoveryPointInput == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter applyRecoveryPointInput is required and cannot be null."));
        } else {
            applyRecoveryPointInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .applyRecoveryPoint(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applyRecoveryPointInput,
                accept,
                context);
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginApplyRecoveryPointAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            ApplyRecoveryPointInput applyRecoveryPointInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            applyRecoveryPointWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applyRecoveryPointInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginApplyRecoveryPointAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            ApplyRecoveryPointInput applyRecoveryPointInput,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            applyRecoveryPointWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applyRecoveryPointInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginApplyRecoveryPoint(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ApplyRecoveryPointInput applyRecoveryPointInput) {
        return this
            .beginApplyRecoveryPointAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applyRecoveryPointInput)
            .getSyncPoller();
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginApplyRecoveryPoint(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ApplyRecoveryPointInput applyRecoveryPointInput,
        Context context) {
        return this
            .beginApplyRecoveryPointAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applyRecoveryPointInput,
                context)
            .getSyncPoller();
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> applyRecoveryPointAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ApplyRecoveryPointInput applyRecoveryPointInput) {
        return beginApplyRecoveryPointAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applyRecoveryPointInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> applyRecoveryPointAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ApplyRecoveryPointInput applyRecoveryPointInput,
        Context context) {
        return beginApplyRecoveryPointAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applyRecoveryPointInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner applyRecoveryPoint(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ApplyRecoveryPointInput applyRecoveryPointInput) {
        return applyRecoveryPointAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applyRecoveryPointInput)
            .block();
    }

    /**
     * Change or apply recovery point.
     *
     * <p>The operation to change the recovery point of a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The ARM fabric name.
     * @param protectionContainerName The protection container name.
     * @param replicatedProtectedItemName The replicated protected item name.
     * @param applyRecoveryPointInput The ApplyRecoveryPointInput.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner applyRecoveryPoint(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ApplyRecoveryPointInput applyRecoveryPointInput,
        Context context) {
        return applyRecoveryPointAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applyRecoveryPointInput,
                context)
            .block();
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> failoverCancelWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .failoverCancel(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> failoverCancelWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .failoverCancel(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                accept,
                context);
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginFailoverCancelAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            failoverCancelWithResponseAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginFailoverCancelAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            failoverCancelWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginFailoverCancel(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return this
            .beginFailoverCancelAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .getSyncPoller();
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginFailoverCancel(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return this
            .beginFailoverCancelAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .getSyncPoller();
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> failoverCancelAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return beginFailoverCancelAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> failoverCancelAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return beginFailoverCancelAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner failoverCancel(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return failoverCancelAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .block();
    }

    /**
     * Execute cancel failover.
     *
     * <p>Operation to cancel the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner failoverCancel(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return failoverCancelAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .block();
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> failoverCommitWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .failoverCommit(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> failoverCommitWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .failoverCommit(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                accept,
                context);
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginFailoverCommitAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            failoverCommitWithResponseAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginFailoverCommitAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            failoverCommitWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginFailoverCommit(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return this
            .beginFailoverCommitAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .getSyncPoller();
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginFailoverCommit(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return this
            .beginFailoverCommitAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .getSyncPoller();
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> failoverCommitAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return beginFailoverCommitAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> failoverCommitAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return beginFailoverCommitAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner failoverCommit(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return failoverCommitAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .block();
    }

    /**
     * Execute commit failover.
     *
     * <p>Operation to commit the failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner failoverCommit(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return failoverCommitAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .block();
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> plannedFailoverWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        PlannedFailoverInput failoverInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (failoverInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter failoverInput is required and cannot be null."));
        } else {
            failoverInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .plannedFailover(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            failoverInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> plannedFailoverWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        PlannedFailoverInput failoverInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (failoverInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter failoverInput is required and cannot be null."));
        } else {
            failoverInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .plannedFailover(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                accept,
                context);
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginPlannedFailoverAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            PlannedFailoverInput failoverInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            plannedFailoverWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginPlannedFailoverAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            PlannedFailoverInput failoverInput,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            plannedFailoverWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginPlannedFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        PlannedFailoverInput failoverInput) {
        return this
            .beginPlannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput)
            .getSyncPoller();
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginPlannedFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        PlannedFailoverInput failoverInput,
        Context context) {
        return this
            .beginPlannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                context)
            .getSyncPoller();
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> plannedFailoverAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        PlannedFailoverInput failoverInput) {
        return beginPlannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> plannedFailoverAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        PlannedFailoverInput failoverInput,
        Context context) {
        return beginPlannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner plannedFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        PlannedFailoverInput failoverInput) {
        return plannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput)
            .block();
    }

    /**
     * Execute planned failover.
     *
     * <p>Operation to initiate a planned failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Planned failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner plannedFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        PlannedFailoverInput failoverInput,
        Context context) {
        return plannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                context)
            .block();
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (disableProtectionInput == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter disableProtectionInput is required and cannot be null."));
        } else {
            disableProtectionInput.validate();
        }
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            disableProtectionInput,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (disableProtectionInput == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter disableProtectionInput is required and cannot be null."));
        } else {
            disableProtectionInput.validate();
        }
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                disableProtectionInput,
                context);
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                disableProtectionInput);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                disableProtectionInput,
                context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput) {
        return this
            .beginDeleteAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                disableProtectionInput)
            .getSyncPoller();
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput,
        Context context) {
        return this
            .beginDeleteAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                disableProtectionInput,
                context)
            .getSyncPoller();
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput) {
        return beginDeleteAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                disableProtectionInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput,
        Context context) {
        return beginDeleteAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                disableProtectionInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput) {
        deleteAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                disableProtectionInput)
            .block();
    }

    /**
     * Disables protection.
     *
     * <p>The operation to disable replication on a replication protected item. This will also remove the item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param disableProtectionInput Disable protection input.
     * @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 resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        DisableProtectionInput disableProtectionInput,
        Context context) {
        deleteAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                disableProtectionInput,
                context)
            .block();
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> removeDisksWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (removeDisksInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter removeDisksInput is required and cannot be null."));
        } else {
            removeDisksInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .removeDisks(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            removeDisksInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> removeDisksWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (removeDisksInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter removeDisksInput is required and cannot be null."));
        } else {
            removeDisksInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .removeDisks(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                removeDisksInput,
                accept,
                context);
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginRemoveDisksAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            removeDisksWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                removeDisksInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginRemoveDisksAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            removeDisksWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                removeDisksInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginRemoveDisks(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput) {
        return this
            .beginRemoveDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                removeDisksInput)
            .getSyncPoller();
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginRemoveDisks(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput,
        Context context) {
        return this
            .beginRemoveDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                removeDisksInput,
                context)
            .getSyncPoller();
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> removeDisksAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput) {
        return beginRemoveDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                removeDisksInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> removeDisksAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput,
        Context context) {
        return beginRemoveDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                removeDisksInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner removeDisks(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput) {
        return removeDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                removeDisksInput)
            .block();
    }

    /**
     * Removes disk(s).
     *
     * <p>Operation to remove disk(s) from the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param removeDisksInput Remove disks input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner removeDisks(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        RemoveDisksInput removeDisksInput,
        Context context) {
        return removeDisksAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                removeDisksInput,
                context)
            .block();
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> repairReplicationWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .repairReplication(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> repairReplicationWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .repairReplication(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                accept,
                context);
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginRepairReplicationAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            repairReplicationWithResponseAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginRepairReplicationAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            repairReplicationWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginRepairReplication(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return this
            .beginRepairReplicationAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .getSyncPoller();
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginRepairReplication(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return this
            .beginRepairReplicationAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .getSyncPoller();
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> repairReplicationAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return beginRepairReplicationAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> repairReplicationAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return beginRepairReplicationAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner repairReplication(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName) {
        return repairReplicationAsync(
                resourceName, resourceGroupName, fabricName, protectionContainerName, replicatedProtectedItemName)
            .block();
    }

    /**
     * Resynchronize or repair replication.
     *
     * <p>The operation to start resynchronize/repair replication for a replication protected item requiring
     * resynchronization.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric.
     * @param protectionContainerName The name of the container.
     * @param replicatedProtectedItemName The name of the replication protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner repairReplication(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        Context context) {
        return repairReplicationAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                context)
            .block();
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> reprotectWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (reprotectInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter reprotectInput is required and cannot be null."));
        } else {
            reprotectInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .reprotect(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            reprotectInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> reprotectWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (reprotectInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter reprotectInput is required and cannot be null."));
        } else {
            reprotectInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .reprotect(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                reprotectInput,
                accept,
                context);
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginReprotectAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            reprotectWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                reprotectInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginReprotectAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            reprotectWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                reprotectInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginReprotect(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput) {
        return this
            .beginReprotectAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                reprotectInput)
            .getSyncPoller();
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginReprotect(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput,
        Context context) {
        return this
            .beginReprotectAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                reprotectInput,
                context)
            .getSyncPoller();
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> reprotectAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput) {
        return beginReprotectAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                reprotectInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> reprotectAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput,
        Context context) {
        return beginReprotectAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                reprotectInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner reprotect(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput) {
        return reprotectAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                reprotectInput)
            .block();
    }

    /**
     * Execute Reverse Replication\Reprotect.
     *
     * <p>Operation to reprotect or reverse replicate a failed over replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param reprotectInput Reverse replication input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner reprotect(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ReverseReplicationInput reprotectInput,
        Context context) {
        return reprotectAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                reprotectInput,
                context)
            .block();
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> resolveHealthErrorsWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ResolveHealthInput resolveHealthInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (resolveHealthInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resolveHealthInput is required and cannot be null."));
        } else {
            resolveHealthInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .resolveHealthErrors(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            resolveHealthInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> resolveHealthErrorsWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ResolveHealthInput resolveHealthInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (resolveHealthInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resolveHealthInput is required and cannot be null."));
        } else {
            resolveHealthInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .resolveHealthErrors(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                resolveHealthInput,
                accept,
                context);
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginResolveHealthErrorsAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            ResolveHealthInput resolveHealthInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            resolveHealthErrorsWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                resolveHealthInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginResolveHealthErrorsAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            ResolveHealthInput resolveHealthInput,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            resolveHealthErrorsWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                resolveHealthInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginResolveHealthErrors(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            ResolveHealthInput resolveHealthInput) {
        return this
            .beginResolveHealthErrorsAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                resolveHealthInput)
            .getSyncPoller();
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginResolveHealthErrors(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            ResolveHealthInput resolveHealthInput,
            Context context) {
        return this
            .beginResolveHealthErrorsAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                resolveHealthInput,
                context)
            .getSyncPoller();
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> resolveHealthErrorsAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ResolveHealthInput resolveHealthInput) {
        return beginResolveHealthErrorsAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                resolveHealthInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> resolveHealthErrorsAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ResolveHealthInput resolveHealthInput,
        Context context) {
        return beginResolveHealthErrorsAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                resolveHealthInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner resolveHealthErrors(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ResolveHealthInput resolveHealthInput) {
        return resolveHealthErrorsAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                resolveHealthInput)
            .block();
    }

    /**
     * Resolve health errors.
     *
     * <p>Operation to resolve health issues of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param resolveHealthInput Health issue input object.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner resolveHealthErrors(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        ResolveHealthInput resolveHealthInput,
        Context context) {
        return resolveHealthErrorsAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                resolveHealthInput,
                context)
            .block();
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> switchProviderWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        SwitchProviderInput switchProviderInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (switchProviderInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter switchProviderInput is required and cannot be null."));
        } else {
            switchProviderInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .switchProvider(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            switchProviderInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> switchProviderWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        SwitchProviderInput switchProviderInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (switchProviderInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter switchProviderInput is required and cannot be null."));
        } else {
            switchProviderInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .switchProvider(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                switchProviderInput,
                accept,
                context);
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginSwitchProviderAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            SwitchProviderInput switchProviderInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            switchProviderWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                switchProviderInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginSwitchProviderAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            SwitchProviderInput switchProviderInput,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            switchProviderWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                switchProviderInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginSwitchProvider(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        SwitchProviderInput switchProviderInput) {
        return this
            .beginSwitchProviderAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                switchProviderInput)
            .getSyncPoller();
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginSwitchProvider(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        SwitchProviderInput switchProviderInput,
        Context context) {
        return this
            .beginSwitchProviderAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                switchProviderInput,
                context)
            .getSyncPoller();
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> switchProviderAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        SwitchProviderInput switchProviderInput) {
        return beginSwitchProviderAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                switchProviderInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> switchProviderAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        SwitchProviderInput switchProviderInput,
        Context context) {
        return beginSwitchProviderAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                switchProviderInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner switchProvider(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        SwitchProviderInput switchProviderInput) {
        return switchProviderAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                switchProviderInput)
            .block();
    }

    /**
     * Execute switch provider.
     *
     * <p>Operation to initiate a switch provider of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param switchProviderInput Switch provider input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner switchProvider(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        SwitchProviderInput switchProviderInput,
        Context context) {
        return switchProviderAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                switchProviderInput,
                context)
            .block();
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> testFailoverWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (testfailoverInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter testfailoverInput is required and cannot be null."));
        } else {
            testfailoverInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .testFailover(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            testfailoverInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> testFailoverWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (testfailoverInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter testfailoverInput is required and cannot be null."));
        } else {
            testfailoverInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .testFailover(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                testfailoverInput,
                accept,
                context);
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginTestFailoverAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            testFailoverWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                testfailoverInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginTestFailoverAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            testFailoverWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                testfailoverInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginTestFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput) {
        return this
            .beginTestFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                testfailoverInput)
            .getSyncPoller();
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginTestFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput,
        Context context) {
        return this
            .beginTestFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                testfailoverInput,
                context)
            .getSyncPoller();
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> testFailoverAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput) {
        return beginTestFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                testfailoverInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> testFailoverAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput,
        Context context) {
        return beginTestFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                testfailoverInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner testFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput) {
        return testFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                testfailoverInput)
            .block();
    }

    /**
     * Execute test failover.
     *
     * <p>Operation to perform a test failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param testfailoverInput Test failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner testFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverInput testfailoverInput,
        Context context) {
        return testFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                testfailoverInput,
                context)
            .block();
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> testFailoverCleanupWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverCleanupInput cleanupInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (cleanupInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter cleanupInput is required and cannot be null."));
        } else {
            cleanupInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .testFailoverCleanup(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            cleanupInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> testFailoverCleanupWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverCleanupInput cleanupInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (cleanupInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter cleanupInput is required and cannot be null."));
        } else {
            cleanupInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .testFailoverCleanup(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                cleanupInput,
                accept,
                context);
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginTestFailoverCleanupAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            TestFailoverCleanupInput cleanupInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            testFailoverCleanupWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                cleanupInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginTestFailoverCleanupAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            TestFailoverCleanupInput cleanupInput,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            testFailoverCleanupWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                cleanupInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginTestFailoverCleanup(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            TestFailoverCleanupInput cleanupInput) {
        return this
            .beginTestFailoverCleanupAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                cleanupInput)
            .getSyncPoller();
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginTestFailoverCleanup(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            TestFailoverCleanupInput cleanupInput,
            Context context) {
        return this
            .beginTestFailoverCleanupAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                cleanupInput,
                context)
            .getSyncPoller();
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> testFailoverCleanupAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverCleanupInput cleanupInput) {
        return beginTestFailoverCleanupAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                cleanupInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> testFailoverCleanupAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverCleanupInput cleanupInput,
        Context context) {
        return beginTestFailoverCleanupAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                cleanupInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner testFailoverCleanup(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverCleanupInput cleanupInput) {
        return testFailoverCleanupAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                cleanupInput)
            .block();
    }

    /**
     * Execute test failover cleanup.
     *
     * <p>Operation to clean up the test failover of a replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param cleanupInput Test failover cleanup input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner testFailoverCleanup(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        TestFailoverCleanupInput cleanupInput,
        Context context) {
        return testFailoverCleanupAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                cleanupInput,
                context)
            .block();
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> unplannedFailoverWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UnplannedFailoverInput failoverInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (failoverInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter failoverInput is required and cannot be null."));
        } else {
            failoverInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .unplannedFailover(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            failoverInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> unplannedFailoverWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UnplannedFailoverInput failoverInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (failoverInput == null) {
            return Mono.error(new IllegalArgumentException("Parameter failoverInput is required and cannot be null."));
        } else {
            failoverInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .unplannedFailover(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                accept,
                context);
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginUnplannedFailoverAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            UnplannedFailoverInput failoverInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            unplannedFailoverWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginUnplannedFailoverAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            UnplannedFailoverInput failoverInput,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            unplannedFailoverWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginUnplannedFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UnplannedFailoverInput failoverInput) {
        return this
            .beginUnplannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput)
            .getSyncPoller();
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginUnplannedFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UnplannedFailoverInput failoverInput,
        Context context) {
        return this
            .beginUnplannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                context)
            .getSyncPoller();
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> unplannedFailoverAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UnplannedFailoverInput failoverInput) {
        return beginUnplannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> unplannedFailoverAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UnplannedFailoverInput failoverInput,
        Context context) {
        return beginUnplannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner unplannedFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UnplannedFailoverInput failoverInput) {
        return unplannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput)
            .block();
    }

    /**
     * Execute unplanned failover.
     *
     * <p>Operation to initiate a failover of the replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Unique fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param failoverInput Failover input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner unplannedFailover(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UnplannedFailoverInput failoverInput,
        Context context) {
        return unplannedFailoverAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                failoverInput,
                context)
            .block();
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateApplianceWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (applianceUpdateInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter applianceUpdateInput is required and cannot be null."));
        } else {
            applianceUpdateInput.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .updateAppliance(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            applianceUpdateInput,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateApplianceWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (applianceUpdateInput == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter applianceUpdateInput is required and cannot be null."));
        } else {
            applianceUpdateInput.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .updateAppliance(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applianceUpdateInput,
                accept,
                context);
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginUpdateApplianceAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateApplianceWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applianceUpdateInput);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginUpdateApplianceAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateApplianceWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applianceUpdateInput,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginUpdateAppliance(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput) {
        return this
            .beginUpdateApplianceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applianceUpdateInput)
            .getSyncPoller();
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner> beginUpdateAppliance(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput,
        Context context) {
        return this
            .beginUpdateApplianceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applianceUpdateInput,
                context)
            .getSyncPoller();
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> updateApplianceAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput) {
        return beginUpdateApplianceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applianceUpdateInput)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> updateApplianceAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput,
        Context context) {
        return beginUpdateApplianceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applianceUpdateInput,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner updateAppliance(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput) {
        return updateApplianceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applianceUpdateInput)
            .block();
    }

    /**
     * Updates appliance for replication protected Item.
     *
     * <p>The operation to update appliance of an ASR replication protected item.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName Fabric name.
     * @param protectionContainerName Protection container name.
     * @param replicatedProtectedItemName Replication protected item name.
     * @param applianceUpdateInput Appliance update protection input.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner updateAppliance(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateApplianceForReplicationProtectedItemInput applianceUpdateInput,
        Context context) {
        return updateApplianceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                applianceUpdateInput,
                context)
            .block();
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateMobilityServiceWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateMobilityServiceRequest updateMobilityServiceRequest) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (updateMobilityServiceRequest == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter updateMobilityServiceRequest is required and cannot be null."));
        } else {
            updateMobilityServiceRequest.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .updateMobilityService(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            fabricName,
                            protectionContainerName,
                            replicatedProtectedItemName,
                            updateMobilityServiceRequest,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateMobilityServiceWithResponseAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateMobilityServiceRequest updateMobilityServiceRequest,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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 (fabricName == null) {
            return Mono.error(new IllegalArgumentException("Parameter fabricName is required and cannot be null."));
        }
        if (protectionContainerName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter protectionContainerName is required and cannot be null."));
        }
        if (replicatedProtectedItemName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter replicatedProtectedItemName is required and cannot be null."));
        }
        if (updateMobilityServiceRequest == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter updateMobilityServiceRequest is required and cannot be null."));
        } else {
            updateMobilityServiceRequest.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .updateMobilityService(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateMobilityServiceRequest,
                accept,
                context);
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginUpdateMobilityServiceAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            UpdateMobilityServiceRequest updateMobilityServiceRequest) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateMobilityServiceWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateMobilityServiceRequest);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                this.client.getContext());
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginUpdateMobilityServiceAsync(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            UpdateMobilityServiceRequest updateMobilityServiceRequest,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateMobilityServiceWithResponseAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateMobilityServiceRequest,
                context);
        return this
            .client
            .<ReplicationProtectedItemInner, ReplicationProtectedItemInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                ReplicationProtectedItemInner.class,
                ReplicationProtectedItemInner.class,
                context);
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginUpdateMobilityService(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            UpdateMobilityServiceRequest updateMobilityServiceRequest) {
        return this
            .beginUpdateMobilityServiceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateMobilityServiceRequest)
            .getSyncPoller();
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<ReplicationProtectedItemInner>, ReplicationProtectedItemInner>
        beginUpdateMobilityService(
            String resourceName,
            String resourceGroupName,
            String fabricName,
            String protectionContainerName,
            String replicatedProtectedItemName,
            UpdateMobilityServiceRequest updateMobilityServiceRequest,
            Context context) {
        return this
            .beginUpdateMobilityServiceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateMobilityServiceRequest,
                context)
            .getSyncPoller();
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> updateMobilityServiceAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateMobilityServiceRequest updateMobilityServiceRequest) {
        return beginUpdateMobilityServiceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateMobilityServiceRequest)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<ReplicationProtectedItemInner> updateMobilityServiceAsync(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateMobilityServiceRequest updateMobilityServiceRequest,
        Context context) {
        return beginUpdateMobilityServiceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateMobilityServiceRequest,
                context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner updateMobilityService(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateMobilityServiceRequest updateMobilityServiceRequest) {
        return updateMobilityServiceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateMobilityServiceRequest)
            .block();
    }

    /**
     * Update the mobility service on a protected item.
     *
     * <p>The operation to update(push update) the installed mobility service software on a replication protected item
     * to the latest available version.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param fabricName The name of the fabric containing the protected item.
     * @param protectionContainerName The name of the container containing the protected item.
     * @param replicatedProtectedItemName The name of the protected item on which the agent is to be updated.
     * @param updateMobilityServiceRequest Request to update the mobility service on the protected item.
     * @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 replication protected item.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReplicationProtectedItemInner updateMobilityService(
        String resourceName,
        String resourceGroupName,
        String fabricName,
        String protectionContainerName,
        String replicatedProtectedItemName,
        UpdateMobilityServiceRequest updateMobilityServiceRequest,
        Context context) {
        return updateMobilityServiceAsync(
                resourceName,
                resourceGroupName,
                fabricName,
                protectionContainerName,
                replicatedProtectedItemName,
                updateMobilityServiceRequest,
                context)
            .block();
    }

    /**
     * Gets the list of replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the vault.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param skipToken The pagination token. Possible values: "FabricId" or "FabricId_CloudId" or null.
     * @param filter OData filter options.
     * @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 list of ASR replication protected items in the vault along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ReplicationProtectedItemInner>> listSinglePageAsync(
        String resourceName, String resourceGroupName, String skipToken, String filter) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .list(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            resourceName,
                            resourceGroupName,
                            this.client.getSubscriptionId(),
                            skipToken,
                            filter,
                            accept,
                            context))
            .<PagedResponse<ReplicationProtectedItemInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets the list of replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the vault.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param skipToken The pagination token. Possible values: "FabricId" or "FabricId_CloudId" or null.
     * @param filter OData filter options.
     * @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 list of ASR replication protected items in the vault along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ReplicationProtectedItemInner>> listSinglePageAsync(
        String resourceName, String resourceGroupName, String skipToken, String filter, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter resourceName is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName 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."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                resourceName,
                resourceGroupName,
                this.client.getSubscriptionId(),
                skipToken,
                filter,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Gets the list of replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the vault.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param skipToken The pagination token. Possible values: "FabricId" or "FabricId_CloudId" or null.
     * @param filter OData filter options.
     * @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 list of ASR replication protected items in the vault as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ReplicationProtectedItemInner> listAsync(
        String resourceName, String resourceGroupName, String skipToken, String filter) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceName, resourceGroupName, skipToken, filter),
            nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * Gets the list of replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the vault.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @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 list of ASR replication protected items in the vault as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ReplicationProtectedItemInner> listAsync(String resourceName, String resourceGroupName) {
        final String skipToken = null;
        final String filter = null;
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceName, resourceGroupName, skipToken, filter),
            nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * Gets the list of replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the vault.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param skipToken The pagination token. Possible values: "FabricId" or "FabricId_CloudId" or null.
     * @param filter OData filter options.
     * @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 list of ASR replication protected items in the vault as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<ReplicationProtectedItemInner> listAsync(
        String resourceName, String resourceGroupName, String skipToken, String filter, Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceName, resourceGroupName, skipToken, filter, context),
            nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * Gets the list of replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the vault.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @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 list of ASR replication protected items in the vault as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ReplicationProtectedItemInner> list(String resourceName, String resourceGroupName) {
        final String skipToken = null;
        final String filter = null;
        return new PagedIterable<>(listAsync(resourceName, resourceGroupName, skipToken, filter));
    }

    /**
     * Gets the list of replication protected items.
     *
     * <p>Gets the list of ASR replication protected items in the vault.
     *
     * @param resourceName The name of the recovery services vault.
     * @param resourceGroupName The name of the resource group where the recovery services vault is present.
     * @param skipToken The pagination token. Possible values: "FabricId" or "FabricId_CloudId" or null.
     * @param filter OData filter options.
     * @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 list of ASR replication protected items in the vault as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<ReplicationProtectedItemInner> list(
        String resourceName, String resourceGroupName, String skipToken, String filter, Context context) {
        return new PagedIterable<>(listAsync(resourceName, resourceGroupName, skipToken, filter, context));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return replication protected item collection along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ReplicationProtectedItemInner>> listByReplicationProtectionContainersNextSinglePageAsync(
        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
                        .listByReplicationProtectionContainersNext(
                            nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<ReplicationProtectedItemInner>>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 replication protected item collection along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ReplicationProtectedItemInner>> listByReplicationProtectionContainersNextSinglePageAsync(
        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
            .listByReplicationProtectionContainersNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <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 replication protected item collection along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ReplicationProtectedItemInner>> 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<ReplicationProtectedItemInner>>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 replication protected item collection along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<ReplicationProtectedItemInner>> 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));
    }
}
