/**
 * Generated by orval v7.10.0 🍺
 * Do not edit manually.
 * Monitoring | v1
 * OpenAPI spec version: 1.0.0
 */
import {
  useMutation,
  useQuery
} from '@tanstack/react-query';
import type {
  DataTag,
  DefinedInitialDataOptions,
  DefinedUseQueryResult,
  MutationFunction,
  QueryClient,
  QueryFunction,
  QueryKey,
  UndefinedInitialDataOptions,
  UseMutationOptions,
  UseMutationResult,
  UseQueryOptions,
  UseQueryResult
} from '@tanstack/react-query';

import type {
  AssetGroupModel,
  CreateRequest,
  GetAssetGroupListParams,
  ProblemDetails,
  TableDataResponseModelOfAssetGroupModel,
  UpdateRequest
} from './client.schemas';

import { customClient } from '../services/http.service';





export const getAssetGroupList = (
    params?: GetAssetGroupListParams,
 signal?: AbortSignal
) => {
      
      
      return customClient<TableDataResponseModelOfAssetGroupModel>(
      {url: `/api/asset-groups`, method: 'GET',
        params, signal
    },
      );
    }
  

export const getGetAssetGroupListQueryKey = (params?: GetAssetGroupListParams,) => {
    return [`/api/asset-groups`, ...(params ? [params]: [])] as const;
    }

    
export const getGetAssetGroupListQueryOptions = <TData = Awaited<ReturnType<typeof getAssetGroupList>>, TError = unknown>(params?: GetAssetGroupListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroupList>>, TError, TData>>, }
) => {

const {query: queryOptions} = options ?? {};

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

  

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

      

      

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

export type GetAssetGroupListQueryResult = NonNullable<Awaited<ReturnType<typeof getAssetGroupList>>>
export type GetAssetGroupListQueryError = unknown


export function useGetAssetGroupList<TData = Awaited<ReturnType<typeof getAssetGroupList>>, TError = unknown>(
 params: undefined |  GetAssetGroupListParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroupList>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getAssetGroupList>>,
          TError,
          Awaited<ReturnType<typeof getAssetGroupList>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetAssetGroupList<TData = Awaited<ReturnType<typeof getAssetGroupList>>, TError = unknown>(
 params?: GetAssetGroupListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroupList>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getAssetGroupList>>,
          TError,
          Awaited<ReturnType<typeof getAssetGroupList>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetAssetGroupList<TData = Awaited<ReturnType<typeof getAssetGroupList>>, TError = unknown>(
 params?: GetAssetGroupListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroupList>>, TError, TData>>, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }

export function useGetAssetGroupList<TData = Awaited<ReturnType<typeof getAssetGroupList>>, TError = unknown>(
 params?: GetAssetGroupListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroupList>>, TError, TData>>, }
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

  const queryOptions = getGetAssetGroupListQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const createAssetGroup = (
    createRequest: CreateRequest,
 signal?: AbortSignal
) => {
      
      
      return customClient<AssetGroupModel>(
      {url: `/api/asset-groups`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: createRequest, signal
    },
      );
    }
  


export const getCreateAssetGroupMutationOptions = <TError = string | ProblemDetails,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createAssetGroup>>, TError,{data: CreateRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof createAssetGroup>>, TError,{data: CreateRequest}, TContext> => {

const mutationKey = ['createAssetGroup'];
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 createAssetGroup>>, {data: CreateRequest}> = (props) => {
          const {data} = props ?? {};

          return  createAssetGroup(data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreateAssetGroupMutationResult = NonNullable<Awaited<ReturnType<typeof createAssetGroup>>>
    export type CreateAssetGroupMutationBody = CreateRequest
    export type CreateAssetGroupMutationError = string | ProblemDetails

    export const useCreateAssetGroup = <TError = string | ProblemDetails,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createAssetGroup>>, TError,{data: CreateRequest}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof createAssetGroup>>,
        TError,
        {data: CreateRequest},
        TContext
      > => {

      const mutationOptions = getCreateAssetGroupMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const getAssetGroup = (
    id: string,
 signal?: AbortSignal
) => {
      
      
      return customClient<AssetGroupModel>(
      {url: `/api/asset-groups/${id}`, method: 'GET', signal
    },
      );
    }
  

export const getGetAssetGroupQueryKey = (id: string,) => {
    return [`/api/asset-groups/${id}`] as const;
    }

    
export const getGetAssetGroupQueryOptions = <TData = Awaited<ReturnType<typeof getAssetGroup>>, TError = string>(id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroup>>, TError, TData>>, }
) => {

const {query: queryOptions} = options ?? {};

  const queryKey =  queryOptions?.queryKey ?? getGetAssetGroupQueryKey(id);

  

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

      

      

   return  { queryKey, queryFn, enabled: !!(id), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getAssetGroup>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}

export type GetAssetGroupQueryResult = NonNullable<Awaited<ReturnType<typeof getAssetGroup>>>
export type GetAssetGroupQueryError = string


export function useGetAssetGroup<TData = Awaited<ReturnType<typeof getAssetGroup>>, TError = string>(
 id: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroup>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getAssetGroup>>,
          TError,
          Awaited<ReturnType<typeof getAssetGroup>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetAssetGroup<TData = Awaited<ReturnType<typeof getAssetGroup>>, TError = string>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroup>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getAssetGroup>>,
          TError,
          Awaited<ReturnType<typeof getAssetGroup>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetAssetGroup<TData = Awaited<ReturnType<typeof getAssetGroup>>, TError = string>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroup>>, TError, TData>>, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }

export function useGetAssetGroup<TData = Awaited<ReturnType<typeof getAssetGroup>>, TError = string>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAssetGroup>>, TError, TData>>, }
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

  const queryOptions = getGetAssetGroupQueryOptions(id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const updateAssetGroup = (
    id: string,
    updateRequest: UpdateRequest,
 ) => {
      
      
      return customClient<void>(
      {url: `/api/asset-groups/${id}`, method: 'PUT',
      headers: {'Content-Type': 'application/json', },
      data: updateRequest
    },
      );
    }
  


export const getUpdateAssetGroupMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateAssetGroup>>, TError,{id: string;data: UpdateRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof updateAssetGroup>>, TError,{id: string;data: UpdateRequest}, TContext> => {

const mutationKey = ['updateAssetGroup'];
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 updateAssetGroup>>, {id: string;data: UpdateRequest}> = (props) => {
          const {id,data} = props ?? {};

          return  updateAssetGroup(id,data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type UpdateAssetGroupMutationResult = NonNullable<Awaited<ReturnType<typeof updateAssetGroup>>>
    export type UpdateAssetGroupMutationBody = UpdateRequest
    export type UpdateAssetGroupMutationError = string

    export const useUpdateAssetGroup = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateAssetGroup>>, TError,{id: string;data: UpdateRequest}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof updateAssetGroup>>,
        TError,
        {id: string;data: UpdateRequest},
        TContext
      > => {

      const mutationOptions = getUpdateAssetGroupMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const deleteAssetGroup = (
    id: string,
 ) => {
      
      
      return customClient<void>(
      {url: `/api/asset-groups/${id}`, method: 'DELETE'
    },
      );
    }
  


export const getDeleteAssetGroupMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteAssetGroup>>, TError,{id: string}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof deleteAssetGroup>>, TError,{id: string}, TContext> => {

const mutationKey = ['deleteAssetGroup'];
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 deleteAssetGroup>>, {id: string}> = (props) => {
          const {id} = props ?? {};

          return  deleteAssetGroup(id,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteAssetGroupMutationResult = NonNullable<Awaited<ReturnType<typeof deleteAssetGroup>>>
    
    export type DeleteAssetGroupMutationError = string

    export const useDeleteAssetGroup = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteAssetGroup>>, TError,{id: string}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof deleteAssetGroup>>,
        TError,
        {id: string},
        TContext
      > => {

      const mutationOptions = getDeleteAssetGroupMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    