All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.migrationdiscoverysap.implementation.SapInstancesClientImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for MigrationDiscoverySap Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Migration Discovery SAP Client. Package tag package-preview-2023-10.

There is a newer version: 1.0.0-beta.2
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.migrationdiscoverysap.implementation;

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

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

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

    /**
     * The interface defining all the services for MigrationDiscoverySapMgmtClientSapInstances to be used by the proxy
     * service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "MigrationDiscoverySa")
    public interface SapInstancesService {
        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listBySapDiscoverySite(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapDiscoverySiteName") String sapDiscoverySiteName, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances/{sapInstanceName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> get(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapDiscoverySiteName") String sapDiscoverySiteName,
            @PathParam("sapInstanceName") String sapInstanceName, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances/{sapInstanceName}")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> create(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapDiscoverySiteName") String sapDiscoverySiteName,
            @PathParam("sapInstanceName") String sapInstanceName,
            @BodyParam("application/json") SapInstanceInner resource, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances/{sapInstanceName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> update(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapDiscoverySiteName") String sapDiscoverySiteName,
            @PathParam("sapInstanceName") String sapInstanceName,
            @BodyParam("application/json") SapInstanceTagsUpdate properties, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances/{sapInstanceName}")
        @ExpectedResponses({ 200, 202, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> delete(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapDiscoverySiteName") String sapDiscoverySiteName,
            @PathParam("sapInstanceName") String sapInstanceName, @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Lists the SAP Instance resources for the given SAP Migration discovery site resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a SAPInstance list operation along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySapDiscoverySiteSinglePageAsync(String resourceGroupName,
        String sapDiscoverySiteName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listBySapDiscoverySite(this.client.getEndpoint(), this.client.getApiVersion(),
                    this.client.getSubscriptionId(), resourceGroupName, sapDiscoverySiteName, accept, context))
            .>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()));
    }

    /**
     * Lists the SAP Instance resources for the given SAP Migration discovery site resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a SAPInstance list operation along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySapDiscoverySiteSinglePageAsync(String resourceGroupName,
        String sapDiscoverySiteName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listBySapDiscoverySite(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), resourceGroupName, sapDiscoverySiteName, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Lists the SAP Instance resources for the given SAP Migration discovery site resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a SAPInstance list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listBySapDiscoverySiteAsync(String resourceGroupName,
        String sapDiscoverySiteName) {
        return new PagedFlux<>(() -> listBySapDiscoverySiteSinglePageAsync(resourceGroupName, sapDiscoverySiteName),
            nextLink -> listBySapDiscoverySiteNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the SAP Instance resources for the given SAP Migration discovery site resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a SAPInstance list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listBySapDiscoverySiteAsync(String resourceGroupName,
        String sapDiscoverySiteName, Context context) {
        return new PagedFlux<>(
            () -> listBySapDiscoverySiteSinglePageAsync(resourceGroupName, sapDiscoverySiteName, context),
            nextLink -> listBySapDiscoverySiteNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists the SAP Instance resources for the given SAP Migration discovery site resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a SAPInstance list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listBySapDiscoverySite(String resourceGroupName,
        String sapDiscoverySiteName) {
        return new PagedIterable<>(listBySapDiscoverySiteAsync(resourceGroupName, sapDiscoverySiteName));
    }

    /**
     * Lists the SAP Instance resources for the given SAP Migration discovery site resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response of a SAPInstance list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listBySapDiscoverySite(String resourceGroupName, String sapDiscoverySiteName,
        Context context) {
        return new PagedIterable<>(listBySapDiscoverySiteAsync(resourceGroupName, sapDiscoverySiteName, context));
    }

    /**
     * Gets the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 SAP Instance resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        if (sapInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), resourceGroupName, sapDiscoverySiteName, sapInstanceName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @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 SAP Instance resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        if (sapInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(),
            resourceGroupName, sapDiscoverySiteName, sapInstanceName, accept, context);
    }

    /**
     * Gets the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 SAP Instance resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName) {
        return getWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @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 SAP Instance resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getWithResponse(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, Context context) {
        return getWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context).block();
    }

    /**
     * Gets the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 SAP Instance resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapInstanceInner get(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName) {
        return getWithResponse(resourceGroupName, sapDiscoverySiteName, sapInstanceName, Context.NONE).getValue();
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createWithResponseAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, SapInstanceInner resource) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        if (sapInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapInstanceName is required and cannot be null."));
        }
        if (resource == null) {
            return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.create(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource,
                accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createWithResponseAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, SapInstanceInner resource, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        if (sapInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapInstanceName is required and cannot be null."));
        }
        if (resource == null) {
            return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null."));
        } else {
            resource.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.create(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(),
            resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource, accept, context);
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of define the SAP Instance resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, SapInstanceInner> beginCreateAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, SapInstanceInner resource) {
        Mono>> mono
            = createWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            SapInstanceInner.class, SapInstanceInner.class, this.client.getContext());
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of define the SAP Instance resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, SapInstanceInner> beginCreateAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, SapInstanceInner resource, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = createWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            SapInstanceInner.class, SapInstanceInner.class, context);
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of define the SAP Instance resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, SapInstanceInner> beginCreate(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, SapInstanceInner resource) {
        return this.beginCreateAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource)
            .getSyncPoller();
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of define the SAP Instance resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, SapInstanceInner> beginCreate(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, SapInstanceInner resource, Context context) {
        return this.beginCreateAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource, context)
            .getSyncPoller();
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, SapInstanceInner resource) {
        return beginCreateAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, SapInstanceInner resource, Context context) {
        return beginCreateAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapInstanceInner create(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName,
        SapInstanceInner resource) {
        return createAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource).block();
    }

    /**
     * Creates the SAP Instance resource. <br><br>This will be used by service only. PUT operation on this
     * resource by end user will return a Bad Request error.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param resource Resource create parameters.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapInstanceInner create(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName,
        SapInstanceInner resource, Context context) {
        return createAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, resource, context).block();
    }

    /**
     * Updates the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param properties The resource properties to be updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> updateWithResponseAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, SapInstanceTagsUpdate properties) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        if (sapInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapInstanceName is required and cannot be null."));
        }
        if (properties == null) {
            return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null."));
        } else {
            properties.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), resourceGroupName, sapDiscoverySiteName, sapInstanceName, properties,
                accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param properties The resource properties to be updated.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> updateWithResponseAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, SapInstanceTagsUpdate properties, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        if (sapInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapInstanceName is required and cannot be null."));
        }
        if (properties == null) {
            return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null."));
        } else {
            properties.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(),
            resourceGroupName, sapDiscoverySiteName, sapInstanceName, properties, accept, context);
    }

    /**
     * Updates the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param properties The resource properties to be updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono updateAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, SapInstanceTagsUpdate properties) {
        return updateWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, properties)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Updates the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param properties The resource properties to be updated.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response updateWithResponse(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, SapInstanceTagsUpdate properties, Context context) {
        return updateWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, properties, context)
            .block();
    }

    /**
     * Updates the SAP Instance resource.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param properties The resource properties to be updated.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return define the SAP Instance resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapInstanceInner update(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName,
        SapInstanceTagsUpdate properties) {
        return updateWithResponse(resourceGroupName, sapDiscoverySiteName, sapInstanceName, properties, Context.NONE)
            .getValue();
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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>> deleteWithResponseAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        if (sapInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil.withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(),
            this.client.getSubscriptionId(), resourceGroupName, sapDiscoverySiteName, sapInstanceName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @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>> deleteWithResponseAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapDiscoverySiteName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapDiscoverySiteName is required and cannot be null."));
        }
        if (sapInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter sapInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(),
            resourceGroupName, sapDiscoverySiteName, sapInstanceName, accept, context);
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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, Void> beginDeleteAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName) {
        Mono>> mono
            = deleteWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            this.client.getContext());
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @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, Void> beginDeleteAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = deleteWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            context);
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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, Void> beginDelete(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName) {
        return this.beginDeleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName).getSyncPoller();
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @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, Void> beginDelete(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, Context context) {
        return this.beginDeleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context).getSyncPoller();
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 deleteAsync(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName) {
        return beginDeleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @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 deleteAsync(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName,
        Context context) {
        return beginDeleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName) {
        deleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName).block();
    }

    /**
     * Deletes the SAP Instance resource. <br><br>This will be used by service only. Delete operation on
     * this resource by end user will return a Bad Request error. You can delete the parent resource, which is the SAP
     * Migration discovery site resource, using the delete operation on it.
     * 
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapDiscoverySiteName The name of the discovery site resource for SAP Migration.
     * @param sapInstanceName The name of SAP Instance resource for SAP Migration.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName, Context context) {
        deleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context).block();
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy