/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { InvalidateQueryFilters, QueryClient, useQuery, UseQueryResult, useSuspenseQuery, UseSuspenseQueryResult, } from "@tanstack/react-query"; import * as components from "../models/components/index.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; import * as errors from "../models/errors/index.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { useSDKContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildUsageSandboxQuery, prefetchUsageSandbox, queryKeyUsageSandbox, UsageSandboxQueryData, } from "./usageSandbox.core.js"; export { buildUsageSandboxQuery, prefetchUsageSandbox, queryKeyUsageSandbox, type UsageSandboxQueryData, }; export type UsageSandboxQueryError = | errors.HTTPValidationError | SDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get Sandbox Usage * * @remarks * Aggregate sandbox usage (session lifecycle, execution, and workspace operations) over a time range, bucketed and optionally grouped. Buckets are calendar-aligned in UTC: `start_time` is snapped down and `end_time` snapped up to the nearest bucket-width boundary, so the first and last buckets may extend slightly beyond the requested range. Org-scoped: callers see their own usage, org admins their team's; cluster admins may pass `all_orgs` or `org_ids`. Cost and spend reporting lives in the budgeting API (`/api/v1/budgeting/usage/costs`). */ export function useUsageSandbox( request: operations.GetSandboxUsageRequest, options?: QueryHookOptions, ): UseQueryResult { const client = useSDKContext(); return useQuery({ ...buildUsageSandboxQuery( client, request, options, ), ...options, }); } /** * Get Sandbox Usage * * @remarks * Aggregate sandbox usage (session lifecycle, execution, and workspace operations) over a time range, bucketed and optionally grouped. Buckets are calendar-aligned in UTC: `start_time` is snapped down and `end_time` snapped up to the nearest bucket-width boundary, so the first and last buckets may extend slightly beyond the requested range. Org-scoped: callers see their own usage, org admins their team's; cluster admins may pass `all_orgs` or `org_ids`. Cost and spend reporting lives in the budgeting API (`/api/v1/budgeting/usage/costs`). */ export function useUsageSandboxSuspense( request: operations.GetSandboxUsageRequest, options?: SuspenseQueryHookOptions< UsageSandboxQueryData, UsageSandboxQueryError >, ): UseSuspenseQueryResult { const client = useSDKContext(); return useSuspenseQuery({ ...buildUsageSandboxQuery( client, request, options, ), ...options, }); } export function setUsageSandboxData( client: QueryClient, queryKeyBase: [ parameters: { startTime: number; endTime?: number | null | undefined; bucketWidth?: components.SandboxUsageBucketWidth | undefined; groupBy?: Array | null | undefined; allOrgs?: boolean | undefined; orgIds?: Array | null | undefined; xOnBehalfOf?: string | undefined; }, ], data: UsageSandboxQueryData, ): UsageSandboxQueryData | undefined { const key = queryKeyUsageSandbox(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateUsageSandbox( client: QueryClient, queryKeyBase: TupleToPrefixes< [parameters: { startTime: number; endTime?: number | null | undefined; bucketWidth?: components.SandboxUsageBucketWidth | undefined; groupBy?: Array | null | undefined; allOrgs?: boolean | undefined; orgIds?: Array | null | undefined; xOnBehalfOf?: string | undefined; }] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@meetkai/mka1", "usage", "sandbox", ...queryKeyBase], }); } export function invalidateAllUsageSandbox( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@meetkai/mka1", "usage", "sandbox"], }); }