// 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.artifacts.implementation;

import com.azure.analytics.synapse.artifacts.models.ArtifactRenameRequest;
import com.azure.analytics.synapse.artifacts.models.CloudErrorException;
import com.azure.analytics.synapse.artifacts.models.SparkBatchJob;
import com.azure.analytics.synapse.artifacts.models.SparkJobDefinitionResource;
import com.azure.analytics.synapse.artifacts.models.SparkJobDefinitionsListResponse;
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.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Post;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.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 SparkJobDefinitions. */
public final class SparkJobDefinitionsImpl {
    /** The proxy service used to perform REST calls. */
    private final SparkJobDefinitionsService service;

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

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

    /**
     * The interface defining all the services for ArtifactsClientSparkJobDefinitions to be used by the proxy service to
     * perform REST calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "ArtifactsClientSpark")
    public interface SparkJobDefinitionsService {
        @Get("/sparkJobDefinitions")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<SparkJobDefinitionsListResponse>> getSparkJobDefinitionsByWorkspace(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                Context context);

        @Put("/sparkJobDefinitions/{sparkJobDefinitionName}")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<SparkJobDefinitionResource>> createOrUpdateSparkJobDefinition(
                @HostParam("endpoint") String endpoint,
                @PathParam("sparkJobDefinitionName") String sparkJobDefinitionName,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("If-Match") String ifMatch,
                @BodyParam("application/json") SparkJobDefinitionResource sparkJobDefinition,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("/sparkJobDefinitions/{sparkJobDefinitionName}")
        @ExpectedResponses({200, 304})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<SparkJobDefinitionResource>> getSparkJobDefinition(
                @HostParam("endpoint") String endpoint,
                @PathParam("sparkJobDefinitionName") String sparkJobDefinitionName,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("If-None-Match") String ifNoneMatch,
                @HeaderParam("Accept") String accept,
                Context context);

        @Delete("/sparkJobDefinitions/{sparkJobDefinitionName}")
        @ExpectedResponses({200, 202, 204})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<Void>> deleteSparkJobDefinition(
                @HostParam("endpoint") String endpoint,
                @PathParam("sparkJobDefinitionName") String sparkJobDefinitionName,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                Context context);

        @Post("/sparkJobDefinitions/{sparkJobDefinitionName}/execute")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<SparkBatchJob>> executeSparkJobDefinition(
                @HostParam("endpoint") String endpoint,
                @PathParam("sparkJobDefinitionName") String sparkJobDefinitionName,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                Context context);

        @Post("/sparkJobDefinitions/{sparkJobDefinitionName}/rename")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<Void>> renameSparkJobDefinition(
                @HostParam("endpoint") String endpoint,
                @PathParam("sparkJobDefinitionName") String sparkJobDefinitionName,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") ArtifactRenameRequest request,
                @HeaderParam("Accept") String accept,
                Context context);

        @Post("/debugSparkJobDefinition")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<SparkBatchJob>> debugSparkJobDefinition(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") SparkJobDefinitionResource sparkJobDefinitionAzureResource,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<SparkJobDefinitionsListResponse>> getSparkJobDefinitionsByWorkspaceNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                Context context);
    }

    /**
     * Lists spark job definitions.
     *
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<SparkJobDefinitionResource>> getSparkJobDefinitionsByWorkspaceSinglePageAsync() {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.getSparkJobDefinitionsByWorkspace(
                                        this.client.getEndpoint(), apiVersion, accept, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Lists spark job definitions.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<SparkJobDefinitionResource>> getSparkJobDefinitionsByWorkspaceSinglePageAsync(
            Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.getSparkJobDefinitionsByWorkspace(this.client.getEndpoint(), apiVersion, accept, context)
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Lists spark job definitions.
     *
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<SparkJobDefinitionResource> getSparkJobDefinitionsByWorkspaceAsync() {
        return new PagedFlux<>(
                () -> getSparkJobDefinitionsByWorkspaceSinglePageAsync(),
                nextLink -> getSparkJobDefinitionsByWorkspaceNextSinglePageAsync(nextLink));
    }

    /**
     * Lists spark job definitions.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<SparkJobDefinitionResource> getSparkJobDefinitionsByWorkspaceAsync(Context context) {
        return new PagedFlux<>(
                () -> getSparkJobDefinitionsByWorkspaceSinglePageAsync(context),
                nextLink -> getSparkJobDefinitionsByWorkspaceNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists spark job definitions.
     *
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse<SparkJobDefinitionResource> getSparkJobDefinitionsByWorkspaceSinglePage() {
        return getSparkJobDefinitionsByWorkspaceSinglePageAsync().block();
    }

    /**
     * Lists spark job definitions.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse<SparkJobDefinitionResource> getSparkJobDefinitionsByWorkspaceSinglePage(Context context) {
        return getSparkJobDefinitionsByWorkspaceSinglePageAsync(context).block();
    }

    /**
     * Lists spark job definitions.
     *
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<SparkJobDefinitionResource> getSparkJobDefinitionsByWorkspace() {
        return new PagedIterable<>(getSparkJobDefinitionsByWorkspaceAsync());
    }

    /**
     * Lists spark job definitions.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<SparkJobDefinitionResource> getSparkJobDefinitionsByWorkspace(Context context) {
        return new PagedIterable<>(getSparkJobDefinitionsByWorkspaceAsync(context));
    }

    /**
     * Creates or updates a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param sparkJobDefinition Spark Job Definition resource definition.
     * @param ifMatch ETag of the Spark Job Definition entity. Should only be specified for update, for which it should
     *     match existing entity or can be * for unconditional update.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return spark job definition resource type along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkJobDefinitionResource>> createOrUpdateSparkJobDefinitionWithResponseAsync(
            String sparkJobDefinitionName, SparkJobDefinitionResource sparkJobDefinition, String ifMatch) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createOrUpdateSparkJobDefinition(
                                this.client.getEndpoint(),
                                sparkJobDefinitionName,
                                apiVersion,
                                ifMatch,
                                sparkJobDefinition,
                                accept,
                                context));
    }

    /**
     * Creates or updates a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param sparkJobDefinition Spark Job Definition resource definition.
     * @param ifMatch ETag of the Spark Job Definition entity. Should only be specified for update, for which it should
     *     match existing entity or can be * for unconditional update.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return spark job definition resource type along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkJobDefinitionResource>> createOrUpdateSparkJobDefinitionWithResponseAsync(
            String sparkJobDefinitionName,
            SparkJobDefinitionResource sparkJobDefinition,
            String ifMatch,
            Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.createOrUpdateSparkJobDefinition(
                this.client.getEndpoint(),
                sparkJobDefinitionName,
                apiVersion,
                ifMatch,
                sparkJobDefinition,
                accept,
                context);
    }

    /**
     * Creates or updates a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param sparkJobDefinition Spark Job Definition resource definition.
     * @param ifMatch ETag of the Spark Job Definition entity. Should only be specified for update, for which it should
     *     match existing entity or can be * for unconditional update.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return spark job definition resource type on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkJobDefinitionResource> createOrUpdateSparkJobDefinitionAsync(
            String sparkJobDefinitionName, SparkJobDefinitionResource sparkJobDefinition, String ifMatch) {
        return createOrUpdateSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, sparkJobDefinition, ifMatch)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Creates or updates a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param sparkJobDefinition Spark Job Definition resource definition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return spark job definition resource type on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkJobDefinitionResource> createOrUpdateSparkJobDefinitionAsync(
            String sparkJobDefinitionName, SparkJobDefinitionResource sparkJobDefinition) {
        final String ifMatch = null;
        return createOrUpdateSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, sparkJobDefinition, ifMatch)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Creates or updates a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param sparkJobDefinition Spark Job Definition resource definition.
     * @param ifMatch ETag of the Spark Job Definition entity. Should only be specified for update, for which it should
     *     match existing entity or can be * for unconditional update.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return spark job definition resource type on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkJobDefinitionResource> createOrUpdateSparkJobDefinitionAsync(
            String sparkJobDefinitionName,
            SparkJobDefinitionResource sparkJobDefinition,
            String ifMatch,
            Context context) {
        return createOrUpdateSparkJobDefinitionWithResponseAsync(
                        sparkJobDefinitionName, sparkJobDefinition, ifMatch, context)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Creates or updates a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param sparkJobDefinition Spark Job Definition resource definition.
     * @param ifMatch ETag of the Spark Job Definition entity. Should only be specified for update, for which it should
     *     match existing entity or can be * for unconditional update.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return spark job definition resource type along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SparkJobDefinitionResource> createOrUpdateSparkJobDefinitionWithResponse(
            String sparkJobDefinitionName,
            SparkJobDefinitionResource sparkJobDefinition,
            String ifMatch,
            Context context) {
        return createOrUpdateSparkJobDefinitionWithResponseAsync(
                        sparkJobDefinitionName, sparkJobDefinition, ifMatch, context)
                .block();
    }

    /**
     * Creates or updates a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param sparkJobDefinition Spark Job Definition resource definition.
     * @param ifMatch ETag of the Spark Job Definition entity. Should only be specified for update, for which it should
     *     match existing entity or can be * for unconditional update.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return spark job definition resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SparkJobDefinitionResource createOrUpdateSparkJobDefinition(
            String sparkJobDefinitionName, SparkJobDefinitionResource sparkJobDefinition, String ifMatch) {
        return createOrUpdateSparkJobDefinitionWithResponse(
                        sparkJobDefinitionName, sparkJobDefinition, ifMatch, Context.NONE)
                .getValue();
    }

    /**
     * Creates or updates a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param sparkJobDefinition Spark Job Definition resource definition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return spark job definition resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SparkJobDefinitionResource createOrUpdateSparkJobDefinition(
            String sparkJobDefinitionName, SparkJobDefinitionResource sparkJobDefinition) {
        final String ifMatch = null;
        return createOrUpdateSparkJobDefinitionWithResponse(
                        sparkJobDefinitionName, sparkJobDefinition, ifMatch, Context.NONE)
                .getValue();
    }

    /**
     * Gets a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param ifNoneMatch ETag of the Spark Job Definition entity. Should only be specified for get. If the ETag matches
     *     the existing entity tag, or if * was provided, then no content will be returned.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Spark Job Definition along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkJobDefinitionResource>> getSparkJobDefinitionWithResponseAsync(
            String sparkJobDefinitionName, String ifNoneMatch) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getSparkJobDefinition(
                                this.client.getEndpoint(),
                                sparkJobDefinitionName,
                                apiVersion,
                                ifNoneMatch,
                                accept,
                                context));
    }

    /**
     * Gets a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param ifNoneMatch ETag of the Spark Job Definition entity. Should only be specified for get. If the ETag matches
     *     the existing entity tag, or if * was provided, then no content will be returned.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Spark Job Definition along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkJobDefinitionResource>> getSparkJobDefinitionWithResponseAsync(
            String sparkJobDefinitionName, String ifNoneMatch, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.getSparkJobDefinition(
                this.client.getEndpoint(), sparkJobDefinitionName, apiVersion, ifNoneMatch, accept, context);
    }

    /**
     * Gets a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param ifNoneMatch ETag of the Spark Job Definition entity. Should only be specified for get. If the ETag matches
     *     the existing entity tag, or if * was provided, then no content will be returned.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Spark Job Definition on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkJobDefinitionResource> getSparkJobDefinitionAsync(
            String sparkJobDefinitionName, String ifNoneMatch) {
        return getSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, ifNoneMatch)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Spark Job Definition on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkJobDefinitionResource> getSparkJobDefinitionAsync(String sparkJobDefinitionName) {
        final String ifNoneMatch = null;
        return getSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, ifNoneMatch)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param ifNoneMatch ETag of the Spark Job Definition entity. Should only be specified for get. If the ETag matches
     *     the existing entity tag, or if * was provided, then no content will be returned.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Spark Job Definition on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkJobDefinitionResource> getSparkJobDefinitionAsync(
            String sparkJobDefinitionName, String ifNoneMatch, Context context) {
        return getSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, ifNoneMatch, context)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param ifNoneMatch ETag of the Spark Job Definition entity. Should only be specified for get. If the ETag matches
     *     the existing entity tag, or if * was provided, then no content will be returned.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Spark Job Definition along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SparkJobDefinitionResource> getSparkJobDefinitionWithResponse(
            String sparkJobDefinitionName, String ifNoneMatch, Context context) {
        return getSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, ifNoneMatch, context).block();
    }

    /**
     * Gets a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param ifNoneMatch ETag of the Spark Job Definition entity. Should only be specified for get. If the ETag matches
     *     the existing entity tag, or if * was provided, then no content will be returned.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Spark Job Definition.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SparkJobDefinitionResource getSparkJobDefinition(String sparkJobDefinitionName, String ifNoneMatch) {
        return getSparkJobDefinitionWithResponse(sparkJobDefinitionName, ifNoneMatch, Context.NONE).getValue();
    }

    /**
     * Gets a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Spark Job Definition.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SparkJobDefinitionResource getSparkJobDefinition(String sparkJobDefinitionName) {
        final String ifNoneMatch = null;
        return getSparkJobDefinitionWithResponse(sparkJobDefinitionName, ifNoneMatch, Context.NONE).getValue();
    }

    /**
     * Deletes a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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)
    public Mono<Response<Void>> deleteSparkJobDefinitionWithResponseAsync(String sparkJobDefinitionName) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.deleteSparkJobDefinition(
                                this.client.getEndpoint(), sparkJobDefinitionName, apiVersion, accept, context));
    }

    /**
     * Deletes a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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)
    public Mono<Response<Void>> deleteSparkJobDefinitionWithResponseAsync(
            String sparkJobDefinitionName, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.deleteSparkJobDefinition(
                this.client.getEndpoint(), sparkJobDefinitionName, apiVersion, accept, context);
    }

    /**
     * Deletes a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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)
    public Mono<Void> deleteSparkJobDefinitionAsync(String sparkJobDefinitionName) {
        return deleteSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName).flatMap(ignored -> Mono.empty());
    }

    /**
     * Deletes a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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)
    public Mono<Void> deleteSparkJobDefinitionAsync(String sparkJobDefinitionName, Context context) {
        return deleteSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, context)
                .flatMap(ignored -> Mono.empty());
    }

    /**
     * Deletes a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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> deleteSparkJobDefinitionWithResponse(String sparkJobDefinitionName, Context context) {
        return deleteSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, context).block();
    }

    /**
     * Deletes a Spark Job Definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 deleteSparkJobDefinition(String sparkJobDefinitionName) {
        deleteSparkJobDefinitionWithResponse(sparkJobDefinitionName, Context.NONE);
    }

    /**
     * Executes the spark job definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkBatchJob>> executeSparkJobDefinitionWithResponseAsync(String sparkJobDefinitionName) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.executeSparkJobDefinition(
                                this.client.getEndpoint(), sparkJobDefinitionName, apiVersion, accept, context));
    }

    /**
     * Executes the spark job definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkBatchJob>> executeSparkJobDefinitionWithResponseAsync(
            String sparkJobDefinitionName, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.executeSparkJobDefinition(
                this.client.getEndpoint(), sparkJobDefinitionName, apiVersion, accept, context);
    }

    /**
     * Executes the spark job definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkBatchJob> executeSparkJobDefinitionAsync(String sparkJobDefinitionName) {
        return executeSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Executes the spark job definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkBatchJob> executeSparkJobDefinitionAsync(String sparkJobDefinitionName, Context context) {
        return executeSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, context)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Executes the spark job definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SparkBatchJob> executeSparkJobDefinitionWithResponse(
            String sparkJobDefinitionName, Context context) {
        return executeSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, context).block();
    }

    /**
     * Executes the spark job definition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SparkBatchJob executeSparkJobDefinition(String sparkJobDefinitionName) {
        return executeSparkJobDefinitionWithResponse(sparkJobDefinitionName, Context.NONE).getValue();
    }

    /**
     * Renames a sparkJobDefinition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param request proposed new name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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)
    public Mono<Response<Void>> renameSparkJobDefinitionWithResponseAsync(
            String sparkJobDefinitionName, ArtifactRenameRequest request) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.renameSparkJobDefinition(
                                this.client.getEndpoint(),
                                sparkJobDefinitionName,
                                apiVersion,
                                request,
                                accept,
                                context));
    }

    /**
     * Renames a sparkJobDefinition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param request proposed new name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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)
    public Mono<Response<Void>> renameSparkJobDefinitionWithResponseAsync(
            String sparkJobDefinitionName, ArtifactRenameRequest request, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.renameSparkJobDefinition(
                this.client.getEndpoint(), sparkJobDefinitionName, apiVersion, request, accept, context);
    }

    /**
     * Renames a sparkJobDefinition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param request proposed new name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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)
    public Mono<Void> renameSparkJobDefinitionAsync(String sparkJobDefinitionName, ArtifactRenameRequest request) {
        return renameSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, request)
                .flatMap(ignored -> Mono.empty());
    }

    /**
     * Renames a sparkJobDefinition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param request proposed new name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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)
    public Mono<Void> renameSparkJobDefinitionAsync(
            String sparkJobDefinitionName, ArtifactRenameRequest request, Context context) {
        return renameSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, request, context)
                .flatMap(ignored -> Mono.empty());
    }

    /**
     * Renames a sparkJobDefinition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param request proposed new name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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> renameSparkJobDefinitionWithResponse(
            String sparkJobDefinitionName, ArtifactRenameRequest request, Context context) {
        return renameSparkJobDefinitionWithResponseAsync(sparkJobDefinitionName, request, context).block();
    }

    /**
     * Renames a sparkJobDefinition.
     *
     * @param sparkJobDefinitionName The spark job definition name.
     * @param request proposed new name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 renameSparkJobDefinition(String sparkJobDefinitionName, ArtifactRenameRequest request) {
        renameSparkJobDefinitionWithResponse(sparkJobDefinitionName, request, Context.NONE);
    }

    /**
     * Debug the spark job definition.
     *
     * @param sparkJobDefinitionAzureResource Spark Job Definition resource definition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkBatchJob>> debugSparkJobDefinitionWithResponseAsync(
            SparkJobDefinitionResource sparkJobDefinitionAzureResource) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.debugSparkJobDefinition(
                                this.client.getEndpoint(),
                                apiVersion,
                                sparkJobDefinitionAzureResource,
                                accept,
                                context));
    }

    /**
     * Debug the spark job definition.
     *
     * @param sparkJobDefinitionAzureResource Spark Job Definition resource definition.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<SparkBatchJob>> debugSparkJobDefinitionWithResponseAsync(
            SparkJobDefinitionResource sparkJobDefinitionAzureResource, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.debugSparkJobDefinition(
                this.client.getEndpoint(), apiVersion, sparkJobDefinitionAzureResource, accept, context);
    }

    /**
     * Debug the spark job definition.
     *
     * @param sparkJobDefinitionAzureResource Spark Job Definition resource definition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkBatchJob> debugSparkJobDefinitionAsync(
            SparkJobDefinitionResource sparkJobDefinitionAzureResource) {
        return debugSparkJobDefinitionWithResponseAsync(sparkJobDefinitionAzureResource)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Debug the spark job definition.
     *
     * @param sparkJobDefinitionAzureResource Spark Job Definition resource definition.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<SparkBatchJob> debugSparkJobDefinitionAsync(
            SparkJobDefinitionResource sparkJobDefinitionAzureResource, Context context) {
        return debugSparkJobDefinitionWithResponseAsync(sparkJobDefinitionAzureResource, context)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Debug the spark job definition.
     *
     * @param sparkJobDefinitionAzureResource Spark Job Definition resource definition.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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 body along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SparkBatchJob> debugSparkJobDefinitionWithResponse(
            SparkJobDefinitionResource sparkJobDefinitionAzureResource, Context context) {
        return debugSparkJobDefinitionWithResponseAsync(sparkJobDefinitionAzureResource, context).block();
    }

    /**
     * Debug the spark job definition.
     *
     * @param sparkJobDefinitionAzureResource Spark Job Definition resource definition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SparkBatchJob debugSparkJobDefinition(SparkJobDefinitionResource sparkJobDefinitionAzureResource) {
        return debugSparkJobDefinitionWithResponse(sparkJobDefinitionAzureResource, Context.NONE).getValue();
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<SparkJobDefinitionResource>> getSparkJobDefinitionsByWorkspaceNextSinglePageAsync(
            String nextLink) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.getSparkJobDefinitionsByWorkspaceNext(
                                        nextLink, this.client.getEndpoint(), accept, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<SparkJobDefinitionResource>> getSparkJobDefinitionsByWorkspaceNextSinglePageAsync(
            String nextLink, Context context) {
        final String accept = "application/json";
        return service.getSparkJobDefinitionsByWorkspaceNext(nextLink, this.client.getEndpoint(), accept, context)
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse<SparkJobDefinitionResource> getSparkJobDefinitionsByWorkspaceNextSinglePage(String nextLink) {
        return getSparkJobDefinitionsByWorkspaceNextSinglePageAsync(nextLink).block();
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of spark job definitions resources along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse<SparkJobDefinitionResource> getSparkJobDefinitionsByWorkspaceNextSinglePage(
            String nextLink, Context context) {
        return getSparkJobDefinitionsByWorkspaceNextSinglePageAsync(nextLink, context).block();
    }
}
