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

package com.azure.resourcemanager.workloads.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.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.workloads.fluent.SapLandscapeMonitorsClient;
import com.azure.resourcemanager.workloads.fluent.models.SapLandscapeMonitorInner;
import com.azure.resourcemanager.workloads.fluent.models.SapLandscapeMonitorListResultInner;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in SapLandscapeMonitorsClient. */
public final class SapLandscapeMonitorsClientImpl implements SapLandscapeMonitorsClient {
    /** The proxy service used to perform REST calls. */
    private final SapLandscapeMonitorsService service;

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

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

    /**
     * The interface defining all the services for WorkloadsClientSapLandscapeMonitors to be used by the proxy service
     * to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "WorkloadsClientSapLa")
    public interface SapLandscapeMonitorsService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/sapLandscapeMonitor/default")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SapLandscapeMonitorInner>> get(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("monitorName") String monitorName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/sapLandscapeMonitor/default")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SapLandscapeMonitorInner>> create(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("monitorName") String monitorName,
            @BodyParam("application/json") SapLandscapeMonitorInner sapLandscapeMonitorParameter,
            @HeaderParam("Accept") String accept,
            Context context);

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

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/monitors/{monitorName}/sapLandscapeMonitor/default")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SapLandscapeMonitorInner>> update(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("monitorName") String monitorName,
            @BodyParam("application/json") SapLandscapeMonitorInner sapLandscapeMonitorParameter,
            @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapLandscapeMonitorInner>> getWithResponseAsync(
        String resourceGroupName, String monitorName) {
        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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName 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,
                            monitorName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @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 configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapLandscapeMonitorInner>> getWithResponseAsync(
        String resourceGroupName, String monitorName, 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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName 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,
                monitorName,
                accept,
                context);
    }

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapLandscapeMonitorInner> getAsync(String resourceGroupName, String monitorName) {
        return getWithResponseAsync(resourceGroupName, monitorName).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @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 configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SapLandscapeMonitorInner> getWithResponse(
        String resourceGroupName, String monitorName, Context context) {
        return getWithResponseAsync(resourceGroupName, monitorName, context).block();
    }

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapLandscapeMonitorInner get(String resourceGroupName, String monitorName) {
        return getWithResponse(resourceGroupName, monitorName, Context.NONE).getValue();
    }

    /**
     * Creates a SAP Landscape Monitor Dashboard.
     *
     * <p>Creates a SAP Landscape Monitor Dashboard for the specified subscription, resource group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration associated with SAP Landscape Monitor Dashboard along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapLandscapeMonitorInner>> createWithResponseAsync(
        String resourceGroupName, String monitorName, SapLandscapeMonitorInner sapLandscapeMonitorParameter) {
        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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName is required and cannot be null."));
        }
        if (sapLandscapeMonitorParameter == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter sapLandscapeMonitorParameter is required and cannot be null."));
        } else {
            sapLandscapeMonitorParameter.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .create(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            monitorName,
                            sapLandscapeMonitorParameter,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Creates a SAP Landscape Monitor Dashboard.
     *
     * <p>Creates a SAP Landscape Monitor Dashboard for the specified subscription, resource group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @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 configuration associated with SAP Landscape Monitor Dashboard along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapLandscapeMonitorInner>> createWithResponseAsync(
        String resourceGroupName,
        String monitorName,
        SapLandscapeMonitorInner sapLandscapeMonitorParameter,
        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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName is required and cannot be null."));
        }
        if (sapLandscapeMonitorParameter == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter sapLandscapeMonitorParameter is required and cannot be null."));
        } else {
            sapLandscapeMonitorParameter.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .create(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                monitorName,
                sapLandscapeMonitorParameter,
                accept,
                context);
    }

    /**
     * Creates a SAP Landscape Monitor Dashboard.
     *
     * <p>Creates a SAP Landscape Monitor Dashboard for the specified subscription, resource group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration associated with SAP Landscape Monitor Dashboard on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapLandscapeMonitorInner> createAsync(
        String resourceGroupName, String monitorName, SapLandscapeMonitorInner sapLandscapeMonitorParameter) {
        return createWithResponseAsync(resourceGroupName, monitorName, sapLandscapeMonitorParameter)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Creates a SAP Landscape Monitor Dashboard.
     *
     * <p>Creates a SAP Landscape Monitor Dashboard for the specified subscription, resource group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @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 configuration associated with SAP Landscape Monitor Dashboard along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SapLandscapeMonitorInner> createWithResponse(
        String resourceGroupName,
        String monitorName,
        SapLandscapeMonitorInner sapLandscapeMonitorParameter,
        Context context) {
        return createWithResponseAsync(resourceGroupName, monitorName, sapLandscapeMonitorParameter, context).block();
    }

    /**
     * Creates a SAP Landscape Monitor Dashboard.
     *
     * <p>Creates a SAP Landscape Monitor Dashboard for the specified subscription, resource group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration associated with SAP Landscape Monitor Dashboard.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapLandscapeMonitorInner create(
        String resourceGroupName, String monitorName, SapLandscapeMonitorInner sapLandscapeMonitorParameter) {
        return createWithResponse(resourceGroupName, monitorName, sapLandscapeMonitorParameter, Context.NONE)
            .getValue();
    }

    /**
     * Deletes a SAP Landscape Monitor Dashboard.
     *
     * <p>Deletes a SAP Landscape Monitor Dashboard with the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(String resourceGroupName, String monitorName) {
        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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName 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,
                            monitorName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes a SAP Landscape Monitor Dashboard.
     *
     * <p>Deletes a SAP Landscape Monitor Dashboard with the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteWithResponseAsync(
        String resourceGroupName, String monitorName, 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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName 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,
                monitorName,
                accept,
                context);
    }

    /**
     * Deletes a SAP Landscape Monitor Dashboard.
     *
     * <p>Deletes a SAP Landscape Monitor Dashboard with the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(String resourceGroupName, String monitorName) {
        return deleteWithResponseAsync(resourceGroupName, monitorName).flatMap(ignored -> Mono.empty());
    }

    /**
     * Deletes a SAP Landscape Monitor Dashboard.
     *
     * <p>Deletes a SAP Landscape Monitor Dashboard with the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @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}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteWithResponse(String resourceGroupName, String monitorName, Context context) {
        return deleteWithResponseAsync(resourceGroupName, monitorName, context).block();
    }

    /**
     * Deletes a SAP Landscape Monitor Dashboard.
     *
     * <p>Deletes a SAP Landscape Monitor Dashboard with the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @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 monitorName) {
        deleteWithResponse(resourceGroupName, monitorName, Context.NONE);
    }

    /**
     * Patches the SAP Landscape Monitor Dashboard.
     *
     * <p>Patches the SAP Landscape Monitor Dashboard for the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration associated with SAP Landscape Monitor Dashboard along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapLandscapeMonitorInner>> updateWithResponseAsync(
        String resourceGroupName, String monitorName, SapLandscapeMonitorInner sapLandscapeMonitorParameter) {
        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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName is required and cannot be null."));
        }
        if (sapLandscapeMonitorParameter == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter sapLandscapeMonitorParameter is required and cannot be null."));
        } else {
            sapLandscapeMonitorParameter.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            monitorName,
                            sapLandscapeMonitorParameter,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Patches the SAP Landscape Monitor Dashboard.
     *
     * <p>Patches the SAP Landscape Monitor Dashboard for the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @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 configuration associated with SAP Landscape Monitor Dashboard along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapLandscapeMonitorInner>> updateWithResponseAsync(
        String resourceGroupName,
        String monitorName,
        SapLandscapeMonitorInner sapLandscapeMonitorParameter,
        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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName is required and cannot be null."));
        }
        if (sapLandscapeMonitorParameter == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter sapLandscapeMonitorParameter is required and cannot be null."));
        } else {
            sapLandscapeMonitorParameter.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                monitorName,
                sapLandscapeMonitorParameter,
                accept,
                context);
    }

    /**
     * Patches the SAP Landscape Monitor Dashboard.
     *
     * <p>Patches the SAP Landscape Monitor Dashboard for the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration associated with SAP Landscape Monitor Dashboard on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapLandscapeMonitorInner> updateAsync(
        String resourceGroupName, String monitorName, SapLandscapeMonitorInner sapLandscapeMonitorParameter) {
        return updateWithResponseAsync(resourceGroupName, monitorName, sapLandscapeMonitorParameter)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Patches the SAP Landscape Monitor Dashboard.
     *
     * <p>Patches the SAP Landscape Monitor Dashboard for the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @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 configuration associated with SAP Landscape Monitor Dashboard along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SapLandscapeMonitorInner> updateWithResponse(
        String resourceGroupName,
        String monitorName,
        SapLandscapeMonitorInner sapLandscapeMonitorParameter,
        Context context) {
        return updateWithResponseAsync(resourceGroupName, monitorName, sapLandscapeMonitorParameter, context).block();
    }

    /**
     * Patches the SAP Landscape Monitor Dashboard.
     *
     * <p>Patches the SAP Landscape Monitor Dashboard for the specified subscription, resource group, and SAP monitor
     * name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @param sapLandscapeMonitorParameter Request body representing a configuration for Sap Landscape Monitor
     *     Dashboard.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration associated with SAP Landscape Monitor Dashboard.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapLandscapeMonitorInner update(
        String resourceGroupName, String monitorName, SapLandscapeMonitorInner sapLandscapeMonitorParameter) {
        return updateWithResponse(resourceGroupName, monitorName, sapLandscapeMonitorParameter, Context.NONE)
            .getValue();
    }

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapLandscapeMonitorListResultInner>> listWithResponseAsync(
        String resourceGroupName, String monitorName) {
        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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .list(
                            this.client.getEndpoint(),
                            this.client.getApiVersion(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            monitorName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @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 configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapLandscapeMonitorListResultInner>> listWithResponseAsync(
        String resourceGroupName, String monitorName, 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 (monitorName == null) {
            return Mono.error(new IllegalArgumentException("Parameter monitorName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(
                this.client.getEndpoint(),
                this.client.getApiVersion(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                monitorName,
                accept,
                context);
    }

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapLandscapeMonitorListResultInner> listAsync(String resourceGroupName, String monitorName) {
        return listWithResponseAsync(resourceGroupName, monitorName).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @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 configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SapLandscapeMonitorListResultInner> listWithResponse(
        String resourceGroupName, String monitorName, Context context) {
        return listWithResponseAsync(resourceGroupName, monitorName, context).block();
    }

    /**
     * Gets configuration values for Single Pane Of Glass for SAP monitor.
     *
     * <p>Gets configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     * group, and resource name.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param monitorName Name of the SAP monitor resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return configuration values for Single Pane Of Glass for SAP monitor for the specified subscription, resource
     *     group, and resource name.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapLandscapeMonitorListResultInner list(String resourceGroupName, String monitorName) {
        return listWithResponse(resourceGroupName, monitorName, Context.NONE).getValue();
    }
}
