/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 4f6a7f9704c0 */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GleanCore } from "../core.js"; import { clientAuthenticationCreateToken } from "../funcs/clientAuthenticationCreateToken.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; import { GleanBaseError } from "../models/errors/gleanbaseerror.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import { unwrapAsync } from "../types/fp.js"; import { useGleanContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type ClientAuthenticationCreateTokenMutationVariables = { options?: RequestOptions; }; export type ClientAuthenticationCreateTokenMutationData = components.CreateAuthTokenResponse; export type ClientAuthenticationCreateTokenMutationError = | GleanBaseError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create authentication token * * @remarks * Creates an authentication token for the authenticated user. These are * specifically intended to be used with the [Web SDK](https://developers.glean.com/web). * * Note: The tokens generated from this endpoint are **not** valid tokens * for use with the Client API (e.g. `/rest/api/v1/*`). */ export function useClientAuthenticationCreateTokenMutation( options?: MutationHookOptions< ClientAuthenticationCreateTokenMutationData, ClientAuthenticationCreateTokenMutationError, ClientAuthenticationCreateTokenMutationVariables >, ): UseMutationResult< ClientAuthenticationCreateTokenMutationData, ClientAuthenticationCreateTokenMutationError, ClientAuthenticationCreateTokenMutationVariables > { const client = useGleanContext(); return useMutation({ ...buildClientAuthenticationCreateTokenMutation(client, options), ...options, }); } export function mutationKeyClientAuthenticationCreateToken(): MutationKey { return ["@gleanwork/api-client", "authentication", "createToken"]; } export function buildClientAuthenticationCreateTokenMutation( client$: GleanCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: ClientAuthenticationCreateTokenMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyClientAuthenticationCreateToken(), mutationFn: function clientAuthenticationCreateTokenMutationFn({ options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(clientAuthenticationCreateToken( client$, mergedOptions, )); }, }; }