/**
 * 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 {
  CreatePhotoRequest,
  GetPhotoListParams,
  PhotoModel,
  TableDataResponseModelOfPhotoModel,
  UpdatePhotoRequest
} from './client.schemas';

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





export const getPhotoList = (
    params?: GetPhotoListParams,
 signal?: AbortSignal
) => {
      
      
      return customClient<TableDataResponseModelOfPhotoModel>(
      {url: `/api/photos`, method: 'GET',
        params, signal
    },
      );
    }
  

export const getGetPhotoListQueryKey = (params?: GetPhotoListParams,) => {
    return [`/api/photos`, ...(params ? [params]: [])] as const;
    }

    
export const getGetPhotoListQueryOptions = <TData = Awaited<ReturnType<typeof getPhotoList>>, TError = unknown>(params?: GetPhotoListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getPhotoList>>, TError, TData>>, }
) => {

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

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

  

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

      

      

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

export type GetPhotoListQueryResult = NonNullable<Awaited<ReturnType<typeof getPhotoList>>>
export type GetPhotoListQueryError = unknown


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

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

  const queryOptions = getGetPhotoListQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const createPhoto = (
    createPhotoRequest: CreatePhotoRequest,
 signal?: AbortSignal
) => {
      
      
      return customClient<PhotoModel>(
      {url: `/api/photos`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: createPhotoRequest, signal
    },
      );
    }
  


export const getCreatePhotoMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createPhoto>>, TError,{data: CreatePhotoRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof createPhoto>>, TError,{data: CreatePhotoRequest}, TContext> => {

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

          return  createPhoto(data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreatePhotoMutationResult = NonNullable<Awaited<ReturnType<typeof createPhoto>>>
    export type CreatePhotoMutationBody = CreatePhotoRequest
    export type CreatePhotoMutationError = string

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

      const mutationOptions = getCreatePhotoMutationOptions(options);

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

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

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

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

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

  

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

      

      

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

export type GetPhotoQueryResult = NonNullable<Awaited<ReturnType<typeof getPhoto>>>
export type GetPhotoQueryError = string


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

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

  const queryOptions = getGetPhotoQueryOptions(id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



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


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

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

          return  updatePhoto(id,data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type UpdatePhotoMutationResult = NonNullable<Awaited<ReturnType<typeof updatePhoto>>>
    export type UpdatePhotoMutationBody = UpdatePhotoRequest
    export type UpdatePhotoMutationError = string

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

      const mutationOptions = getUpdatePhotoMutationOptions(options);

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


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

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

          return  deletePhoto(id,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeletePhotoMutationResult = NonNullable<Awaited<ReturnType<typeof deletePhoto>>>
    
    export type DeletePhotoMutationError = string

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

      const mutationOptions = getDeletePhotoMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    