/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { SDKCore } from "../core.js"; import { budgetsSetTeam } from "../funcs/budgetsSetTeam.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 BudgetsSetTeamMutationVariables = { request: operations.SetTeamBudgetRequest; options?: RequestOptions; }; export type BudgetsSetTeamMutationData = operations.SetTeamBudgetResponseBody; export type BudgetsSetTeamMutationError = | SDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Set a team budget * * @remarks * Creates or updates a budget for the team in the target org. One budget per (scope, owner); editing re-evaluates against live spend. An explicit team budget replaces the org's per-team default budget of the same owner and period for this team (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 teams in their own organization (owner=org). */ export function useBudgetsSetTeamMutation( options?: MutationHookOptions< BudgetsSetTeamMutationData, BudgetsSetTeamMutationError, BudgetsSetTeamMutationVariables >, ): UseMutationResult< BudgetsSetTeamMutationData, BudgetsSetTeamMutationError, BudgetsSetTeamMutationVariables > { const client = useSDKContext(); return useMutation({ ...buildBudgetsSetTeamMutation(client, options), ...options, }); } export function mutationKeyBudgetsSetTeam(): MutationKey { return ["@meetkai/mka1", "budgets", "setTeam"]; } export function buildBudgetsSetTeamMutation( client$: SDKCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: BudgetsSetTeamMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyBudgetsSetTeam(), mutationFn: function budgetsSetTeamMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(budgetsSetTeam( client$, request, mergedOptions, )); }, }; }