diff --git a/frontend/src/api/infraMonitoring/getK8sNodesList.ts b/frontend/src/api/infraMonitoring/getK8sNodesList.ts deleted file mode 100644 index 18fc3ce42a..0000000000 --- a/frontend/src/api/infraMonitoring/getK8sNodesList.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { ApiBaseInstance } from 'api'; -import { ErrorResponseHandler } from 'api/ErrorResponseHandler'; -import { AxiosError } from 'axios'; -import { ErrorResponse, SuccessResponse } from 'types/api'; -import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; -import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; - -export interface K8sNodesListPayload { - filters: TagFilter; - groupBy?: BaseAutocompleteData[]; - offset?: number; - limit?: number; - orderBy?: { - columnName: string; - order: 'asc' | 'desc'; - }; -} - -export interface K8sNodesData { - nodeUID: string; - nodeCPUUsage: number; - nodeCPUAllocatable: number; - nodeMemoryUsage: number; - nodeMemoryAllocatable: number; - meta: { - k8s_node_name: string; - k8s_node_uid: string; - }; -} - -export interface K8sNodesListResponse { - status: string; - data: { - type: string; - records: K8sNodesData[]; - groups: null; - total: number; - sentAnyHostMetricsData: boolean; - isSendingK8SAgentMetrics: boolean; - }; -} - -export const getK8sNodesList = async ( - props: K8sNodesListPayload, - signal?: AbortSignal, - headers?: Record, -): Promise | ErrorResponse> => { - try { - const response = await ApiBaseInstance.post('/nodes/list', props, { - signal, - headers, - }); - - return { - statusCode: 200, - error: null, - message: 'Success', - payload: response.data, - params: props, - }; - } catch (error) { - return ErrorResponseHandler(error as AxiosError); - } -}; diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sNodesList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sNodesList.ts deleted file mode 100644 index 4e2ac964d2..0000000000 --- a/frontend/src/hooks/infraMonitoring/useGetK8sNodesList.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { - getK8sNodesList, - K8sNodesListPayload, - K8sNodesListResponse, -} from 'api/infraMonitoring/getK8sNodesList'; -import { REACT_QUERY_KEY } from 'constants/reactQueryKeys'; -import { useMemo } from 'react'; -import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query'; -import { ErrorResponse, SuccessResponse } from 'types/api'; - -type UseGetK8sNodesList = ( - requestData: K8sNodesListPayload, - options?: UseQueryOptions< - SuccessResponse | ErrorResponse, - Error - >, - headers?: Record, -) => UseQueryResult< - SuccessResponse | ErrorResponse, - Error ->; - -export const useGetK8sNodesList: UseGetK8sNodesList = ( - requestData, - options, - headers, -) => { - const queryKey = useMemo(() => { - if (options?.queryKey && Array.isArray(options.queryKey)) { - return [...options.queryKey]; - } - - if (options?.queryKey && typeof options.queryKey === 'string') { - return options.queryKey; - } - - return [REACT_QUERY_KEY.GET_HOST_LIST, requestData]; - }, [options?.queryKey, requestData]); - - return useQuery | ErrorResponse, Error>({ - queryFn: ({ signal }) => getK8sNodesList(requestData, signal, headers), - ...options, - queryKey, - }); -};