/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { SDKCore } from "../core.js"; import { budgetsSetOrg } from "../funcs/budgetsSetOrg.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 BudgetsSetOrgMutationVariables = { request: operations.SetOrgBudgetRequest; options?: RequestOptions; }; export type BudgetsSetOrgMutationData = operations.SetOrgBudgetResponseBody; export type BudgetsSetOrgMutationError = | SDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Set an org budget * * @remarks * Creates or updates a budget for the org. One budget per (scope, owner); editing re-evaluates against live spend. 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. */ export function useBudgetsSetOrgMutation( options?: MutationHookOptions< BudgetsSetOrgMutationData, BudgetsSetOrgMutationError, BudgetsSetOrgMutationVariables >, ): UseMutationResult< BudgetsSetOrgMutationData, BudgetsSetOrgMutationError, BudgetsSetOrgMutationVariables > { const client = useSDKContext(); return useMutation({ ...buildBudgetsSetOrgMutation(client, options), ...options, }); } export function mutationKeyBudgetsSetOrg(): MutationKey { return ["@meetkai/mka1", "budgets", "setOrg"]; } export function buildBudgetsSetOrgMutation( client$: SDKCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: BudgetsSetOrgMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyBudgetsSetOrg(), mutationFn: function budgetsSetOrgMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(budgetsSetOrg( client$, request, mergedOptions, )); }, }; }