/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: e56c0845e38e */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GleanCore } from "../core.js"; import { indexingAuthenticationRotateToken } from "../funcs/indexingAuthenticationRotateToken.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 IndexingAuthenticationRotateTokenMutationVariables = { options?: RequestOptions; }; export type IndexingAuthenticationRotateTokenMutationData = components.RotateTokenResponse; export type IndexingAuthenticationRotateTokenMutationError = | GleanBaseError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Rotate token * * @remarks * Rotates the secret value inside the Indexing API token and returns the new raw secret. All other properties of the token are unchanged. In order to rotate the secret value, include the token as the bearer token in the `/rotatetoken` request. Please refer to [Token rotation](https://developers.glean.com/indexing/authentication/token-rotation) documentation for more information. */ export function useIndexingAuthenticationRotateTokenMutation( options?: MutationHookOptions< IndexingAuthenticationRotateTokenMutationData, IndexingAuthenticationRotateTokenMutationError, IndexingAuthenticationRotateTokenMutationVariables >, ): UseMutationResult< IndexingAuthenticationRotateTokenMutationData, IndexingAuthenticationRotateTokenMutationError, IndexingAuthenticationRotateTokenMutationVariables > { const client = useGleanContext(); return useMutation({ ...buildIndexingAuthenticationRotateTokenMutation(client, options), ...options, }); } export function mutationKeyIndexingAuthenticationRotateToken(): MutationKey { return ["@gleanwork/api-client", "authentication", "rotateToken"]; } export function buildIndexingAuthenticationRotateTokenMutation( client$: GleanCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: IndexingAuthenticationRotateTokenMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyIndexingAuthenticationRotateToken(), mutationFn: function indexingAuthenticationRotateTokenMutationFn({ options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(indexingAuthenticationRotateToken( client$, mergedOptions, )); }, }; }