import { WorkspaceScopedResource, extractData } from './base.js';
/**
 * Manage Amigo Platform workspaces.
 * Workspaces are the top-level tenancy boundary for all resources.
 *
 * Note: ``list`` operates at account level (``/v1/workspaces``).
 * Creation lives at ``/v1/me/workspaces`` — see ``MeResource``
 * (``client.me.createWorkspace``). The legacy
 * ``POST /v1/workspaces/self-service`` was removed in platform-api
 * PR #2472; ``/v1/workspaces/<x>`` paths now exclusively operate on
 * a specific workspace, so URL-parsing consumers can never confuse
 * an account-level operation with a workspace-scoped one.
 * Get/update/archive/provision operate on a specific workspace.
 */
export class WorkspacesResource extends WorkspaceScopedResource {
    /** List workspaces accessible to the current API key */
    async list(params) {
        return extractData(await this.client.GET('/v1/workspaces', {
            params: { query: params },
        }));
    }
    listAutoPaging(params) {
        return this.iteratePaginatedList((pageParams) => this.list(pageParams), params);
    }
    /** Get a single workspace by ID */
    async get(id) {
        return extractData(await this.client.GET('/v1/workspaces/{workspace_id}', {
            params: { path: { workspace_id: id ?? this.workspaceId } },
        }));
    }
    /** Update workspace metadata */
    async update(body, id) {
        return extractData(await this.client.PATCH('/v1/workspaces/{workspace_id}', {
            params: { path: { workspace_id: id ?? this.workspaceId } },
            body,
        }));
    }
    /** Archive (soft-delete) a workspace */
    async archive(body, id) {
        return extractData(await this.client.POST('/v1/workspaces/{workspace_id}/archive', {
            params: { path: { workspace_id: id ?? this.workspaceId } },
            body,
        }));
    }
    /** Provision a workspace (seed integrations, mark as provisioned) */
    async provision(id) {
        return extractData(await this.client.POST('/v1/workspaces/{workspace_id}/provision', {
            params: { path: { workspace_id: id ?? this.workspaceId } },
        }));
    }
    /** Pre-check environment conversion warnings */
    async checkEnvironment(target, id) {
        return extractData(await this.client.GET('/v1/workspaces/{workspace_id}/environment-check', {
            params: {
                path: { workspace_id: id ?? this.workspaceId },
                query: target ? { target } : undefined,
            },
        }));
    }
    /** Convert workspace between staging and production */
    async convertEnvironment(body, id) {
        return extractData(await this.client.POST('/v1/workspaces/{workspace_id}/convert-environment', {
            params: { path: { workspace_id: id ?? this.workspaceId } },
            body,
        }));
    }
    /**
     * Workspace-allowlisted phone numbers that can place test calls into voice
     * agents. The list is read-mostly; writes overwrite the entire allowlist.
     *
     * Always operates on the bound workspace. Use `client.withOptions(...)` or
     * construct a second `AmigoClient` if you need to act on a different
     * workspace.
     */
    testCallerNumbers = {
        /** Get the workspace's test caller allowlist */
        get: async () => extractData(await this.client.GET('/v1/workspaces/{workspace_id}/test-caller-numbers', {
            params: { path: { workspace_id: this.workspaceId } },
        })),
        /**
         * Replace the workspace's test caller allowlist.
         *
         * **Replace-all semantics:** the request body fully replaces the existing
         * allowlist; numbers omitted from `body` are removed. Read first, mutate,
         * then write to add/remove individual entries safely.
         */
        update: async (body) => extractData(await this.client.PUT('/v1/workspaces/{workspace_id}/test-caller-numbers', {
            params: { path: { workspace_id: this.workspaceId } },
            body,
        })),
    };
}
//# sourceMappingURL=workspaces.js.map