/**
 * 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 {
  CameraModel,
  CreateCameraRequest,
  GetCameraListParams,
  TableDataResponseModelOfCameraModel,
  UpdateCameraRequest
} from './client.schemas';

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





export const getCameraList = (
    params?: GetCameraListParams,
 signal?: AbortSignal
) => {
      
      
      return customClient<TableDataResponseModelOfCameraModel>(
      {url: `/api/cameras`, method: 'GET',
        params, signal
    },
      );
    }
  

export const getGetCameraListQueryKey = (params?: GetCameraListParams,) => {
    return [`/api/cameras`, ...(params ? [params]: [])] as const;
    }

    
export const getGetCameraListQueryOptions = <TData = Awaited<ReturnType<typeof getCameraList>>, TError = unknown>(params?: GetCameraListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCameraList>>, TError, TData>>, }
) => {

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

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

  

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

      

      

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

export type GetCameraListQueryResult = NonNullable<Awaited<ReturnType<typeof getCameraList>>>
export type GetCameraListQueryError = unknown


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

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

  const queryOptions = getGetCameraListQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const createCamera = (
    createCameraRequest: CreateCameraRequest,
 signal?: AbortSignal
) => {
      
      
      return customClient<CameraModel>(
      {url: `/api/cameras`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: createCameraRequest, signal
    },
      );
    }
  


export const getCreateCameraMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createCamera>>, TError,{data: CreateCameraRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof createCamera>>, TError,{data: CreateCameraRequest}, TContext> => {

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

          return  createCamera(data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreateCameraMutationResult = NonNullable<Awaited<ReturnType<typeof createCamera>>>
    export type CreateCameraMutationBody = CreateCameraRequest
    export type CreateCameraMutationError = string

    export const useCreateCamera = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createCamera>>, TError,{data: CreateCameraRequest}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof createCamera>>,
        TError,
        {data: CreateCameraRequest},
        TContext
      > => {

      const mutationOptions = getCreateCameraMutationOptions(options);

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

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

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

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

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

  

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

      

      

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

export type GetCameraQueryResult = NonNullable<Awaited<ReturnType<typeof getCamera>>>
export type GetCameraQueryError = string


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

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

  const queryOptions = getGetCameraQueryOptions(id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const updateCamera = (
    id: string,
    updateCameraRequest: UpdateCameraRequest,
 ) => {
      
      
      return customClient<void>(
      {url: `/api/cameras/${id}`, method: 'PUT',
      headers: {'Content-Type': 'application/json', },
      data: updateCameraRequest
    },
      );
    }
  


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

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

          return  updateCamera(id,data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type UpdateCameraMutationResult = NonNullable<Awaited<ReturnType<typeof updateCamera>>>
    export type UpdateCameraMutationBody = UpdateCameraRequest
    export type UpdateCameraMutationError = string

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

      const mutationOptions = getUpdateCameraMutationOptions(options);

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


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

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

          return  deleteCamera(id,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteCameraMutationResult = NonNullable<Awaited<ReturnType<typeof deleteCamera>>>
    
    export type DeleteCameraMutationError = string

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

      const mutationOptions = getDeleteCameraMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    