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

package com.azure.analytics.synapse.monitoring.implementation;

import com.azure.analytics.synapse.monitoring.models.SparkJobListViewResponse;
import com.azure.analytics.synapse.monitoring.models.SqlQueryStringDataModel;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
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.exception.HttpResponseException;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import reactor.core.publisher.Mono;

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

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

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

    /**
     * The interface defining all the services for MonitoringClientMonitorings to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "MonitoringClientMoni")
    public interface MonitoringsService {
        @Get("/monitoring/workloadTypes/spark/Applications")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<SparkJobListViewResponse>> getSparkJobList(
                @HostParam("endpoint") String endpoint,
                @HeaderParam("x-ms-client-request-id") String xMsClientRequestId,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("/monitoring/workloadTypes/sql/querystring")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<SqlQueryStringDataModel>> getSqlJobQueryString(
                @HostParam("endpoint") String endpoint,
                @HeaderParam("x-ms-client-request-id") String xMsClientRequestId,
                @QueryParam("api-version") String apiVersion,
                @QueryParam("filter") String filter,
                @QueryParam("$orderby") String orderby,
                @QueryParam("skip") String skip,
                @HeaderParam("Accept") String accept,
                Context context);
    }

    /**
     * Get list of spark applications for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of spark applications for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkJobListViewResponse>> getSparkJobListWithResponseAsync(String xMsClientRequestId) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getSparkJobList(
                                this.client.getEndpoint(),
                                xMsClientRequestId,
                                this.client.getApiVersion(),
                                accept,
                                context));
    }

    /**
     * Get list of spark applications for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of spark applications for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkJobListViewResponse>> getSparkJobListWithResponseAsync(
            String xMsClientRequestId, Context context) {
        final String accept = "application/json";
        return service.getSparkJobList(
                this.client.getEndpoint(), xMsClientRequestId, this.client.getApiVersion(), accept, context);
    }

    /**
     * Get list of spark applications for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of spark applications for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkJobListViewResponse> getSparkJobListAsync(String xMsClientRequestId) {
        return getSparkJobListWithResponseAsync(xMsClientRequestId)
                .flatMap(
                        (Response<SparkJobListViewResponse> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Get list of spark applications for the workspace.
     *
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of spark applications for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkJobListViewResponse> getSparkJobListAsync() {
        final String xMsClientRequestId = null;
        return getSparkJobListWithResponseAsync(xMsClientRequestId)
                .flatMap(
                        (Response<SparkJobListViewResponse> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Get list of spark applications for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of spark applications for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkJobListViewResponse> getSparkJobListAsync(String xMsClientRequestId, Context context) {
        return getSparkJobListWithResponseAsync(xMsClientRequestId, context)
                .flatMap(
                        (Response<SparkJobListViewResponse> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Get list of spark applications for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of spark applications for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SparkJobListViewResponse getSparkJobList(String xMsClientRequestId) {
        return getSparkJobListAsync(xMsClientRequestId).block();
    }

    /**
     * Get list of spark applications for the workspace.
     *
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of spark applications for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SparkJobListViewResponse getSparkJobList() {
        final String xMsClientRequestId = null;
        return getSparkJobListAsync(xMsClientRequestId).block();
    }

    /**
     * Get list of spark applications for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of spark applications for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SparkJobListViewResponse> getSparkJobListWithResponse(String xMsClientRequestId, Context context) {
        return getSparkJobListWithResponseAsync(xMsClientRequestId, context).block();
    }

    /**
     * Get SQL OD/DW Query for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @param filter The filter parameter.
     * @param orderby The orderby parameter.
     * @param skip The skip parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return sQL OD/DW Query for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SqlQueryStringDataModel>> getSqlJobQueryStringWithResponseAsync(
            String xMsClientRequestId, String filter, String orderby, String skip) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getSqlJobQueryString(
                                this.client.getEndpoint(),
                                xMsClientRequestId,
                                this.client.getApiVersion(),
                                filter,
                                orderby,
                                skip,
                                accept,
                                context));
    }

    /**
     * Get SQL OD/DW Query for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @param filter The filter parameter.
     * @param orderby The orderby parameter.
     * @param skip The skip parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return sQL OD/DW Query for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SqlQueryStringDataModel>> getSqlJobQueryStringWithResponseAsync(
            String xMsClientRequestId, String filter, String orderby, String skip, Context context) {
        final String accept = "application/json";
        return service.getSqlJobQueryString(
                this.client.getEndpoint(),
                xMsClientRequestId,
                this.client.getApiVersion(),
                filter,
                orderby,
                skip,
                accept,
                context);
    }

    /**
     * Get SQL OD/DW Query for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @param filter The filter parameter.
     * @param orderby The orderby parameter.
     * @param skip The skip parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return sQL OD/DW Query for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SqlQueryStringDataModel> getSqlJobQueryStringAsync(
            String xMsClientRequestId, String filter, String orderby, String skip) {
        return getSqlJobQueryStringWithResponseAsync(xMsClientRequestId, filter, orderby, skip)
                .flatMap(
                        (Response<SqlQueryStringDataModel> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Get SQL OD/DW Query for the workspace.
     *
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return sQL OD/DW Query for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SqlQueryStringDataModel> getSqlJobQueryStringAsync() {
        final String xMsClientRequestId = null;
        final String filter = null;
        final String orderby = null;
        final String skip = null;
        return getSqlJobQueryStringWithResponseAsync(xMsClientRequestId, filter, orderby, skip)
                .flatMap(
                        (Response<SqlQueryStringDataModel> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Get SQL OD/DW Query for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @param filter The filter parameter.
     * @param orderby The orderby parameter.
     * @param skip The skip parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return sQL OD/DW Query for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SqlQueryStringDataModel> getSqlJobQueryStringAsync(
            String xMsClientRequestId, String filter, String orderby, String skip, Context context) {
        return getSqlJobQueryStringWithResponseAsync(xMsClientRequestId, filter, orderby, skip, context)
                .flatMap(
                        (Response<SqlQueryStringDataModel> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Get SQL OD/DW Query for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @param filter The filter parameter.
     * @param orderby The orderby parameter.
     * @param skip The skip parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return sQL OD/DW Query for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SqlQueryStringDataModel getSqlJobQueryString(
            String xMsClientRequestId, String filter, String orderby, String skip) {
        return getSqlJobQueryStringAsync(xMsClientRequestId, filter, orderby, skip).block();
    }

    /**
     * Get SQL OD/DW Query for the workspace.
     *
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return sQL OD/DW Query for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SqlQueryStringDataModel getSqlJobQueryString() {
        final String xMsClientRequestId = null;
        final String filter = null;
        final String orderby = null;
        final String skip = null;
        return getSqlJobQueryStringAsync(xMsClientRequestId, filter, orderby, skip).block();
    }

    /**
     * Get SQL OD/DW Query for the workspace.
     *
     * @param xMsClientRequestId Can provide a guid, which is helpful for debugging and to provide better customer
     *     support.
     * @param filter The filter parameter.
     * @param orderby The orderby parameter.
     * @param skip The skip parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return sQL OD/DW Query for the workspace.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SqlQueryStringDataModel> getSqlJobQueryStringWithResponse(
            String xMsClientRequestId, String filter, String orderby, String skip, Context context) {
        return getSqlJobQueryStringWithResponseAsync(xMsClientRequestId, filter, orderby, skip, context).block();
    }
}
