// 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.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.time.OffsetDateTime;
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 DevBoxes. */
public final class DevBoxesImpl {
    /** The proxy service used to perform REST calls. */
    private final DevBoxesService service;

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

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

    /**
     * The interface defining all the services for DevCenterDevBoxes to be used by the proxy service to perform REST
     * calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "DevCenterDevBoxes")
    public interface DevBoxesService {
        @Get("/projects/{projectName}/pools")
        @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>> listPools(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/pools/{poolName}")
        @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>> getPool(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("poolName") String poolName,
                @PathParam("projectName") String projectName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/pools/{poolName}/schedules")
        @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>> listSchedulesByPool(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("poolName") String poolName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}")
        @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>> getScheduleByPool(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("poolName") String poolName,
                @PathParam("scheduleName") String scheduleName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/users/{userId}/devboxes")
        @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>> listDevBoxesByUser(
                @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}/devboxes/{devBoxName}")
        @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>> getDevBoxByUser(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Put("/projects/{projectName}/users/{userId}/devboxes/{devBoxName}")
        @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>> createDevBox(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @BodyParam("application/json") BinaryData body,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Delete("/projects/{projectName}/users/{userId}/devboxes/{devBoxName}")
        @ExpectedResponses({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>> deleteDevBox(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:start")
        @ExpectedResponses({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>> startDevBox(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:stop")
        @ExpectedResponses({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>> stopDevBox(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/remoteConnection")
        @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>> getRemoteConnection(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/upcomingActions")
        @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>> listUpcomingActions(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/upcomingActions/{upcomingActionId}")
        @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>> getUpcomingAction(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @PathParam("upcomingActionId") String upcomingActionId,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/upcomingActions/{upcomingActionId}:skip")
        @ExpectedResponses({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>> skipUpcomingAction(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @PathParam("upcomingActionId") String upcomingActionId,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/upcomingActions/{upcomingActionId}:delay")
        @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>> delayUpcomingAction(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("projectName") String projectName,
                @PathParam("userId") String userId,
                @PathParam("devBoxName") String devBoxName,
                @PathParam("upcomingActionId") String upcomingActionId,
                @QueryParam("delayUntil") OffsetDateTime delayUntil,
                @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>> listPoolsNext(
                @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>> listSchedulesByPoolNext(
                @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>> listDevBoxesByUserNext(
                @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>> listUpcomingActionsNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);
    }

    /**
     * Lists available pools.
     *
     * <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>
     *     <tr><td>filter</td><td>String</td><td>No</td><td>An OData filter clause to apply to the operation.</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)
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     localAdministrator: 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 the Pool list result along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listPoolsSinglePageAsync(
            String projectName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listPools(
                                        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 available pools.
     *
     * <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>
     *     <tr><td>filter</td><td>String</td><td>No</td><td>An OData filter clause to apply to the operation.</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)
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     localAdministrator: 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 the Pool list result as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listPoolsAsync(String projectName, RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listPoolsSinglePageAsync(projectName, requestOptions),
                nextLink -> listPoolsNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Lists available pools.
     *
     * <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>
     *     <tr><td>filter</td><td>String</td><td>No</td><td>An OData filter clause to apply to the operation.</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)
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     localAdministrator: 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 the Pool list result as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listPools(String projectName, RequestOptions requestOptions) {
        return new PagedIterable<>(listPoolsAsync(projectName, requestOptions));
    }

    /**
     * Gets a pool.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     localAdministrator: String(Enabled/Disabled) (Optional)
     * }
     * }</pre>
     *
     * @param poolName The name of a pool of Dev Boxes.
     * @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 a pool along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getPoolWithResponseAsync(
            String poolName, String projectName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getPool(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                poolName,
                                projectName,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Gets a pool.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     localAdministrator: String(Enabled/Disabled) (Optional)
     * }
     * }</pre>
     *
     * @param poolName The name of a pool of Dev Boxes.
     * @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 a pool along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getPoolWithResponse(
            String poolName, String projectName, RequestOptions requestOptions) {
        return getPoolWithResponseAsync(poolName, projectName, requestOptions).block();
    }

    /**
     * Lists available schedules for a pool.
     *
     * <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>
     *     <tr><td>filter</td><td>String</td><td>No</td><td>An OData filter clause to apply to the operation.</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)
     *     type: String(StopDevBox) (Optional)
     *     frequency: String(Daily) (Optional)
     *     time: String (Optional)
     *     timeZone: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param poolName The name of a pool of Dev Boxes.
     * @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 Schedule list result along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listSchedulesByPoolSinglePageAsync(
            String projectName, String poolName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listSchedulesByPool(
                                        this.client.getEndpoint(),
                                        this.client.getServiceVersion().getVersion(),
                                        projectName,
                                        poolName,
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Lists available schedules for a pool.
     *
     * <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>
     *     <tr><td>filter</td><td>String</td><td>No</td><td>An OData filter clause to apply to the operation.</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)
     *     type: String(StopDevBox) (Optional)
     *     frequency: String(Daily) (Optional)
     *     time: String (Optional)
     *     timeZone: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param poolName The name of a pool of Dev Boxes.
     * @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 Schedule list result as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listSchedulesByPoolAsync(
            String projectName, String poolName, RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listSchedulesByPoolSinglePageAsync(projectName, poolName, requestOptions),
                nextLink -> listSchedulesByPoolNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Lists available schedules for a pool.
     *
     * <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>
     *     <tr><td>filter</td><td>String</td><td>No</td><td>An OData filter clause to apply to the operation.</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)
     *     type: String(StopDevBox) (Optional)
     *     frequency: String(Daily) (Optional)
     *     time: String (Optional)
     *     timeZone: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param poolName The name of a pool of Dev Boxes.
     * @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 Schedule list result as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listSchedulesByPool(
            String projectName, String poolName, RequestOptions requestOptions) {
        return new PagedIterable<>(listSchedulesByPoolAsync(projectName, poolName, requestOptions));
    }

    /**
     * Gets a schedule.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     type: String(StopDevBox) (Optional)
     *     frequency: String(Daily) (Optional)
     *     time: String (Optional)
     *     timeZone: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param poolName The name of a pool of Dev Boxes.
     * @param scheduleName The name of a schedule.
     * @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 schedule along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getScheduleByPoolWithResponseAsync(
            String projectName, String poolName, String scheduleName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getScheduleByPool(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                poolName,
                                scheduleName,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Gets a schedule.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     type: String(StopDevBox) (Optional)
     *     frequency: String(Daily) (Optional)
     *     time: String (Optional)
     *     timeZone: String (Optional)
     * }
     * }</pre>
     *
     * @param projectName The DevCenter Project upon which to execute operations.
     * @param poolName The name of a pool of Dev Boxes.
     * @param scheduleName The name of a schedule.
     * @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 schedule along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getScheduleByPoolWithResponse(
            String projectName, String poolName, String scheduleName, RequestOptions requestOptions) {
        return getScheduleByPoolWithResponseAsync(projectName, poolName, scheduleName, requestOptions).block();
    }

    /**
     * Lists Dev Boxes in the project for a particular 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>filter</td><td>String</td><td>No</td><td>An OData filter clause to apply to the operation.</td></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)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (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 the Dev Box list result along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listDevBoxesByUserSinglePageAsync(
            String projectName, String userId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listDevBoxesByUser(
                                        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 Dev Boxes in the project for a particular 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>filter</td><td>String</td><td>No</td><td>An OData filter clause to apply to the operation.</td></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)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (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 the Dev Box list result as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listDevBoxesByUserAsync(
            String projectName, String userId, RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listDevBoxesByUserSinglePageAsync(projectName, userId, requestOptions),
                nextLink -> listDevBoxesByUserNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Lists Dev Boxes in the project for a particular 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>filter</td><td>String</td><td>No</td><td>An OData filter clause to apply to the operation.</td></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)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (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 the Dev Box list result as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listDevBoxesByUser(
            String projectName, String userId, RequestOptions requestOptions) {
        return new PagedIterable<>(listDevBoxesByUserAsync(projectName, userId, requestOptions));
    }

    /**
     * Gets a Dev Box.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (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 devBoxName The name of a Dev Box.
     * @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 Dev Box along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getDevBoxByUserWithResponseAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getDevBoxByUser(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                devBoxName,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Gets a Dev Box.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (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 devBoxName The name of a Dev Box.
     * @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 Dev Box along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getDevBoxByUserWithResponse(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        return getDevBoxByUserWithResponseAsync(projectName, userId, devBoxName, requestOptions).block();
    }

    /**
     * Creates or updates a Dev Box.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (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 devBoxName The name of a Dev Box.
     * @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 a DevBox Dev Box along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BinaryData>> createDevBoxWithResponseAsync(
            String projectName, String userId, String devBoxName, BinaryData body, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createDevBox(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                devBoxName,
                                body,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Creates or updates a Dev Box.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (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 devBoxName The name of a Dev Box.
     * @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 a DevBox Dev Box.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public PollerFlux<BinaryData, BinaryData> beginCreateDevBoxAsync(
            String projectName, String userId, String devBoxName, BinaryData body, RequestOptions requestOptions) {
        return PollerFlux.create(
                Duration.ofSeconds(1),
                () -> this.createDevBoxWithResponseAsync(projectName, userId, devBoxName, 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 a Dev Box.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: String(Enabled/Disabled) (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 devBoxName The name of a Dev Box.
     * @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 a DevBox Dev Box.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<BinaryData, BinaryData> beginCreateDevBox(
            String projectName, String userId, String devBoxName, BinaryData body, RequestOptions requestOptions) {
        return this.beginCreateDevBoxAsync(projectName, userId, devBoxName, body, requestOptions).getSyncPoller();
    }

    /**
     * Deletes a Dev Box.
     *
     * @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 devBoxName The name of a Dev Box.
     * @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>> deleteDevBoxWithResponseAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.deleteDevBox(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                devBoxName,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Deletes a Dev Box.
     *
     * @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 devBoxName The name of a Dev Box.
     * @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> beginDeleteDevBoxAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        return PollerFlux.create(
                Duration.ofSeconds(1),
                () -> this.deleteDevBoxWithResponseAsync(projectName, userId, devBoxName, 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 a Dev Box.
     *
     * @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 devBoxName The name of a Dev Box.
     * @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> beginDeleteDevBox(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        return this.beginDeleteDevBoxAsync(projectName, userId, devBoxName, requestOptions).getSyncPoller();
    }

    /**
     * Starts a Dev Box.
     *
     * @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 devBoxName The name of a Dev Box.
     * @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>> startDevBoxWithResponseAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.startDevBox(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                devBoxName,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Starts a Dev Box.
     *
     * @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 devBoxName The name of a Dev Box.
     * @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> beginStartDevBoxAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        return PollerFlux.create(
                Duration.ofSeconds(1),
                () -> this.startDevBoxWithResponseAsync(projectName, userId, devBoxName, 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));
    }

    /**
     * Starts a Dev Box.
     *
     * @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 devBoxName The name of a Dev Box.
     * @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> beginStartDevBox(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        return this.beginStartDevBoxAsync(projectName, userId, devBoxName, requestOptions).getSyncPoller();
    }

    /**
     * Stops a Dev Box.
     *
     * <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>hibernate</td><td>Boolean</td><td>No</td><td>Optional parameter to hibernate the dev box.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * @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 devBoxName The name of a Dev Box.
     * @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>> stopDevBoxWithResponseAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.stopDevBox(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                devBoxName,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Stops a Dev Box.
     *
     * <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>hibernate</td><td>Boolean</td><td>No</td><td>Optional parameter to hibernate the dev box.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * @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 devBoxName The name of a Dev Box.
     * @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> beginStopDevBoxAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        return PollerFlux.create(
                Duration.ofSeconds(1),
                () -> this.stopDevBoxWithResponseAsync(projectName, userId, devBoxName, 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));
    }

    /**
     * Stops a Dev Box.
     *
     * <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>hibernate</td><td>Boolean</td><td>No</td><td>Optional parameter to hibernate the dev box.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * @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 devBoxName The name of a Dev Box.
     * @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> beginStopDevBox(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        return this.beginStopDevBoxAsync(projectName, userId, devBoxName, requestOptions).getSyncPoller();
    }

    /**
     * Gets RDP Connection info.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     webUrl: String (Optional)
     *     rdpConnectionUrl: 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 devBoxName The name of a Dev Box.
     * @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 rDP Connection info along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getRemoteConnectionWithResponseAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getRemoteConnection(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                devBoxName,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Gets RDP Connection info.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     webUrl: String (Optional)
     *     rdpConnectionUrl: 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 devBoxName The name of a Dev Box.
     * @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 rDP Connection info along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getRemoteConnectionWithResponse(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        return getRemoteConnectionWithResponseAsync(projectName, userId, devBoxName, requestOptions).block();
    }

    /**
     * Lists upcoming actions on a Dev Box.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     actionType: String(Stop) (Optional)
     *     reason: String(Schedule) (Optional)
     *     scheduledTime: OffsetDateTime (Optional)
     *     originalScheduledTime: OffsetDateTime (Optional)
     *     sourceId: 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 devBoxName The name of a Dev Box.
     * @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 Upcoming Action list result along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listUpcomingActionsSinglePageAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listUpcomingActions(
                                        this.client.getEndpoint(),
                                        this.client.getServiceVersion().getVersion(),
                                        projectName,
                                        userId,
                                        devBoxName,
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Lists upcoming actions on a Dev Box.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     actionType: String(Stop) (Optional)
     *     reason: String(Schedule) (Optional)
     *     scheduledTime: OffsetDateTime (Optional)
     *     originalScheduledTime: OffsetDateTime (Optional)
     *     sourceId: 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 devBoxName The name of a Dev Box.
     * @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 Upcoming Action list result as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listUpcomingActionsAsync(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listUpcomingActionsSinglePageAsync(projectName, userId, devBoxName, requestOptions),
                nextLink -> listUpcomingActionsNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Lists upcoming actions on a Dev Box.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     actionType: String(Stop) (Optional)
     *     reason: String(Schedule) (Optional)
     *     scheduledTime: OffsetDateTime (Optional)
     *     originalScheduledTime: OffsetDateTime (Optional)
     *     sourceId: 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 devBoxName The name of a Dev Box.
     * @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 Upcoming Action list result as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listUpcomingActions(
            String projectName, String userId, String devBoxName, RequestOptions requestOptions) {
        return new PagedIterable<>(listUpcomingActionsAsync(projectName, userId, devBoxName, requestOptions));
    }

    /**
     * Gets an Upcoming Action.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     actionType: String(Stop) (Optional)
     *     reason: String(Schedule) (Optional)
     *     scheduledTime: OffsetDateTime (Optional)
     *     originalScheduledTime: OffsetDateTime (Optional)
     *     sourceId: 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 devBoxName The name of a Dev Box.
     * @param upcomingActionId The upcoming action id.
     * @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 Upcoming Action along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getUpcomingActionWithResponseAsync(
            String projectName,
            String userId,
            String devBoxName,
            String upcomingActionId,
            RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getUpcomingAction(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                devBoxName,
                                upcomingActionId,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Gets an Upcoming Action.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     actionType: String(Stop) (Optional)
     *     reason: String(Schedule) (Optional)
     *     scheduledTime: OffsetDateTime (Optional)
     *     originalScheduledTime: OffsetDateTime (Optional)
     *     sourceId: 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 devBoxName The name of a Dev Box.
     * @param upcomingActionId The upcoming action id.
     * @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 Upcoming Action along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getUpcomingActionWithResponse(
            String projectName,
            String userId,
            String devBoxName,
            String upcomingActionId,
            RequestOptions requestOptions) {
        return getUpcomingActionWithResponseAsync(projectName, userId, devBoxName, upcomingActionId, requestOptions)
                .block();
    }

    /**
     * Skips an Upcoming Action.
     *
     * @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 devBoxName The name of a Dev Box.
     * @param upcomingActionId The upcoming action id.
     * @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)
    public Mono<Response<Void>> skipUpcomingActionWithResponseAsync(
            String projectName,
            String userId,
            String devBoxName,
            String upcomingActionId,
            RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.skipUpcomingAction(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                devBoxName,
                                upcomingActionId,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Skips an Upcoming Action.
     *
     * @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 devBoxName The name of a Dev Box.
     * @param upcomingActionId The upcoming action id.
     * @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}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> skipUpcomingActionWithResponse(
            String projectName,
            String userId,
            String devBoxName,
            String upcomingActionId,
            RequestOptions requestOptions) {
        return skipUpcomingActionWithResponseAsync(projectName, userId, devBoxName, upcomingActionId, requestOptions)
                .block();
    }

    /**
     * Delays an Upcoming Action.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     actionType: String(Stop) (Optional)
     *     reason: String(Schedule) (Optional)
     *     scheduledTime: OffsetDateTime (Optional)
     *     originalScheduledTime: OffsetDateTime (Optional)
     *     sourceId: 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 devBoxName The name of a Dev Box.
     * @param upcomingActionId The upcoming action id.
     * @param delayUntil The delayed action time (UTC).
     * @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 upcoming Action along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> delayUpcomingActionWithResponseAsync(
            String projectName,
            String userId,
            String devBoxName,
            String upcomingActionId,
            OffsetDateTime delayUntil,
            RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.delayUpcomingAction(
                                this.client.getEndpoint(),
                                this.client.getServiceVersion().getVersion(),
                                projectName,
                                userId,
                                devBoxName,
                                upcomingActionId,
                                delayUntil,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Delays an Upcoming Action.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     actionType: String(Stop) (Optional)
     *     reason: String(Schedule) (Optional)
     *     scheduledTime: OffsetDateTime (Optional)
     *     originalScheduledTime: OffsetDateTime (Optional)
     *     sourceId: 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 devBoxName The name of a Dev Box.
     * @param upcomingActionId The upcoming action id.
     * @param delayUntil The delayed action time (UTC).
     * @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 upcoming Action along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> delayUpcomingActionWithResponse(
            String projectName,
            String userId,
            String devBoxName,
            String upcomingActionId,
            OffsetDateTime delayUntil,
            RequestOptions requestOptions) {
        return delayUpcomingActionWithResponseAsync(
                        projectName, userId, devBoxName, upcomingActionId, delayUntil, requestOptions)
                .block();
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     name: String (Optional)
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     localAdministrator: 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 the Pool list result along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listPoolsNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listPoolsNext(
                                        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)
     *     type: String(StopDevBox) (Optional)
     *     frequency: String(Daily) (Optional)
     *     time: String (Optional)
     *     timeZone: 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 the Schedule list result along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listSchedulesByPoolNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listSchedulesByPoolNext(
                                        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)
     *     projectName: String (Optional)
     *     poolName: String (Required)
     *     hibernateSupport: String(Disabled/Enabled) (Optional)
     *     provisioningState: String (Optional)
     *     actionState: String (Optional)
     *     powerState: String(Unknown/Deallocated/PoweredOff/Running/Hibernated) (Optional)
     *     uniqueId: String (Optional)
     *     errorDetails (Optional): {
     *         code: String (Optional)
     *         message: String (Optional)
     *     }
     *     location: String (Optional)
     *     osType: String(Windows) (Optional)
     *     user: String (Optional)
     *     hardwareProfile (Optional): {
     *         skuName: String (Optional)
     *         vCPUs: Integer (Optional)
     *         memoryGB: Integer (Optional)
     *     }
     *     storageProfile (Optional): {
     *         osDisk (Optional): {
     *             diskSizeGB: Integer (Optional)
     *         }
     *     }
     *     imageReference (Optional): {
     *         name: String (Optional)
     *         version: String (Optional)
     *         operatingSystem: String (Optional)
     *         osBuildNumber: String (Optional)
     *         publishedDate: OffsetDateTime (Optional)
     *     }
     *     createdTime: OffsetDateTime (Optional)
     *     localAdministrator: 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 the Dev Box list result along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listDevBoxesByUserNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listDevBoxesByUserNext(
                                        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)
     *     actionType: String(Stop) (Optional)
     *     reason: String(Schedule) (Optional)
     *     scheduledTime: OffsetDateTime (Optional)
     *     originalScheduledTime: OffsetDateTime (Optional)
     *     sourceId: 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 the Upcoming Action list result along with {@link PagedResponse} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listUpcomingActionsNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listUpcomingActionsNext(
                                        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;
        }
    }
}
