/**
 * 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 {
  AccessModel,
  CreateRequest5,
  GetAccessListParams,
  ProblemDetails,
  TableDataResponseModelOfAccessModel
} from './client.schemas';

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





export const getAccessList = (
    params?: GetAccessListParams,
 signal?: AbortSignal
) => {
      
      
      return customClient<TableDataResponseModelOfAccessModel>(
      {url: `/api/accesses`, method: 'GET',
        params, signal
    },
      );
    }
  

export const getGetAccessListQueryKey = (params?: GetAccessListParams,) => {
    return [`/api/accesses`, ...(params ? [params]: [])] as const;
    }

    
export const getGetAccessListQueryOptions = <TData = Awaited<ReturnType<typeof getAccessList>>, TError = unknown>(params?: GetAccessListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAccessList>>, TError, TData>>, }
) => {

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

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

  

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

      

      

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

export type GetAccessListQueryResult = NonNullable<Awaited<ReturnType<typeof getAccessList>>>
export type GetAccessListQueryError = unknown


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

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

  const queryOptions = getGetAccessListQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const createAccess = (
    createRequest5: CreateRequest5,
 signal?: AbortSignal
) => {
      
      
      return customClient<AccessModel>(
      {url: `/api/accesses`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: createRequest5, signal
    },
      );
    }
  


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

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

          return  createAccess(data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreateAccessMutationResult = NonNullable<Awaited<ReturnType<typeof createAccess>>>
    export type CreateAccessMutationBody = CreateRequest5
    export type CreateAccessMutationError = string | ProblemDetails

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

      const mutationOptions = getCreateAccessMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const getAccess = (
    id: string,
 signal?: AbortSignal
) => {
      
      
      return customClient<AccessModel>(
      {url: `/api/accesses/${id}`, method: 'GET', signal
    },
      );
    }
  

export const getGetAccessQueryKey = (id: string,) => {
    return [`/api/accesses/${id}`] as const;
    }

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

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

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

  

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

      

      

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

export type GetAccessQueryResult = NonNullable<Awaited<ReturnType<typeof getAccess>>>
export type GetAccessQueryError = string


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

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

  const queryOptions = getGetAccessQueryOptions(id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const deleteAccess = (
    id: string,
 ) => {
      
      
      return customClient<void>(
      {url: `/api/accesses/${id}`, method: 'DELETE'
    },
      );
    }
  


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

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

          return  deleteAccess(id,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteAccessMutationResult = NonNullable<Awaited<ReturnType<typeof deleteAccess>>>
    
    export type DeleteAccessMutationError = string

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

      const mutationOptions = getDeleteAccessMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    