/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { SDKCore } from "../core.js"; import { budgetsSetUser } from "../funcs/budgetsSetUser.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.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 { unwrapAsync } from "../types/fp.js"; import { useSDKContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type BudgetsSetUserMutationVariables = { request: operations.SetUserBudgetRequest; options?: RequestOptions; }; export type BudgetsSetUserMutationData = operations.SetUserBudgetResponseBody; export type BudgetsSetUserMutationError = | SDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Set a user budget * * @remarks * Creates or updates a budget for the user in the target org. One budget per (scope, owner); editing re-evaluates against live spend. An explicit user budget replaces the org's per-user default budget of the same owner and period for this user (exemption-by-override — it may raise or tighten it); different-period defaults, org budgets, and API-key budgets still apply. Targets the caller's own organization (inferred from the API key or session) unless the optional org_id query parameter names another org — cluster admins only. Callable by cluster admins, or org admins for users in their own organization (owner=org). */ export function useBudgetsSetUserMutation( options?: MutationHookOptions< BudgetsSetUserMutationData, BudgetsSetUserMutationError, BudgetsSetUserMutationVariables >, ): UseMutationResult< BudgetsSetUserMutationData, BudgetsSetUserMutationError, BudgetsSetUserMutationVariables > { const client = useSDKContext(); return useMutation({ ...buildBudgetsSetUserMutation(client, options), ...options, }); } export function mutationKeyBudgetsSetUser(): MutationKey { return ["@meetkai/mka1", "budgets", "setUser"]; } export function buildBudgetsSetUserMutation( client$: SDKCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: BudgetsSetUserMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyBudgetsSetUser(), mutationFn: function budgetsSetUserMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(budgetsSetUser( client$, request, mergedOptions, )); }, }; }