NotebooksImpl.java

// 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.CloudErrorAutoGeneratedException;
import com.azure.analytics.synapse.artifacts.models.NotebookListResponse;
import com.azure.analytics.synapse.artifacts.models.NotebookResource;
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 Notebooks. */
public final class NotebooksImpl {
    /** The proxy service used to perform REST calls. */
    private final NotebooksService service;

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

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

    /**
     * The interface defining all the services for ArtifactsClientNotebooks to be used by the proxy service to perform
     * REST calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "ArtifactsClientNoteb")
    private interface NotebooksService {
        @Get("/notebooks")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CloudErrorAutoGeneratedException.class)
        Mono<Response<NotebookListResponse>> getNotebooksByWorkspace(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("/notebooksSummary")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CloudErrorAutoGeneratedException.class)
        Mono<Response<NotebookListResponse>> getNotebookSummaryByWorkSpace(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                Context context);

        @Put("/notebooks/{notebookName}")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(CloudErrorAutoGeneratedException.class)
        Mono<Response<NotebookResource>> createOrUpdateNotebook(
                @HostParam("endpoint") String endpoint,
                @PathParam("notebookName") String notebookName,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("If-Match") String ifMatch,
                @BodyParam("application/json") NotebookResource notebook,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("/notebooks/{notebookName}")
        @ExpectedResponses({200, 304})
        @UnexpectedResponseExceptionType(CloudErrorAutoGeneratedException.class)
        Mono<Response<NotebookResource>> getNotebook(
                @HostParam("endpoint") String endpoint,
                @PathParam("notebookName") String notebookName,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("If-None-Match") String ifNoneMatch,
                @HeaderParam("Accept") String accept,
                Context context);

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

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

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

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

    /**
     * Lists Notebooks.
     *
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<NotebookResource>> getNotebooksByWorkspaceSinglePageAsync() {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.getNotebooksByWorkspace(this.client.getEndpoint(), apiVersion, accept, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Lists Notebooks.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<NotebookResource>> getNotebooksByWorkspaceSinglePageAsync(Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.getNotebooksByWorkspace(this.client.getEndpoint(), apiVersion, accept, context)
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Lists Notebooks.
     *
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<NotebookResource> getNotebooksByWorkspaceAsync() {
        return new PagedFlux<>(
                () -> getNotebooksByWorkspaceSinglePageAsync(),
                nextLink -> getNotebooksByWorkspaceNextSinglePageAsync(nextLink));
    }

    /**
     * Lists Notebooks.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<NotebookResource> getNotebooksByWorkspaceAsync(Context context) {
        return new PagedFlux<>(
                () -> getNotebooksByWorkspaceSinglePageAsync(context),
                nextLink -> getNotebooksByWorkspaceNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists Notebooks.
     *
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<NotebookResource> getNotebooksByWorkspace() {
        return new PagedIterable<>(getNotebooksByWorkspaceAsync());
    }

    /**
     * Lists Notebooks.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<NotebookResource> getNotebooksByWorkspace(Context context) {
        return new PagedIterable<>(getNotebooksByWorkspaceAsync(context));
    }

    /**
     * Lists a summary of Notebooks.
     *
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<NotebookResource>> getNotebookSummaryByWorkSpaceSinglePageAsync() {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.getNotebookSummaryByWorkSpace(
                                        this.client.getEndpoint(), apiVersion, accept, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Lists a summary of Notebooks.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<NotebookResource>> getNotebookSummaryByWorkSpaceSinglePageAsync(Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.getNotebookSummaryByWorkSpace(this.client.getEndpoint(), apiVersion, accept, context)
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Lists a summary of Notebooks.
     *
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<NotebookResource> getNotebookSummaryByWorkSpaceAsync() {
        return new PagedFlux<>(
                () -> getNotebookSummaryByWorkSpaceSinglePageAsync(),
                nextLink -> getNotebookSummaryByWorkSpaceNextSinglePageAsync(nextLink));
    }

    /**
     * Lists a summary of Notebooks.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<NotebookResource> getNotebookSummaryByWorkSpaceAsync(Context context) {
        return new PagedFlux<>(
                () -> getNotebookSummaryByWorkSpaceSinglePageAsync(context),
                nextLink -> getNotebookSummaryByWorkSpaceNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists a summary of Notebooks.
     *
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<NotebookResource> getNotebookSummaryByWorkSpace() {
        return new PagedIterable<>(getNotebookSummaryByWorkSpaceAsync());
    }

    /**
     * Lists a summary of Notebooks.
     *
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<NotebookResource> getNotebookSummaryByWorkSpace(Context context) {
        return new PagedIterable<>(getNotebookSummaryByWorkSpaceAsync(context));
    }

    /**
     * Creates or updates a Note Book.
     *
     * @param notebookName The notebook name.
     * @param notebook Note book resource definition.
     * @param ifMatch ETag of the Note book 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return notebook resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<NotebookResource>> createOrUpdateNotebookWithResponseAsync(
            String notebookName, NotebookResource notebook, String ifMatch) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createOrUpdateNotebook(
                                this.client.getEndpoint(),
                                notebookName,
                                apiVersion,
                                ifMatch,
                                notebook,
                                accept,
                                context));
    }

    /**
     * Creates or updates a Note Book.
     *
     * @param notebookName The notebook name.
     * @param notebook Note book resource definition.
     * @param ifMatch ETag of the Note book 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return notebook resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<NotebookResource>> createOrUpdateNotebookWithResponseAsync(
            String notebookName, NotebookResource notebook, String ifMatch, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.createOrUpdateNotebook(
                this.client.getEndpoint(), notebookName, apiVersion, ifMatch, notebook, accept, context);
    }

    /**
     * Creates or updates a Note Book.
     *
     * @param notebookName The notebook name.
     * @param notebook Note book resource definition.
     * @param ifMatch ETag of the Note book 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return notebook resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<NotebookResource> createOrUpdateNotebookAsync(
            String notebookName, NotebookResource notebook, String ifMatch) {
        return createOrUpdateNotebookWithResponseAsync(notebookName, notebook, ifMatch)
                .flatMap(
                        (Response<NotebookResource> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Creates or updates a Note Book.
     *
     * @param notebookName The notebook name.
     * @param notebook Note book resource definition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return notebook resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<NotebookResource> createOrUpdateNotebookAsync(String notebookName, NotebookResource notebook) {
        final String ifMatch = null;
        return createOrUpdateNotebookWithResponseAsync(notebookName, notebook, ifMatch)
                .flatMap(
                        (Response<NotebookResource> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Creates or updates a Note Book.
     *
     * @param notebookName The notebook name.
     * @param notebook Note book resource definition.
     * @param ifMatch ETag of the Note book 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return notebook resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<NotebookResource> createOrUpdateNotebookAsync(
            String notebookName, NotebookResource notebook, String ifMatch, Context context) {
        return createOrUpdateNotebookWithResponseAsync(notebookName, notebook, ifMatch, context)
                .flatMap(
                        (Response<NotebookResource> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Creates or updates a Note Book.
     *
     * @param notebookName The notebook name.
     * @param notebook Note book resource definition.
     * @param ifMatch ETag of the Note book 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return notebook resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NotebookResource createOrUpdateNotebook(String notebookName, NotebookResource notebook, String ifMatch) {
        return createOrUpdateNotebookAsync(notebookName, notebook, ifMatch).block();
    }

    /**
     * Creates or updates a Note Book.
     *
     * @param notebookName The notebook name.
     * @param notebook Note book resource definition.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return notebook resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NotebookResource createOrUpdateNotebook(String notebookName, NotebookResource notebook) {
        final String ifMatch = null;
        return createOrUpdateNotebookAsync(notebookName, notebook, ifMatch).block();
    }

    /**
     * Creates or updates a Note Book.
     *
     * @param notebookName The notebook name.
     * @param notebook Note book resource definition.
     * @param ifMatch ETag of the Note book 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return notebook resource type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<NotebookResource> createOrUpdateNotebookWithResponse(
            String notebookName, NotebookResource notebook, String ifMatch, Context context) {
        return createOrUpdateNotebookWithResponseAsync(notebookName, notebook, ifMatch, context).block();
    }

    /**
     * Gets a Note Book.
     *
     * @param notebookName The notebook name.
     * @param ifNoneMatch ETag of the Notebook 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Note Book.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<NotebookResource>> getNotebookWithResponseAsync(String notebookName, String ifNoneMatch) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getNotebook(
                                this.client.getEndpoint(), notebookName, apiVersion, ifNoneMatch, accept, context));
    }

    /**
     * Gets a Note Book.
     *
     * @param notebookName The notebook name.
     * @param ifNoneMatch ETag of the Notebook 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Note Book.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<NotebookResource>> getNotebookWithResponseAsync(
            String notebookName, String ifNoneMatch, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.getNotebook(this.client.getEndpoint(), notebookName, apiVersion, ifNoneMatch, accept, context);
    }

    /**
     * Gets a Note Book.
     *
     * @param notebookName The notebook name.
     * @param ifNoneMatch ETag of the Notebook 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Note Book.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<NotebookResource> getNotebookAsync(String notebookName, String ifNoneMatch) {
        return getNotebookWithResponseAsync(notebookName, ifNoneMatch)
                .flatMap(
                        (Response<NotebookResource> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Gets a Note Book.
     *
     * @param notebookName The notebook name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Note Book.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<NotebookResource> getNotebookAsync(String notebookName) {
        final String ifNoneMatch = null;
        return getNotebookWithResponseAsync(notebookName, ifNoneMatch)
                .flatMap(
                        (Response<NotebookResource> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Gets a Note Book.
     *
     * @param notebookName The notebook name.
     * @param ifNoneMatch ETag of the Notebook 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Note Book.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<NotebookResource> getNotebookAsync(String notebookName, String ifNoneMatch, Context context) {
        return getNotebookWithResponseAsync(notebookName, ifNoneMatch, context)
                .flatMap(
                        (Response<NotebookResource> res) -> {
                            if (res.getValue() != null) {
                                return Mono.just(res.getValue());
                            } else {
                                return Mono.empty();
                            }
                        });
    }

    /**
     * Gets a Note Book.
     *
     * @param notebookName The notebook name.
     * @param ifNoneMatch ETag of the Notebook 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Note Book.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NotebookResource getNotebook(String notebookName, String ifNoneMatch) {
        return getNotebookAsync(notebookName, ifNoneMatch).block();
    }

    /**
     * Gets a Note Book.
     *
     * @param notebookName The notebook name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Note Book.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public NotebookResource getNotebook(String notebookName) {
        final String ifNoneMatch = null;
        return getNotebookAsync(notebookName, ifNoneMatch).block();
    }

    /**
     * Gets a Note Book.
     *
     * @param notebookName The notebook name.
     * @param ifNoneMatch ETag of the Notebook 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 CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a Note Book.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<NotebookResource> getNotebookWithResponse(
            String notebookName, String ifNoneMatch, Context context) {
        return getNotebookWithResponseAsync(notebookName, ifNoneMatch, context).block();
    }

    /**
     * Deletes a Note book.
     *
     * @param notebookName The notebook name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> deleteNotebookWithResponseAsync(String notebookName) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.deleteNotebook(this.client.getEndpoint(), notebookName, apiVersion, accept, context));
    }

    /**
     * Deletes a Note book.
     *
     * @param notebookName The notebook name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> deleteNotebookWithResponseAsync(String notebookName, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.deleteNotebook(this.client.getEndpoint(), notebookName, apiVersion, accept, context);
    }

    /**
     * Deletes a Note book.
     *
     * @param notebookName The notebook name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> deleteNotebookAsync(String notebookName) {
        return deleteNotebookWithResponseAsync(notebookName).flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Deletes a Note book.
     *
     * @param notebookName The notebook name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> deleteNotebookAsync(String notebookName, Context context) {
        return deleteNotebookWithResponseAsync(notebookName, context).flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Deletes a Note book.
     *
     * @param notebookName The notebook name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 deleteNotebook(String notebookName) {
        deleteNotebookAsync(notebookName).block();
    }

    /**
     * Deletes a Note book.
     *
     * @param notebookName The notebook name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Response<Void> deleteNotebookWithResponse(String notebookName, Context context) {
        return deleteNotebookWithResponseAsync(notebookName, context).block();
    }

    /**
     * Renames a notebook.
     *
     * @param notebookName The notebook name.
     * @param request proposed new name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> renameNotebookWithResponseAsync(String notebookName, ArtifactRenameRequest request) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.renameNotebook(
                                this.client.getEndpoint(), notebookName, apiVersion, request, accept, context));
    }

    /**
     * Renames a notebook.
     *
     * @param notebookName The notebook name.
     * @param request proposed new name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> renameNotebookWithResponseAsync(
            String notebookName, ArtifactRenameRequest request, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.renameNotebook(this.client.getEndpoint(), notebookName, apiVersion, request, accept, context);
    }

    /**
     * Renames a notebook.
     *
     * @param notebookName The notebook name.
     * @param request proposed new name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> renameNotebookAsync(String notebookName, ArtifactRenameRequest request) {
        return renameNotebookWithResponseAsync(notebookName, request).flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Renames a notebook.
     *
     * @param notebookName The notebook name.
     * @param request proposed new name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> renameNotebookAsync(String notebookName, ArtifactRenameRequest request, Context context) {
        return renameNotebookWithResponseAsync(notebookName, request, context)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Renames a notebook.
     *
     * @param notebookName The notebook name.
     * @param request proposed new name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 renameNotebook(String notebookName, ArtifactRenameRequest request) {
        renameNotebookAsync(notebookName, request).block();
    }

    /**
     * Renames a notebook.
     *
     * @param notebookName The notebook name.
     * @param request proposed new name.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Response<Void> renameNotebookWithResponse(
            String notebookName, ArtifactRenameRequest request, Context context) {
        return renameNotebookWithResponseAsync(notebookName, request, context).block();
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<NotebookResource>> getNotebooksByWorkspaceNextSinglePageAsync(String nextLink) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.getNotebooksByWorkspaceNext(
                                        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 nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<NotebookResource>> getNotebooksByWorkspaceNextSinglePageAsync(
            String nextLink, Context context) {
        final String accept = "application/json";
        return service.getNotebooksByWorkspaceNext(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 nextLink parameter.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<NotebookResource>> getNotebookSummaryByWorkSpaceNextSinglePageAsync(String nextLink) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.getNotebookSummaryByWorkSpaceNext(
                                        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 nextLink parameter.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorAutoGeneratedException 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 Notebook resources.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<NotebookResource>> getNotebookSummaryByWorkSpaceNextSinglePageAsync(
            String nextLink, Context context) {
        final String accept = "application/json";
        return service.getNotebookSummaryByWorkSpaceNext(nextLink, this.client.getEndpoint(), accept, context)
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }
}