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

com.azure.resourcemanager.migrationdiscoverysap.implementation.ServerInstancesClientImpl 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.ServerInstancesClient;
import com.azure.resourcemanager.migrationdiscoverysap.fluent.models.ServerInstanceInner;
import com.azure.resourcemanager.migrationdiscoverysap.models.ServerInstanceListResult;
import com.azure.resourcemanager.migrationdiscoverysap.models.UpdateServerInstanceRequest;
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 ServerInstancesClient.
 */
public final class ServerInstancesClientImpl implements ServerInstancesClient {
    /**
     * The proxy service used to perform REST calls.
     */
    private final ServerInstancesService service;

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

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

    /**
     * The interface defining all the services for MigrationDiscoverySapMgmtClientServerInstances to be used by the
     * proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "MigrationDiscoverySa")
    public interface ServerInstancesService {
        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances/{sapInstanceName}/serverInstances")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listBySapInstance(@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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances/{sapInstanceName}/serverInstances/{serverInstanceName}")
        @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,
            @PathParam("serverInstanceName") String serverInstanceName, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances/{sapInstanceName}/serverInstances/{serverInstanceName}")
        @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,
            @PathParam("serverInstanceName") String serverInstanceName,
            @BodyParam("application/json") ServerInstanceInner resource, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances/{sapInstanceName}/serverInstances/{serverInstanceName}")
        @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,
            @PathParam("serverInstanceName") String serverInstanceName,
            @BodyParam("application/json") UpdateServerInstanceRequest properties, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapDiscoverySites/{sapDiscoverySiteName}/sapInstances/{sapInstanceName}/serverInstances/{serverInstanceName}")
        @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,
            @PathParam("serverInstanceName") String serverInstanceName, @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Lists the Server Instance resources for the given 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 response of a ServerInstance list operation along with {@link PagedResponse} on successful completion
     * of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySapInstanceSinglePageAsync(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.listBySapInstance(this.client.getEndpoint(), this.client.getApiVersion(),
                this.client.getSubscriptionId(), resourceGroupName, sapDiscoverySiteName, sapInstanceName, 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 Server Instance resources for the given 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 response of a ServerInstance list operation along with {@link PagedResponse} on successful completion
     * of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySapInstanceSinglePageAsync(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
            .listBySapInstance(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(),
                resourceGroupName, sapDiscoverySiteName, sapInstanceName, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Lists the Server Instance resources for the given 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 response of a ServerInstance list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listBySapInstanceAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName) {
        return new PagedFlux<>(
            () -> listBySapInstanceSinglePageAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName),
            nextLink -> listBySapInstanceNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the Server Instance resources for the given 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 response of a ServerInstance list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listBySapInstanceAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, Context context) {
        return new PagedFlux<>(
            () -> listBySapInstanceSinglePageAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context),
            nextLink -> listBySapInstanceNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists the Server Instance resources for the given 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 response of a ServerInstance list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listBySapInstance(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName) {
        return new PagedIterable<>(listBySapInstanceAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName));
    }

    /**
     * Lists the Server Instance resources for the given 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 response of a ServerInstance list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listBySapInstance(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, Context context) {
        return new PagedIterable<>(
            listBySapInstanceAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context));
    }

    /**
     * Gets the Server 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 serverInstanceName The name of the Server 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 Server 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, String serverInstanceName) {
        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 (serverInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter serverInstanceName 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,
                serverInstanceName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets the Server 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 serverInstanceName The name of the Server 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 Server 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, String serverInstanceName, 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 (serverInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter serverInstanceName 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, serverInstanceName, accept, context);
    }

    /**
     * Gets the Server 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 serverInstanceName The name of the Server 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 Server Instance resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, String serverInstanceName) {
        return getWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets the Server 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 serverInstanceName The name of the Server 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 Server Instance resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getWithResponse(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, String serverInstanceName, Context context) {
        return getWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName,
            context).block();
    }

    /**
     * Gets the Server 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 serverInstanceName The name of the Server 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 Server Instance resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ServerInstanceInner get(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName,
        String serverInstanceName) {
        return getWithResponse(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName,
            Context.NONE).getValue();
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server 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, String serverInstanceName, ServerInstanceInner 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 (serverInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter serverInstanceName 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,
                serverInstanceName, resource, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server 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, String serverInstanceName, ServerInstanceInner 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 (serverInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter serverInstanceName 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, serverInstanceName, resource, accept, context);
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server Instance resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ServerInstanceInner> beginCreateAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, String serverInstanceName, ServerInstanceInner resource) {
        Mono>> mono = createWithResponseAsync(resourceGroupName, sapDiscoverySiteName,
            sapInstanceName, serverInstanceName, resource);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            ServerInstanceInner.class, ServerInstanceInner.class, this.client.getContext());
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server Instance resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ServerInstanceInner> beginCreateAsync(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, String serverInstanceName, ServerInstanceInner resource,
        Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono = createWithResponseAsync(resourceGroupName, sapDiscoverySiteName,
            sapInstanceName, serverInstanceName, resource, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            ServerInstanceInner.class, ServerInstanceInner.class, context);
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server Instance resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ServerInstanceInner> beginCreate(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, String serverInstanceName, ServerInstanceInner resource) {
        return this
            .beginCreateAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, resource)
            .getSyncPoller();
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server Instance resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ServerInstanceInner> beginCreate(String resourceGroupName,
        String sapDiscoverySiteName, String sapInstanceName, String serverInstanceName, ServerInstanceInner resource,
        Context context) {
        return this.beginCreateAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName,
            resource, context).getSyncPoller();
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server Instance resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, String serverInstanceName, ServerInstanceInner resource) {
        return beginCreateAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, resource)
            .last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server Instance resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, String serverInstanceName, ServerInstanceInner resource, Context context) {
        return beginCreateAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, resource,
            context).last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server Instance resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ServerInstanceInner create(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName,
        String serverInstanceName, ServerInstanceInner resource) {
        return createAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, resource)
            .block();
    }

    /**
     * Creates the Server 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 serverInstanceName The name of the Server 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 Server Instance resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ServerInstanceInner create(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName,
        String serverInstanceName, ServerInstanceInner resource, Context context) {
        return createAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, resource,
            context).block();
    }

    /**
     * Updates the Server Instance resource. This operation on a 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 serverInstanceName The name of the Server 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 Server 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, String serverInstanceName,
        UpdateServerInstanceRequest 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 (serverInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter serverInstanceName 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,
                serverInstanceName, properties, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the Server Instance resource. This operation on a 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 serverInstanceName The name of the Server 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 Server 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, String serverInstanceName,
        UpdateServerInstanceRequest 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 (serverInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter serverInstanceName 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, serverInstanceName, properties, accept, context);
    }

    /**
     * Updates the Server Instance resource. This operation on a 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 serverInstanceName The name of the Server 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 Server Instance resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono updateAsync(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, String serverInstanceName, UpdateServerInstanceRequest properties) {
        return updateWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName,
            properties).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Updates the Server Instance resource. This operation on a 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 serverInstanceName The name of the Server 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 Server Instance resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response updateWithResponse(String resourceGroupName, String sapDiscoverySiteName,
        String sapInstanceName, String serverInstanceName, UpdateServerInstanceRequest properties, Context context) {
        return updateWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName,
            properties, context).block();
    }

    /**
     * Updates the Server Instance resource. This operation on a 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 serverInstanceName The name of the Server 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 Server Instance resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ServerInstanceInner update(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName,
        String serverInstanceName, UpdateServerInstanceRequest properties) {
        return updateWithResponse(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName,
            properties, Context.NONE).getValue();
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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, String serverInstanceName) {
        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 (serverInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter serverInstanceName 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,
                serverInstanceName, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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, String serverInstanceName, 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 (serverInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter serverInstanceName 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, serverInstanceName, accept, context);
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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, String serverInstanceName) {
        Mono>> mono
            = deleteWithResponseAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            this.client.getContext());
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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, String serverInstanceName, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono = deleteWithResponseAsync(resourceGroupName, sapDiscoverySiteName,
            sapInstanceName, serverInstanceName, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            context);
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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, String serverInstanceName) {
        return this.beginDeleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName)
            .getSyncPoller();
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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, String serverInstanceName, Context context) {
        return this
            .beginDeleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, context)
            .getSyncPoller();
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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,
        String serverInstanceName) {
        return beginDeleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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,
        String serverInstanceName, Context context) {
        return beginDeleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, context)
            .last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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,
        String serverInstanceName) {
        deleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName).block();
    }

    /**
     * Deletes the Server 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 serverInstanceName The name of the Server 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,
        String serverInstanceName, Context context) {
        deleteAsync(resourceGroupName, sapDiscoverySiteName, sapInstanceName, serverInstanceName, 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 ServerInstance list operation along with {@link PagedResponse} on successful completion
     * of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySapInstanceNextSinglePageAsync(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.listBySapInstanceNext(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 ServerInstance list operation along with {@link PagedResponse} on successful completion
     * of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySapInstanceNextSinglePageAsync(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.listBySapInstanceNext(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