// 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.CloudErrorException;
import com.azure.analytics.synapse.artifacts.models.LibraryListResponse;
import com.azure.analytics.synapse.artifacts.models.LibraryResource;
import com.azure.analytics.synapse.artifacts.models.LibraryResourceInfo;
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.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

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

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

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

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

        @Post("/libraries/{libraryName}/flush")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<LibraryResourceInfo>> flush(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("libraryName") String libraryName,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("/libraryOperationResults/{operationId}")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<LibraryResource>> getOperationResult(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("operationId") String operationId,
                @HeaderParam("Accept") String accept,
                Context context);

        @Delete("/libraries/{libraryName}")
        @ExpectedResponses({200, 202, 409})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<LibraryResourceInfo>> delete(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("libraryName") String libraryName,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("/libraries/{libraryName}")
        @ExpectedResponses({200, 304})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<LibraryResource>> get(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("libraryName") String libraryName,
                @HeaderParam("Accept") String accept,
                Context context);

        @Put("/libraries/{libraryName}")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<LibraryResourceInfo>> create(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("libraryName") String libraryName,
                @HeaderParam("Accept") String accept,
                Context context);

        @Put("/libraries/{libraryName}")
        @ExpectedResponses({201})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<Void>> append(
                @HostParam("endpoint") String endpoint,
                @QueryParam("comp") String comp,
                @QueryParam("api-version") String apiVersion,
                @PathParam("libraryName") String libraryName,
                @HeaderParam("x-ms-blob-condition-appendpos") Long blobConditionAppendPosition,
                @BodyParam("application/octet-stream") Flux<ByteBuffer> content,
                @HeaderParam("Content-Length") long contentLength,
                @HeaderParam("Accept") String accept,
                Context context);

        @Put("/libraries/{libraryName}")
        @ExpectedResponses({201})
        @UnexpectedResponseExceptionType(CloudErrorException.class)
        Mono<Response<Void>> append(
                @HostParam("endpoint") String endpoint,
                @QueryParam("comp") String comp,
                @QueryParam("api-version") String apiVersion,
                @PathParam("libraryName") String libraryName,
                @HeaderParam("x-ms-blob-condition-appendpos") Long blobConditionAppendPosition,
                @BodyParam("application/octet-stream") BinaryData content,
                @HeaderParam("Content-Length") long contentLength,
                @HeaderParam("Accept") String accept,
                Context context);

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

    /**
     * Lists Library.
     *
     * @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 Library resources along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<LibraryResource>> listSinglePageAsync() {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(context -> service.list(this.client.getEndpoint(), apiVersion, accept, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Lists Library.
     *
     * @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 Library resources along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<LibraryResource>> listSinglePageAsync(Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.list(this.client.getEndpoint(), apiVersion, accept, context)
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Lists Library.
     *
     * @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 Library resources as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<LibraryResource> listAsync() {
        return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * Lists Library.
     *
     * @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 Library resources as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<LibraryResource> listAsync(Context context) {
        return new PagedFlux<>(
                () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists Library.
     *
     * @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 Library resources along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse<LibraryResource> listSinglePage() {
        return listSinglePageAsync().block();
    }

    /**
     * Lists Library.
     *
     * @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 Library resources along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse<LibraryResource> listSinglePage(Context context) {
        return listSinglePageAsync(context).block();
    }

    /**
     * Lists Library.
     *
     * @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 Library resources as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<LibraryResource> list() {
        return new PagedIterable<>(listAsync());
    }

    /**
     * Lists Library.
     *
     * @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 Library resources as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<LibraryResource> list(Context context) {
        return new PagedIterable<>(listAsync(context));
    }

    /**
     * Flush Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo>> flushWithResponseAsync(String libraryName) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context -> service.flush(this.client.getEndpoint(), apiVersion, libraryName, accept, context));
    }

    /**
     * Flush Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo>> flushWithResponseAsync(String libraryName, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.flush(this.client.getEndpoint(), apiVersion, libraryName, accept, context);
    }

    /**
     * Flush Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo> flushAsync(String libraryName) {
        return flushWithResponseAsync(libraryName).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Flush Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo> flushAsync(String libraryName, Context context) {
        return flushWithResponseAsync(libraryName, context).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Flush Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo> flushWithResponse(String libraryName, Context context) {
        return flushWithResponseAsync(libraryName, context).block();
    }

    /**
     * Flush Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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 LibraryResourceInfo flush(String libraryName) {
        return flushWithResponse(libraryName, Context.NONE).getValue();
    }

    /**
     * Get Operation result for Library.
     *
     * @param operationId operation id for which status is requested.
     * @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 operation result for Library along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<LibraryResource>> getOperationResultWithResponseAsync(String operationId) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getOperationResult(
                                this.client.getEndpoint(), apiVersion, operationId, accept, context));
    }

    /**
     * Get Operation result for Library.
     *
     * @param operationId operation id for which status is requested.
     * @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 operation result for Library along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<LibraryResource>> getOperationResultWithResponseAsync(String operationId, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.getOperationResult(this.client.getEndpoint(), apiVersion, operationId, accept, context);
    }

    /**
     * Get Operation result for Library.
     *
     * @param operationId operation id for which status is requested.
     * @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 operation result for Library on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<LibraryResource> getOperationResultAsync(String operationId) {
        return getOperationResultWithResponseAsync(operationId).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get Operation result for Library.
     *
     * @param operationId operation id for which status is requested.
     * @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 operation result for Library on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<LibraryResource> getOperationResultAsync(String operationId, Context context) {
        return getOperationResultWithResponseAsync(operationId, context)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get Operation result for Library.
     *
     * @param operationId operation id for which status is requested.
     * @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 operation result for Library along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<LibraryResource> getOperationResultWithResponse(String operationId, Context context) {
        return getOperationResultWithResponseAsync(operationId, context).block();
    }

    /**
     * Get Operation result for Library.
     *
     * @param operationId operation id for which status is requested.
     * @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 operation result for Library.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public LibraryResource getOperationResult(String operationId) {
        return getOperationResultWithResponse(operationId, Context.NONE).getValue();
    }

    /**
     * Delete Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo>> deleteWithResponseAsync(String libraryName) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context -> service.delete(this.client.getEndpoint(), apiVersion, libraryName, accept, context));
    }

    /**
     * Delete Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo>> deleteWithResponseAsync(String libraryName, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.delete(this.client.getEndpoint(), apiVersion, libraryName, accept, context);
    }

    /**
     * Delete Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo> deleteAsync(String libraryName) {
        return deleteWithResponseAsync(libraryName).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Delete Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo> deleteAsync(String libraryName, Context context) {
        return deleteWithResponseAsync(libraryName, context).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Delete Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo> deleteWithResponse(String libraryName, Context context) {
        return deleteWithResponseAsync(libraryName, context).block();
    }

    /**
     * Delete Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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 LibraryResourceInfo delete(String libraryName) {
        return deleteWithResponse(libraryName, Context.NONE).getValue();
    }

    /**
     * Get Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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 library along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<LibraryResource>> getWithResponseAsync(String libraryName) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context -> service.get(this.client.getEndpoint(), apiVersion, libraryName, accept, context));
    }

    /**
     * Get Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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 library along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<LibraryResource>> getWithResponseAsync(String libraryName, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.get(this.client.getEndpoint(), apiVersion, libraryName, accept, context);
    }

    /**
     * Get Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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 library on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<LibraryResource> getAsync(String libraryName) {
        return getWithResponseAsync(libraryName).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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 library on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<LibraryResource> getAsync(String libraryName, Context context) {
        return getWithResponseAsync(libraryName, context).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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 library along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<LibraryResource> getWithResponse(String libraryName, Context context) {
        return getWithResponseAsync(libraryName, context).block();
    }

    /**
     * Get Library.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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 library.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public LibraryResource get(String libraryName) {
        return getWithResponse(libraryName, Context.NONE).getValue();
    }

    /**
     * Creates a library with the library name.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo>> createWithResponseAsync(String libraryName) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context -> service.create(this.client.getEndpoint(), apiVersion, libraryName, accept, context));
    }

    /**
     * Creates a library with the library name.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo>> createWithResponseAsync(String libraryName, Context context) {
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.create(this.client.getEndpoint(), apiVersion, libraryName, accept, context);
    }

    /**
     * Creates a library with the library name.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo> createAsync(String libraryName) {
        return createWithResponseAsync(libraryName).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Creates a library with the library name.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo> createAsync(String libraryName, Context context) {
        return createWithResponseAsync(libraryName, context).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Creates a library with the library name.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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<LibraryResourceInfo> createWithResponse(String libraryName, Context context) {
        return createWithResponseAsync(libraryName, context).block();
    }

    /**
     * Creates a library with the library name.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @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 LibraryResourceInfo create(String libraryName) {
        return createWithResponse(libraryName, Context.NONE).getValue();
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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>> appendWithResponseAsync(
            String libraryName, Flux<ByteBuffer> content, long contentLength, Long blobConditionAppendPosition) {
        final String comp = "appendblock";
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.append(
                                this.client.getEndpoint(),
                                comp,
                                apiVersion,
                                libraryName,
                                blobConditionAppendPosition,
                                content,
                                contentLength,
                                accept,
                                context));
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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>> appendWithResponseAsync(
            String libraryName,
            Flux<ByteBuffer> content,
            long contentLength,
            Long blobConditionAppendPosition,
            Context context) {
        final String comp = "appendblock";
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.append(
                this.client.getEndpoint(),
                comp,
                apiVersion,
                libraryName,
                blobConditionAppendPosition,
                content,
                contentLength,
                accept,
                context);
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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> appendAsync(
            String libraryName, Flux<ByteBuffer> content, long contentLength, Long blobConditionAppendPosition) {
        return appendWithResponseAsync(libraryName, content, contentLength, blobConditionAppendPosition)
                .flatMap(ignored -> Mono.empty());
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @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> appendAsync(String libraryName, Flux<ByteBuffer> content, long contentLength) {
        final Long blobConditionAppendPosition = null;
        return appendWithResponseAsync(libraryName, content, contentLength, blobConditionAppendPosition)
                .flatMap(ignored -> Mono.empty());
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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> appendAsync(
            String libraryName,
            Flux<ByteBuffer> content,
            long contentLength,
            Long blobConditionAppendPosition,
            Context context) {
        return appendWithResponseAsync(libraryName, content, contentLength, blobConditionAppendPosition, context)
                .flatMap(ignored -> Mono.empty());
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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> appendWithResponse(
            String libraryName,
            Flux<ByteBuffer> content,
            long contentLength,
            Long blobConditionAppendPosition,
            Context context) {
        return appendWithResponseAsync(libraryName, content, contentLength, blobConditionAppendPosition, context)
                .block();
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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 append(
            String libraryName, Flux<ByteBuffer> content, long contentLength, Long blobConditionAppendPosition) {
        appendWithResponse(libraryName, content, contentLength, blobConditionAppendPosition, Context.NONE);
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @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 append(String libraryName, Flux<ByteBuffer> content, long contentLength) {
        final Long blobConditionAppendPosition = null;
        appendWithResponse(libraryName, content, contentLength, blobConditionAppendPosition, Context.NONE);
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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>> appendWithResponseAsync(
            String libraryName, BinaryData content, long contentLength, Long blobConditionAppendPosition) {
        final String comp = "appendblock";
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.append(
                                this.client.getEndpoint(),
                                comp,
                                apiVersion,
                                libraryName,
                                blobConditionAppendPosition,
                                content,
                                contentLength,
                                accept,
                                context));
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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>> appendWithResponseAsync(
            String libraryName,
            BinaryData content,
            long contentLength,
            Long blobConditionAppendPosition,
            Context context) {
        final String comp = "appendblock";
        final String apiVersion = "2020-12-01";
        final String accept = "application/json";
        return service.append(
                this.client.getEndpoint(),
                comp,
                apiVersion,
                libraryName,
                blobConditionAppendPosition,
                content,
                contentLength,
                accept,
                context);
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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> appendAsync(
            String libraryName, BinaryData content, long contentLength, Long blobConditionAppendPosition) {
        return appendWithResponseAsync(libraryName, content, contentLength, blobConditionAppendPosition)
                .flatMap(ignored -> Mono.empty());
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @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> appendAsync(String libraryName, BinaryData content, long contentLength) {
        final Long blobConditionAppendPosition = null;
        return appendWithResponseAsync(libraryName, content, contentLength, blobConditionAppendPosition)
                .flatMap(ignored -> Mono.empty());
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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> appendAsync(
            String libraryName,
            BinaryData content,
            long contentLength,
            Long blobConditionAppendPosition,
            Context context) {
        return appendWithResponseAsync(libraryName, content, contentLength, blobConditionAppendPosition, context)
                .flatMap(ignored -> Mono.empty());
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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> appendWithResponse(
            String libraryName,
            BinaryData content,
            long contentLength,
            Long blobConditionAppendPosition,
            Context context) {
        return appendWithResponseAsync(libraryName, content, contentLength, blobConditionAppendPosition, context)
                .block();
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @param blobConditionAppendPosition Set this header to a byte offset at which the block is expected to be
     *     appended. The request succeeds only if the current offset matches this value. Otherwise, the request fails
     *     with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed).
     * @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 append(String libraryName, BinaryData content, long contentLength, Long blobConditionAppendPosition) {
        appendWithResponse(libraryName, content, contentLength, blobConditionAppendPosition, Context.NONE);
    }

    /**
     * Append the content to the library resource created using the create operation. The maximum content size is 4MiB.
     * Content larger than 4MiB must be appended in 4MiB chunks.
     *
     * @param libraryName file name to upload. Minimum length of the filename should be 1 excluding the extension
     *     length.
     * @param content Library file chunk.
     * @param contentLength The Content-Length header for the request.
     * @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 append(String libraryName, BinaryData content, long contentLength) {
        final Long blobConditionAppendPosition = null;
        appendWithResponse(libraryName, content, contentLength, blobConditionAppendPosition, Context.NONE);
    }

    /**
     * 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 Library resources along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<LibraryResource>> listNextSinglePageAsync(String nextLink) {
        final String accept = "application/json";
        return FluxUtil.withContext(context -> service.listNext(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 Library resources along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<LibraryResource>> listNextSinglePageAsync(String nextLink, Context context) {
        final String accept = "application/json";
        return service.listNext(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 Library resources along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse<LibraryResource> listNextSinglePage(String nextLink) {
        return listNextSinglePageAsync(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 Library resources along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse<LibraryResource> listNextSinglePage(String nextLink, Context context) {
        return listNextSinglePageAsync(nextLink, context).block();
    }
}
