/**
 * ! Do not edit manually
 * * The file has been auto-generated using Orval for SigNoz
 * * regenerate with 'yarn generate:api'
 * SigNoz
 */
import { useMutation, useQuery } from 'react-query';
import type {
	InvalidateOptions,
	MutationFunction,
	QueryClient,
	QueryFunction,
	QueryKey,
	UseMutationOptions,
	UseMutationResult,
	UseQueryOptions,
	UseQueryResult,
} from 'react-query';

import type {
	CreateIngestionKey201,
	CreateIngestionKeyLimit201,
	CreateIngestionKeyLimitPathParameters,
	DeleteIngestionKeyLimitPathParameters,
	DeleteIngestionKeyPathParameters,
	GatewaytypesPostableIngestionKeyDTO,
	GatewaytypesPostableIngestionKeyLimitDTO,
	GatewaytypesUpdatableIngestionKeyLimitDTO,
	GetIngestionKeys200,
	GetIngestionKeysParams,
	RenderErrorResponseDTO,
	SearchIngestionKeys200,
	SearchIngestionKeysParams,
	UpdateIngestionKeyLimitPathParameters,
	UpdateIngestionKeyPathParameters,
} from '../sigNoz.schemas';

import { GeneratedAPIInstance } from '../../../generatedAPIInstance';
import type { ErrorType, BodyType } from '../../../generatedAPIInstance';

/**
 * This endpoint returns the ingestion keys for a workspace
 * @summary Get ingestion keys for workspace
 */
export const getIngestionKeys = (
	params?: GetIngestionKeysParams,
	signal?: AbortSignal,
) => {
	return GeneratedAPIInstance<GetIngestionKeys200>({
		url: `/api/v2/gateway/ingestion_keys`,
		method: 'GET',
		params,
		signal,
	});
};

export const getGetIngestionKeysQueryKey = (
	params?: GetIngestionKeysParams,
) => {
	return [
		`/api/v2/gateway/ingestion_keys`,
		...(params ? [params] : []),
	] as const;
};

export const getGetIngestionKeysQueryOptions = <
	TData = Awaited<ReturnType<typeof getIngestionKeys>>,
	TError = ErrorType<RenderErrorResponseDTO>,
>(
	params?: GetIngestionKeysParams,
	options?: {
		query?: UseQueryOptions<
			Awaited<ReturnType<typeof getIngestionKeys>>,
			TError,
			TData
		>;
	},
) => {
	const { query: queryOptions } = options ?? {};

	const queryKey = queryOptions?.queryKey ?? getGetIngestionKeysQueryKey(params);

	const queryFn: QueryFunction<Awaited<ReturnType<typeof getIngestionKeys>>> = ({
		signal,
	}) => getIngestionKeys(params, signal);

	return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
		Awaited<ReturnType<typeof getIngestionKeys>>,
		TError,
		TData
	> & { queryKey: QueryKey };
};

export type GetIngestionKeysQueryResult = NonNullable<
	Awaited<ReturnType<typeof getIngestionKeys>>
>;
export type GetIngestionKeysQueryError = ErrorType<RenderErrorResponseDTO>;

/**
 * @summary Get ingestion keys for workspace
 */

export function useGetIngestionKeys<
	TData = Awaited<ReturnType<typeof getIngestionKeys>>,
	TError = ErrorType<RenderErrorResponseDTO>,
>(
	params?: GetIngestionKeysParams,
	options?: {
		query?: UseQueryOptions<
			Awaited<ReturnType<typeof getIngestionKeys>>,
			TError,
			TData
		>;
	},
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
	const queryOptions = getGetIngestionKeysQueryOptions(params, options);

	const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
		queryKey: QueryKey;
	};

	query.queryKey = queryOptions.queryKey;

	return query;
}

/**
 * @summary Get ingestion keys for workspace
 */
export const invalidateGetIngestionKeys = async (
	queryClient: QueryClient,
	params?: GetIngestionKeysParams,
	options?: InvalidateOptions,
): Promise<QueryClient> => {
	await queryClient.invalidateQueries(
		{ queryKey: getGetIngestionKeysQueryKey(params) },
		options,
	);

	return queryClient;
};

/**
 * This endpoint creates an ingestion key for the workspace
 * @summary Create ingestion key for workspace
 */
export const createIngestionKey = (
	gatewaytypesPostableIngestionKeyDTO: BodyType<GatewaytypesPostableIngestionKeyDTO>,
	signal?: AbortSignal,
) => {
	return GeneratedAPIInstance<CreateIngestionKey201>({
		url: `/api/v2/gateway/ingestion_keys`,
		method: 'POST',
		headers: { 'Content-Type': 'application/json' },
		data: gatewaytypesPostableIngestionKeyDTO,
		signal,
	});
};

export const getCreateIngestionKeyMutationOptions = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof createIngestionKey>>,
		TError,
		{ data: BodyType<GatewaytypesPostableIngestionKeyDTO> },
		TContext
	>;
}): UseMutationOptions<
	Awaited<ReturnType<typeof createIngestionKey>>,
	TError,
	{ data: BodyType<GatewaytypesPostableIngestionKeyDTO> },
	TContext
> => {
	const mutationKey = ['createIngestionKey'];
	const { mutation: mutationOptions } = options
		? options.mutation &&
			'mutationKey' in options.mutation &&
			options.mutation.mutationKey
			? options
			: { ...options, mutation: { ...options.mutation, mutationKey } }
		: { mutation: { mutationKey } };

	const mutationFn: MutationFunction<
		Awaited<ReturnType<typeof createIngestionKey>>,
		{ data: BodyType<GatewaytypesPostableIngestionKeyDTO> }
	> = (props) => {
		const { data } = props ?? {};

		return createIngestionKey(data);
	};

	return { mutationFn, ...mutationOptions };
};

export type CreateIngestionKeyMutationResult = NonNullable<
	Awaited<ReturnType<typeof createIngestionKey>>
>;
export type CreateIngestionKeyMutationBody =
	BodyType<GatewaytypesPostableIngestionKeyDTO>;
export type CreateIngestionKeyMutationError = ErrorType<RenderErrorResponseDTO>;

/**
 * @summary Create ingestion key for workspace
 */
export const useCreateIngestionKey = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof createIngestionKey>>,
		TError,
		{ data: BodyType<GatewaytypesPostableIngestionKeyDTO> },
		TContext
	>;
}): UseMutationResult<
	Awaited<ReturnType<typeof createIngestionKey>>,
	TError,
	{ data: BodyType<GatewaytypesPostableIngestionKeyDTO> },
	TContext
> => {
	const mutationOptions = getCreateIngestionKeyMutationOptions(options);

	return useMutation(mutationOptions);
};
/**
 * This endpoint deletes an ingestion key for the workspace
 * @summary Delete ingestion key for workspace
 */
export const deleteIngestionKey = ({
	keyId,
}: DeleteIngestionKeyPathParameters) => {
	return GeneratedAPIInstance<void>({
		url: `/api/v2/gateway/ingestion_keys/${keyId}`,
		method: 'DELETE',
	});
};

export const getDeleteIngestionKeyMutationOptions = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof deleteIngestionKey>>,
		TError,
		{ pathParams: DeleteIngestionKeyPathParameters },
		TContext
	>;
}): UseMutationOptions<
	Awaited<ReturnType<typeof deleteIngestionKey>>,
	TError,
	{ pathParams: DeleteIngestionKeyPathParameters },
	TContext
> => {
	const mutationKey = ['deleteIngestionKey'];
	const { mutation: mutationOptions } = options
		? options.mutation &&
			'mutationKey' in options.mutation &&
			options.mutation.mutationKey
			? options
			: { ...options, mutation: { ...options.mutation, mutationKey } }
		: { mutation: { mutationKey } };

	const mutationFn: MutationFunction<
		Awaited<ReturnType<typeof deleteIngestionKey>>,
		{ pathParams: DeleteIngestionKeyPathParameters }
	> = (props) => {
		const { pathParams } = props ?? {};

		return deleteIngestionKey(pathParams);
	};

	return { mutationFn, ...mutationOptions };
};

export type DeleteIngestionKeyMutationResult = NonNullable<
	Awaited<ReturnType<typeof deleteIngestionKey>>
>;

export type DeleteIngestionKeyMutationError = ErrorType<RenderErrorResponseDTO>;

/**
 * @summary Delete ingestion key for workspace
 */
export const useDeleteIngestionKey = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof deleteIngestionKey>>,
		TError,
		{ pathParams: DeleteIngestionKeyPathParameters },
		TContext
	>;
}): UseMutationResult<
	Awaited<ReturnType<typeof deleteIngestionKey>>,
	TError,
	{ pathParams: DeleteIngestionKeyPathParameters },
	TContext
> => {
	const mutationOptions = getDeleteIngestionKeyMutationOptions(options);

	return useMutation(mutationOptions);
};
/**
 * This endpoint updates an ingestion key for the workspace
 * @summary Update ingestion key for workspace
 */
export const updateIngestionKey = (
	{ keyId }: UpdateIngestionKeyPathParameters,
	gatewaytypesPostableIngestionKeyDTO: BodyType<GatewaytypesPostableIngestionKeyDTO>,
) => {
	return GeneratedAPIInstance<void>({
		url: `/api/v2/gateway/ingestion_keys/${keyId}`,
		method: 'PATCH',
		headers: { 'Content-Type': 'application/json' },
		data: gatewaytypesPostableIngestionKeyDTO,
	});
};

export const getUpdateIngestionKeyMutationOptions = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof updateIngestionKey>>,
		TError,
		{
			pathParams: UpdateIngestionKeyPathParameters;
			data: BodyType<GatewaytypesPostableIngestionKeyDTO>;
		},
		TContext
	>;
}): UseMutationOptions<
	Awaited<ReturnType<typeof updateIngestionKey>>,
	TError,
	{
		pathParams: UpdateIngestionKeyPathParameters;
		data: BodyType<GatewaytypesPostableIngestionKeyDTO>;
	},
	TContext
> => {
	const mutationKey = ['updateIngestionKey'];
	const { mutation: mutationOptions } = options
		? options.mutation &&
			'mutationKey' in options.mutation &&
			options.mutation.mutationKey
			? options
			: { ...options, mutation: { ...options.mutation, mutationKey } }
		: { mutation: { mutationKey } };

	const mutationFn: MutationFunction<
		Awaited<ReturnType<typeof updateIngestionKey>>,
		{
			pathParams: UpdateIngestionKeyPathParameters;
			data: BodyType<GatewaytypesPostableIngestionKeyDTO>;
		}
	> = (props) => {
		const { pathParams, data } = props ?? {};

		return updateIngestionKey(pathParams, data);
	};

	return { mutationFn, ...mutationOptions };
};

export type UpdateIngestionKeyMutationResult = NonNullable<
	Awaited<ReturnType<typeof updateIngestionKey>>
>;
export type UpdateIngestionKeyMutationBody =
	BodyType<GatewaytypesPostableIngestionKeyDTO>;
export type UpdateIngestionKeyMutationError = ErrorType<RenderErrorResponseDTO>;

/**
 * @summary Update ingestion key for workspace
 */
export const useUpdateIngestionKey = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof updateIngestionKey>>,
		TError,
		{
			pathParams: UpdateIngestionKeyPathParameters;
			data: BodyType<GatewaytypesPostableIngestionKeyDTO>;
		},
		TContext
	>;
}): UseMutationResult<
	Awaited<ReturnType<typeof updateIngestionKey>>,
	TError,
	{
		pathParams: UpdateIngestionKeyPathParameters;
		data: BodyType<GatewaytypesPostableIngestionKeyDTO>;
	},
	TContext
> => {
	const mutationOptions = getUpdateIngestionKeyMutationOptions(options);

	return useMutation(mutationOptions);
};
/**
 * This endpoint creates an ingestion key limit
 * @summary Create limit for the ingestion key
 */
export const createIngestionKeyLimit = (
	{ keyId }: CreateIngestionKeyLimitPathParameters,
	gatewaytypesPostableIngestionKeyLimitDTO: BodyType<GatewaytypesPostableIngestionKeyLimitDTO>,
	signal?: AbortSignal,
) => {
	return GeneratedAPIInstance<CreateIngestionKeyLimit201>({
		url: `/api/v2/gateway/ingestion_keys/${keyId}/limits`,
		method: 'POST',
		headers: { 'Content-Type': 'application/json' },
		data: gatewaytypesPostableIngestionKeyLimitDTO,
		signal,
	});
};

export const getCreateIngestionKeyLimitMutationOptions = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof createIngestionKeyLimit>>,
		TError,
		{
			pathParams: CreateIngestionKeyLimitPathParameters;
			data: BodyType<GatewaytypesPostableIngestionKeyLimitDTO>;
		},
		TContext
	>;
}): UseMutationOptions<
	Awaited<ReturnType<typeof createIngestionKeyLimit>>,
	TError,
	{
		pathParams: CreateIngestionKeyLimitPathParameters;
		data: BodyType<GatewaytypesPostableIngestionKeyLimitDTO>;
	},
	TContext
> => {
	const mutationKey = ['createIngestionKeyLimit'];
	const { mutation: mutationOptions } = options
		? options.mutation &&
			'mutationKey' in options.mutation &&
			options.mutation.mutationKey
			? options
			: { ...options, mutation: { ...options.mutation, mutationKey } }
		: { mutation: { mutationKey } };

	const mutationFn: MutationFunction<
		Awaited<ReturnType<typeof createIngestionKeyLimit>>,
		{
			pathParams: CreateIngestionKeyLimitPathParameters;
			data: BodyType<GatewaytypesPostableIngestionKeyLimitDTO>;
		}
	> = (props) => {
		const { pathParams, data } = props ?? {};

		return createIngestionKeyLimit(pathParams, data);
	};

	return { mutationFn, ...mutationOptions };
};

export type CreateIngestionKeyLimitMutationResult = NonNullable<
	Awaited<ReturnType<typeof createIngestionKeyLimit>>
>;
export type CreateIngestionKeyLimitMutationBody =
	BodyType<GatewaytypesPostableIngestionKeyLimitDTO>;
export type CreateIngestionKeyLimitMutationError =
	ErrorType<RenderErrorResponseDTO>;

/**
 * @summary Create limit for the ingestion key
 */
export const useCreateIngestionKeyLimit = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof createIngestionKeyLimit>>,
		TError,
		{
			pathParams: CreateIngestionKeyLimitPathParameters;
			data: BodyType<GatewaytypesPostableIngestionKeyLimitDTO>;
		},
		TContext
	>;
}): UseMutationResult<
	Awaited<ReturnType<typeof createIngestionKeyLimit>>,
	TError,
	{
		pathParams: CreateIngestionKeyLimitPathParameters;
		data: BodyType<GatewaytypesPostableIngestionKeyLimitDTO>;
	},
	TContext
> => {
	const mutationOptions = getCreateIngestionKeyLimitMutationOptions(options);

	return useMutation(mutationOptions);
};
/**
 * This endpoint deletes an ingestion key limit
 * @summary Delete limit for the ingestion key
 */
export const deleteIngestionKeyLimit = ({
	limitId,
}: DeleteIngestionKeyLimitPathParameters) => {
	return GeneratedAPIInstance<void>({
		url: `/api/v2/gateway/ingestion_keys/limits/${limitId}`,
		method: 'DELETE',
	});
};

export const getDeleteIngestionKeyLimitMutationOptions = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof deleteIngestionKeyLimit>>,
		TError,
		{ pathParams: DeleteIngestionKeyLimitPathParameters },
		TContext
	>;
}): UseMutationOptions<
	Awaited<ReturnType<typeof deleteIngestionKeyLimit>>,
	TError,
	{ pathParams: DeleteIngestionKeyLimitPathParameters },
	TContext
> => {
	const mutationKey = ['deleteIngestionKeyLimit'];
	const { mutation: mutationOptions } = options
		? options.mutation &&
			'mutationKey' in options.mutation &&
			options.mutation.mutationKey
			? options
			: { ...options, mutation: { ...options.mutation, mutationKey } }
		: { mutation: { mutationKey } };

	const mutationFn: MutationFunction<
		Awaited<ReturnType<typeof deleteIngestionKeyLimit>>,
		{ pathParams: DeleteIngestionKeyLimitPathParameters }
	> = (props) => {
		const { pathParams } = props ?? {};

		return deleteIngestionKeyLimit(pathParams);
	};

	return { mutationFn, ...mutationOptions };
};

export type DeleteIngestionKeyLimitMutationResult = NonNullable<
	Awaited<ReturnType<typeof deleteIngestionKeyLimit>>
>;

export type DeleteIngestionKeyLimitMutationError =
	ErrorType<RenderErrorResponseDTO>;

/**
 * @summary Delete limit for the ingestion key
 */
export const useDeleteIngestionKeyLimit = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof deleteIngestionKeyLimit>>,
		TError,
		{ pathParams: DeleteIngestionKeyLimitPathParameters },
		TContext
	>;
}): UseMutationResult<
	Awaited<ReturnType<typeof deleteIngestionKeyLimit>>,
	TError,
	{ pathParams: DeleteIngestionKeyLimitPathParameters },
	TContext
> => {
	const mutationOptions = getDeleteIngestionKeyLimitMutationOptions(options);

	return useMutation(mutationOptions);
};
/**
 * This endpoint updates an ingestion key limit
 * @summary Update limit for the ingestion key
 */
export const updateIngestionKeyLimit = (
	{ limitId }: UpdateIngestionKeyLimitPathParameters,
	gatewaytypesUpdatableIngestionKeyLimitDTO: BodyType<GatewaytypesUpdatableIngestionKeyLimitDTO>,
) => {
	return GeneratedAPIInstance<void>({
		url: `/api/v2/gateway/ingestion_keys/limits/${limitId}`,
		method: 'PATCH',
		headers: { 'Content-Type': 'application/json' },
		data: gatewaytypesUpdatableIngestionKeyLimitDTO,
	});
};

export const getUpdateIngestionKeyLimitMutationOptions = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof updateIngestionKeyLimit>>,
		TError,
		{
			pathParams: UpdateIngestionKeyLimitPathParameters;
			data: BodyType<GatewaytypesUpdatableIngestionKeyLimitDTO>;
		},
		TContext
	>;
}): UseMutationOptions<
	Awaited<ReturnType<typeof updateIngestionKeyLimit>>,
	TError,
	{
		pathParams: UpdateIngestionKeyLimitPathParameters;
		data: BodyType<GatewaytypesUpdatableIngestionKeyLimitDTO>;
	},
	TContext
> => {
	const mutationKey = ['updateIngestionKeyLimit'];
	const { mutation: mutationOptions } = options
		? options.mutation &&
			'mutationKey' in options.mutation &&
			options.mutation.mutationKey
			? options
			: { ...options, mutation: { ...options.mutation, mutationKey } }
		: { mutation: { mutationKey } };

	const mutationFn: MutationFunction<
		Awaited<ReturnType<typeof updateIngestionKeyLimit>>,
		{
			pathParams: UpdateIngestionKeyLimitPathParameters;
			data: BodyType<GatewaytypesUpdatableIngestionKeyLimitDTO>;
		}
	> = (props) => {
		const { pathParams, data } = props ?? {};

		return updateIngestionKeyLimit(pathParams, data);
	};

	return { mutationFn, ...mutationOptions };
};

export type UpdateIngestionKeyLimitMutationResult = NonNullable<
	Awaited<ReturnType<typeof updateIngestionKeyLimit>>
>;
export type UpdateIngestionKeyLimitMutationBody =
	BodyType<GatewaytypesUpdatableIngestionKeyLimitDTO>;
export type UpdateIngestionKeyLimitMutationError =
	ErrorType<RenderErrorResponseDTO>;

/**
 * @summary Update limit for the ingestion key
 */
export const useUpdateIngestionKeyLimit = <
	TError = ErrorType<RenderErrorResponseDTO>,
	TContext = unknown,
>(options?: {
	mutation?: UseMutationOptions<
		Awaited<ReturnType<typeof updateIngestionKeyLimit>>,
		TError,
		{
			pathParams: UpdateIngestionKeyLimitPathParameters;
			data: BodyType<GatewaytypesUpdatableIngestionKeyLimitDTO>;
		},
		TContext
	>;
}): UseMutationResult<
	Awaited<ReturnType<typeof updateIngestionKeyLimit>>,
	TError,
	{
		pathParams: UpdateIngestionKeyLimitPathParameters;
		data: BodyType<GatewaytypesUpdatableIngestionKeyLimitDTO>;
	},
	TContext
> => {
	const mutationOptions = getUpdateIngestionKeyLimitMutationOptions(options);

	return useMutation(mutationOptions);
};
/**
 * This endpoint returns the ingestion keys for a workspace
 * @summary Search ingestion keys for workspace
 */
export const searchIngestionKeys = (
	params: SearchIngestionKeysParams,
	signal?: AbortSignal,
) => {
	return GeneratedAPIInstance<SearchIngestionKeys200>({
		url: `/api/v2/gateway/ingestion_keys/search`,
		method: 'GET',
		params,
		signal,
	});
};

export const getSearchIngestionKeysQueryKey = (
	params?: SearchIngestionKeysParams,
) => {
	return [
		`/api/v2/gateway/ingestion_keys/search`,
		...(params ? [params] : []),
	] as const;
};

export const getSearchIngestionKeysQueryOptions = <
	TData = Awaited<ReturnType<typeof searchIngestionKeys>>,
	TError = ErrorType<RenderErrorResponseDTO>,
>(
	params: SearchIngestionKeysParams,
	options?: {
		query?: UseQueryOptions<
			Awaited<ReturnType<typeof searchIngestionKeys>>,
			TError,
			TData
		>;
	},
) => {
	const { query: queryOptions } = options ?? {};

	const queryKey =
		queryOptions?.queryKey ?? getSearchIngestionKeysQueryKey(params);

	const queryFn: QueryFunction<
		Awaited<ReturnType<typeof searchIngestionKeys>>
	> = ({ signal }) => searchIngestionKeys(params, signal);

	return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
		Awaited<ReturnType<typeof searchIngestionKeys>>,
		TError,
		TData
	> & { queryKey: QueryKey };
};

export type SearchIngestionKeysQueryResult = NonNullable<
	Awaited<ReturnType<typeof searchIngestionKeys>>
>;
export type SearchIngestionKeysQueryError = ErrorType<RenderErrorResponseDTO>;

/**
 * @summary Search ingestion keys for workspace
 */

export function useSearchIngestionKeys<
	TData = Awaited<ReturnType<typeof searchIngestionKeys>>,
	TError = ErrorType<RenderErrorResponseDTO>,
>(
	params: SearchIngestionKeysParams,
	options?: {
		query?: UseQueryOptions<
			Awaited<ReturnType<typeof searchIngestionKeys>>,
			TError,
			TData
		>;
	},
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
	const queryOptions = getSearchIngestionKeysQueryOptions(params, options);

	const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
		queryKey: QueryKey;
	};

	query.queryKey = queryOptions.queryKey;

	return query;
}

/**
 * @summary Search ingestion keys for workspace
 */
export const invalidateSearchIngestionKeys = async (
	queryClient: QueryClient,
	params: SearchIngestionKeysParams,
	options?: InvalidateOptions,
): Promise<QueryClient> => {
	await queryClient.invalidateQueries(
		{ queryKey: getSearchIngestionKeysQueryKey(params) },
		options,
	);

	return queryClient;
};
