/*
 * Copyright (c) 2023-2025 Datalayer, Inc.
 * Distributed under the terms of the Modified BSD License.
 */
/**
 * Computing environments API functions for the Datalayer platform.
 *
 * Provides functions for managing computing environment configurations.
 *
 * @module api/runtimes/environments
 */
import { requestDatalayerAPI } from '../DatalayerApi.js';
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants.js';
import { validateToken } from '../utils/validation.js';
/**
 * List all available computing environments.
 * @param token - Authentication token
 * @param baseUrl - Base URL for the API (defaults to production Runtimes URL)
 * @returns Promise resolving to list of available environments
 * @throws {Error} If authentication token is missing or invalid
 */
export const listEnvironments = async (token, baseUrl = DEFAULT_SERVICE_URLS.RUNTIMES) => {
    validateToken(token);
    return requestDatalayerAPI({
        url: `${baseUrl}${API_BASE_PATHS.RUNTIMES}/environments`,
        method: 'GET',
        token,
    });
};
