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

package com.azure.developer.devcenter.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
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.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
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.RequestOptions;
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 com.azure.core.util.polling.DefaultPollingStrategy;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.core.util.serializer.TypeReference;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import reactor.core.publisher.Mono;

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

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

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

    /**
     * The interface defining all the services for DevCenterEnvironments to be used by the proxy service to perform REST
     * calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "DevCenterEnvironment")
    public interface EnvironmentsService {
        @Get("/projects/{projectName}/environments")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listEnvironments(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/users/{userId}/environments")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listEnvironmentsByUser(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/users/{userId}/environments/{environmentName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> getEnvironmentByUser(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("environmentName") String environmentName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Put("/projects/{projectName}/users/{userId}/environments/{environmentName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> createOrUpdateEnvironment(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("environmentName") String environmentName,
                @BodyParam("application/json") BinaryData body,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Patch("/projects/{projectName}/users/{userId}/environments/{environmentName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> updateEnvironment(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("environmentName") String environmentName,
                @BodyParam("application/merge-patch+json") BinaryData body,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Delete("/projects/{projectName}/users/{userId}/environments/{environmentName}")
        @ExpectedResponses({200, 202, 204})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> deleteEnvironment(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("environmentName") String environmentName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/projects/{projectName}/users/{userId}/environments/{environmentName}:deploy")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> deployEnvironmentAction(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("environmentName") String environmentName,
                @BodyParam("application/json") BinaryData body,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/projects/{projectName}/users/{userId}/environments/{environmentName}:custom")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> customEnvironmentAction(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("environmentName") String environmentName,
                @BodyParam("application/json") BinaryData body,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/catalogItems")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listCatalogItems(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/catalogItems/{catalogItemId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> getCatalogItem(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("catalogItemId") String catalogItemId,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/catalogItems/{catalogItemId}/versions")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listCatalogItemVersions(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("catalogItemId") String catalogItemId,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/catalogItems/{catalogItemId}/versions/{version}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> getCatalogItemVersion(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("catalogItemId") String catalogItemId,
                @PathParam("version") String version,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/environmentTypes")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listEnvironmentTypes(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listEnvironmentsNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listEnvironmentsByUserNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listCatalogItemsNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listCatalogItemVersionsNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listEnvironmentTypesNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);
    }

    /**
     * Lists the environments for a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the environment list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listEnvironmentsSinglePageAsync(
            String projectName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listEnvironments(
                                        this.client.getEndpoint(),
                                        this.client.getServiceVersion().getVersion(),
                                        projectName,
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Lists the environments for a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the environment list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listEnvironmentsAsync(String projectName, RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listEnvironmentsSinglePageAsync(projectName, requestOptions),
                nextLink -> listEnvironmentsNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Lists the environments for a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the environment list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listEnvironments(String projectName, RequestOptions requestOptions) {
        return new PagedIterable<>(listEnvironmentsAsync(projectName, requestOptions));
    }

    /**
     * Lists the environments for a project and user.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the environment list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listEnvironmentsByUserSinglePageAsync(
            String projectName, String userId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listEnvironmentsByUser(
                                        this.client.getEndpoint(),
                                        this.client.getServiceVersion().getVersion(),
                                        projectName,
                                        userId,
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Lists the environments for a project and user.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the environment list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listEnvironmentsByUserAsync(
            String projectName, String userId, RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listEnvironmentsByUserSinglePageAsync(projectName, userId, requestOptions),
                nextLink -> listEnvironmentsByUserNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Lists the environments for a project and user.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the environment list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listEnvironmentsByUser(
            String projectName, String userId, RequestOptions requestOptions) {
        return new PagedIterable<>(listEnvironmentsByUserAsync(projectName, userId, requestOptions));
    }

    /**
     * Gets an environment.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return an environment along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getEnvironmentByUserWithResponseAsync(
            String projectName, String userId, String environmentName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getEnvironmentByUser(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                environmentName,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Gets an environment.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return an environment along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getEnvironmentByUserWithResponse(
            String projectName, String userId, String environmentName, RequestOptions requestOptions) {
        return getEnvironmentByUserWithResponseAsync(projectName, userId, environmentName, requestOptions).block();
    }

    /**
     * Creates or updates an environment.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Represents a environment.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return properties of an environment along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BinaryData>> createOrUpdateEnvironmentWithResponseAsync(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createOrUpdateEnvironment(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                environmentName,
                                body,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Creates or updates an environment.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Represents a environment.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link PollerFlux} for polling of properties of an environment.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public PollerFlux<BinaryData, BinaryData> beginCreateOrUpdateEnvironmentAsync(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        return PollerFlux.create(
                Duration.ofSeconds(1),
                () ->
                        this.createOrUpdateEnvironmentWithResponseAsync(
                                projectName, userId, environmentName, body, requestOptions),
                new DefaultPollingStrategy<>(
                        this.client.getHttpPipeline(),
                        "{endpoint}".replace("{endpoint}", this.client.getEndpoint()),
                        null,
                        requestOptions != null && requestOptions.getContext() != null
                                ? requestOptions.getContext()
                                : Context.NONE),
                TypeReference.createInstance(BinaryData.class),
                TypeReference.createInstance(BinaryData.class));
    }

    /**
     * Creates or updates an environment.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Represents a environment.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link SyncPoller} for polling of properties of an environment.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<BinaryData, BinaryData> beginCreateOrUpdateEnvironment(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        return this.beginCreateOrUpdateEnvironmentAsync(projectName, userId, environmentName, body, requestOptions)
                .getSyncPoller();
    }

    /**
     * Partially updates an environment.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Updatable environment properties.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return properties of an environment along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> updateEnvironmentWithResponseAsync(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.updateEnvironment(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                environmentName,
                                body,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Partially updates an environment.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Updatable environment properties.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return properties of an environment along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> updateEnvironmentWithResponse(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        return updateEnvironmentWithResponseAsync(projectName, userId, environmentName, body, requestOptions).block();
    }

    /**
     * Deletes an environment and all its associated resources.
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deleteEnvironmentWithResponseAsync(
            String projectName, String userId, String environmentName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.deleteEnvironment(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                environmentName,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Deletes an environment and all its associated resources.
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public PollerFlux<BinaryData, Void> beginDeleteEnvironmentAsync(
            String projectName, String userId, String environmentName, RequestOptions requestOptions) {
        return PollerFlux.create(
                Duration.ofSeconds(1),
                () -> this.deleteEnvironmentWithResponseAsync(projectName, userId, environmentName, requestOptions),
                new DefaultPollingStrategy<>(
                        this.client.getHttpPipeline(),
                        "{endpoint}".replace("{endpoint}", this.client.getEndpoint()),
                        null,
                        requestOptions != null && requestOptions.getContext() != null
                                ? requestOptions.getContext()
                                : Context.NONE),
                TypeReference.createInstance(BinaryData.class),
                TypeReference.createInstance(Void.class));
    }

    /**
     * Deletes an environment and all its associated resources.
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<BinaryData, Void> beginDeleteEnvironment(
            String projectName, String userId, String environmentName, RequestOptions requestOptions) {
        return this.beginDeleteEnvironmentAsync(projectName, userId, environmentName, requestOptions).getSyncPoller();
    }

    /**
     * Executes a deploy action.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     actionId: String (Required)
     *     parameters: Object (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Action properties overriding the environment's default values.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> deployEnvironmentActionWithResponseAsync(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.deployEnvironmentAction(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                environmentName,
                                body,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Executes a deploy action.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     actionId: String (Required)
     *     parameters: Object (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Action properties overriding the environment's default values.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public PollerFlux<BinaryData, BinaryData> beginDeployEnvironmentActionAsync(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        return PollerFlux.create(
                Duration.ofSeconds(1),
                () ->
                        this.deployEnvironmentActionWithResponseAsync(
                                projectName, userId, environmentName, body, requestOptions),
                new DefaultPollingStrategy<>(
                        this.client.getHttpPipeline(),
                        "{endpoint}".replace("{endpoint}", this.client.getEndpoint()),
                        null,
                        requestOptions != null && requestOptions.getContext() != null
                                ? requestOptions.getContext()
                                : Context.NONE),
                TypeReference.createInstance(BinaryData.class),
                TypeReference.createInstance(BinaryData.class));
    }

    /**
     * Executes a deploy action.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     actionId: String (Required)
     *     parameters: Object (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Action properties overriding the environment's default values.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<BinaryData, BinaryData> beginDeployEnvironmentAction(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        return this.beginDeployEnvironmentActionAsync(projectName, userId, environmentName, body, requestOptions)
                .getSyncPoller();
    }

    /**
     * Executes a custom action.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     actionId: String (Required)
     *     parameters: Object (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Action properties overriding the environment's default values.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Void>> customEnvironmentActionWithResponseAsync(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.customEnvironmentAction(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                environmentName,
                                body,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Executes a custom action.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     actionId: String (Required)
     *     parameters: Object (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Action properties overriding the environment's default values.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public PollerFlux<BinaryData, BinaryData> beginCustomEnvironmentActionAsync(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        return PollerFlux.create(
                Duration.ofSeconds(1),
                () ->
                        this.customEnvironmentActionWithResponseAsync(
                                projectName, userId, environmentName, body, requestOptions),
                new DefaultPollingStrategy<>(
                        this.client.getHttpPipeline(),
                        "{endpoint}".replace("{endpoint}", this.client.getEndpoint()),
                        null,
                        requestOptions != null && requestOptions.getContext() != null
                                ? requestOptions.getContext()
                                : Context.NONE),
                TypeReference.createInstance(BinaryData.class),
                TypeReference.createInstance(BinaryData.class));
    }

    /**
     * Executes a custom action.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     actionId: String (Required)
     *     parameters: Object (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param userId The AAD object id of the user. If value is 'me', the identity is taken from the authentication
     *     context.
     * @param environmentName The name of the environment.
     * @param body Action properties overriding the environment's default values.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<BinaryData, BinaryData> beginCustomEnvironmentAction(
            String projectName, String userId, String environmentName, BinaryData body, RequestOptions requestOptions) {
        return this.beginCustomEnvironmentActionAsync(projectName, userId, environmentName, body, requestOptions)
                .getSyncPoller();
    }

    /**
     * Lists latest version of all catalog items available for a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     name: String (Optional)
     *     catalogName: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the catalog item list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listCatalogItemsSinglePageAsync(
            String projectName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listCatalogItems(
                                        this.client.getEndpoint(),
                                        this.client.getServiceVersion().getVersion(),
                                        projectName,
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Lists latest version of all catalog items available for a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     name: String (Optional)
     *     catalogName: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the catalog item list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listCatalogItemsAsync(String projectName, RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listCatalogItemsSinglePageAsync(projectName, requestOptions),
                nextLink -> listCatalogItemsNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Lists latest version of all catalog items available for a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     name: String (Optional)
     *     catalogName: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the catalog item list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listCatalogItems(String projectName, RequestOptions requestOptions) {
        return new PagedIterable<>(listCatalogItemsAsync(projectName, requestOptions));
    }

    /**
     * Get a catalog item from a project.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     name: String (Optional)
     *     catalogName: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param catalogItemId The unique id of the catalog item.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a catalog item from a project along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getCatalogItemWithResponseAsync(
            String projectName, String catalogItemId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getCatalogItem(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                catalogItemId,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Get a catalog item from a project.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     name: String (Optional)
     *     catalogName: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param catalogItemId The unique id of the catalog item.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a catalog item from a project along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getCatalogItemWithResponse(
            String projectName, String catalogItemId, RequestOptions requestOptions) {
        return getCatalogItemWithResponseAsync(projectName, catalogItemId, requestOptions).block();
    }

    /**
     * List all versions of a catalog item from a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     catalogItemId: String (Optional)
     *     catalogItemName: String (Optional)
     *     catalogName: String (Optional)
     *     version: String (Optional)
     *     summary: String (Optional)
     *     description: String (Optional)
     *     templatePath: String (Optional)
     *     parametersSchema: String (Optional)
     *     parameters (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             default: Object (Optional)
     *             type: String(array/boolean/integer/null/number/object/string) (Optional)
     *             readOnly: Boolean (Optional)
     *             required: Boolean (Optional)
     *             allowed (Optional): [
     *                 Object (Optional)
     *             ]
     *         }
     *     ]
     *     actions (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             parametersSchema: String (Optional)
     *             parameters (Optional): [
     *                 (recursive schema, see above)
     *             ]
     *             type: String(Custom/Deploy/Delete) (Optional)
     *             typeName: String (Optional)
     *             runner: String (Optional)
     *         }
     *     ]
     *     runner: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     *     eligibleForLatestVersion: Boolean (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param catalogItemId The unique id of the catalog item.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the catalog item list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listCatalogItemVersionsSinglePageAsync(
            String projectName, String catalogItemId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listCatalogItemVersions(
                                        this.client.getEndpoint(),
                                        this.client.getServiceVersion().getVersion(),
                                        projectName,
                                        catalogItemId,
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * List all versions of a catalog item from a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     catalogItemId: String (Optional)
     *     catalogItemName: String (Optional)
     *     catalogName: String (Optional)
     *     version: String (Optional)
     *     summary: String (Optional)
     *     description: String (Optional)
     *     templatePath: String (Optional)
     *     parametersSchema: String (Optional)
     *     parameters (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             default: Object (Optional)
     *             type: String(array/boolean/integer/null/number/object/string) (Optional)
     *             readOnly: Boolean (Optional)
     *             required: Boolean (Optional)
     *             allowed (Optional): [
     *                 Object (Optional)
     *             ]
     *         }
     *     ]
     *     actions (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             parametersSchema: String (Optional)
     *             parameters (Optional): [
     *                 (recursive schema, see above)
     *             ]
     *             type: String(Custom/Deploy/Delete) (Optional)
     *             typeName: String (Optional)
     *             runner: String (Optional)
     *         }
     *     ]
     *     runner: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     *     eligibleForLatestVersion: Boolean (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param catalogItemId The unique id of the catalog item.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the catalog item list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listCatalogItemVersionsAsync(
            String projectName, String catalogItemId, RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listCatalogItemVersionsSinglePageAsync(projectName, catalogItemId, requestOptions),
                nextLink -> listCatalogItemVersionsNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * List all versions of a catalog item from a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     catalogItemId: String (Optional)
     *     catalogItemName: String (Optional)
     *     catalogName: String (Optional)
     *     version: String (Optional)
     *     summary: String (Optional)
     *     description: String (Optional)
     *     templatePath: String (Optional)
     *     parametersSchema: String (Optional)
     *     parameters (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             default: Object (Optional)
     *             type: String(array/boolean/integer/null/number/object/string) (Optional)
     *             readOnly: Boolean (Optional)
     *             required: Boolean (Optional)
     *             allowed (Optional): [
     *                 Object (Optional)
     *             ]
     *         }
     *     ]
     *     actions (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             parametersSchema: String (Optional)
     *             parameters (Optional): [
     *                 (recursive schema, see above)
     *             ]
     *             type: String(Custom/Deploy/Delete) (Optional)
     *             typeName: String (Optional)
     *             runner: String (Optional)
     *         }
     *     ]
     *     runner: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     *     eligibleForLatestVersion: Boolean (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param catalogItemId The unique id of the catalog item.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the catalog item list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listCatalogItemVersions(
            String projectName, String catalogItemId, RequestOptions requestOptions) {
        return new PagedIterable<>(listCatalogItemVersionsAsync(projectName, catalogItemId, requestOptions));
    }

    /**
     * Get a specific catalog item version from a project.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     catalogItemId: String (Optional)
     *     catalogItemName: String (Optional)
     *     catalogName: String (Optional)
     *     version: String (Optional)
     *     summary: String (Optional)
     *     description: String (Optional)
     *     templatePath: String (Optional)
     *     parametersSchema: String (Optional)
     *     parameters (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             default: Object (Optional)
     *             type: String(array/boolean/integer/null/number/object/string) (Optional)
     *             readOnly: Boolean (Optional)
     *             required: Boolean (Optional)
     *             allowed (Optional): [
     *                 Object (Optional)
     *             ]
     *         }
     *     ]
     *     actions (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             parametersSchema: String (Optional)
     *             parameters (Optional): [
     *                 (recursive schema, see above)
     *             ]
     *             type: String(Custom/Deploy/Delete) (Optional)
     *             typeName: String (Optional)
     *             runner: String (Optional)
     *         }
     *     ]
     *     runner: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     *     eligibleForLatestVersion: Boolean (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param catalogItemId The unique id of the catalog item.
     * @param version The version of the catalog item.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a specific catalog item version from a project along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getCatalogItemVersionWithResponseAsync(
            String projectName, String catalogItemId, String version, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getCatalogItemVersion(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                catalogItemId,
                                version,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Get a specific catalog item version from a project.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     catalogItemId: String (Optional)
     *     catalogItemName: String (Optional)
     *     catalogName: String (Optional)
     *     version: String (Optional)
     *     summary: String (Optional)
     *     description: String (Optional)
     *     templatePath: String (Optional)
     *     parametersSchema: String (Optional)
     *     parameters (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             default: Object (Optional)
     *             type: String(array/boolean/integer/null/number/object/string) (Optional)
     *             readOnly: Boolean (Optional)
     *             required: Boolean (Optional)
     *             allowed (Optional): [
     *                 Object (Optional)
     *             ]
     *         }
     *     ]
     *     actions (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             parametersSchema: String (Optional)
     *             parameters (Optional): [
     *                 (recursive schema, see above)
     *             ]
     *             type: String(Custom/Deploy/Delete) (Optional)
     *             typeName: String (Optional)
     *             runner: String (Optional)
     *         }
     *     ]
     *     runner: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     *     eligibleForLatestVersion: Boolean (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param catalogItemId The unique id of the catalog item.
     * @param version The version of the catalog item.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a specific catalog item version from a project along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getCatalogItemVersionWithResponse(
            String projectName, String catalogItemId, String version, RequestOptions requestOptions) {
        return getCatalogItemVersionWithResponseAsync(projectName, catalogItemId, version, requestOptions).block();
    }

    /**
     * Lists all environment types configured for a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     deploymentTargetId: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return result of the environment type list operation along with {@link PagedResponse} on successful completion
     *     of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listEnvironmentTypesSinglePageAsync(
            String projectName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listEnvironmentTypes(
                                        this.client.getEndpoint(),
                                        this.client.getServiceVersion().getVersion(),
                                        projectName,
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Lists all environment types configured for a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     deploymentTargetId: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return result of the environment type list operation as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listEnvironmentTypesAsync(String projectName, RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listEnvironmentTypesSinglePageAsync(projectName, requestOptions),
                nextLink -> listEnvironmentTypesNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Lists all environment types configured for a project.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of resources to return from the operation. Example: 'top=10'.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     deploymentTargetId: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return result of the environment type list operation as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listEnvironmentTypes(String projectName, RequestOptions requestOptions) {
        return new PagedIterable<>(listEnvironmentTypesAsync(projectName, requestOptions));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the environment list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listEnvironmentsNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listEnvironmentsNext(
                                        nextLink, this.client.getEndpoint(), accept, requestOptions, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     description: String (Optional)
     *     catalogName: String (Optional)
     *     catalogItemName: String (Optional)
     *     parameters: Object (Optional)
     *     scheduledTasks (Optional): {
     *         String (Optional): {
     *             type: String(AutoExpire) (Required)
     *             enabled: String(Enabled/Disabled) (Optional)
     *             startTime: OffsetDateTime (Required)
     *         }
     *     }
     *     tags (Optional): {
     *         String: String (Optional)
     *     }
     *     name: String (Optional)
     *     environmentType: String (Required)
     *     user: String (Optional)
     *     provisioningState: String (Optional)
     *     resourceGroupId: String (Optional)
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the environment list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listEnvironmentsByUserNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listEnvironmentsByUserNext(
                                        nextLink, this.client.getEndpoint(), accept, requestOptions, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     name: String (Optional)
     *     catalogName: String (Optional)
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the catalog item list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listCatalogItemsNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listCatalogItemsNext(
                                        nextLink, this.client.getEndpoint(), accept, requestOptions, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     catalogItemId: String (Optional)
     *     catalogItemName: String (Optional)
     *     catalogName: String (Optional)
     *     version: String (Optional)
     *     summary: String (Optional)
     *     description: String (Optional)
     *     templatePath: String (Optional)
     *     parametersSchema: String (Optional)
     *     parameters (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             default: Object (Optional)
     *             type: String(array/boolean/integer/null/number/object/string) (Optional)
     *             readOnly: Boolean (Optional)
     *             required: Boolean (Optional)
     *             allowed (Optional): [
     *                 Object (Optional)
     *             ]
     *         }
     *     ]
     *     actions (Optional): [
     *          (Optional){
     *             id: String (Optional)
     *             name: String (Optional)
     *             description: String (Optional)
     *             parametersSchema: String (Optional)
     *             parameters (Optional): [
     *                 (recursive schema, see above)
     *             ]
     *             type: String(Custom/Deploy/Delete) (Optional)
     *             typeName: String (Optional)
     *             runner: String (Optional)
     *         }
     *     ]
     *     runner: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     *     eligibleForLatestVersion: Boolean (Optional)
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return results of the catalog item list operation along with {@link PagedResponse} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listCatalogItemVersionsNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listCatalogItemVersionsNext(
                                        nextLink, this.client.getEndpoint(), accept, requestOptions, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     deploymentTargetId: String (Optional)
     *     status: String(Enabled/Disabled) (Optional)
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return result of the environment type list operation along with {@link PagedResponse} on successful completion
     *     of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listEnvironmentTypesNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listEnvironmentTypesNext(
                                        nextLink, this.client.getEndpoint(), accept, requestOptions, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    private List<BinaryData> getValues(BinaryData binaryData, String path) {
        try {
            Map<?, ?> obj = binaryData.toObject(Map.class);
            List<?> values = (List<?>) obj.get(path);
            return values.stream().map(BinaryData::fromObject).collect(Collectors.toList());
        } catch (RuntimeException e) {
            return null;
        }
    }

    private String getNextLink(BinaryData binaryData, String path) {
        try {
            Map<?, ?> obj = binaryData.toObject(Map.class);
            return (String) obj.get(path);
        } catch (RuntimeException e) {
            return null;
        }
    }
}
