/**
 * 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 {
  CreateLockedEventCodeRequest,
  GetLockedEventCodeListParams,
  LockedEventCodeModel,
  TableDataResponseModelOfLockedEventCodeModel
} from './client.schemas';

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





export const getLockedEventCodeList = (
    organizationId: string,
    assetId: string,
    params?: GetLockedEventCodeListParams,
 signal?: AbortSignal
) => {
      
      
      return customClient<TableDataResponseModelOfLockedEventCodeModel>(
      {url: `/api/organizations/${organizationId}/assets/${assetId}/locked-event-codes`, method: 'GET',
        params, signal
    },
      );
    }
  

export const getGetLockedEventCodeListQueryKey = (organizationId: string,
    assetId: string,
    params?: GetLockedEventCodeListParams,) => {
    return [`/api/organizations/${organizationId}/assets/${assetId}/locked-event-codes`, ...(params ? [params]: [])] as const;
    }

    
export const getGetLockedEventCodeListQueryOptions = <TData = Awaited<ReturnType<typeof getLockedEventCodeList>>, TError = unknown>(organizationId: string,
    assetId: string,
    params?: GetLockedEventCodeListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getLockedEventCodeList>>, TError, TData>>, }
) => {

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

  const queryKey =  queryOptions?.queryKey ?? getGetLockedEventCodeListQueryKey(organizationId,assetId,params);

  

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

      

      

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

export type GetLockedEventCodeListQueryResult = NonNullable<Awaited<ReturnType<typeof getLockedEventCodeList>>>
export type GetLockedEventCodeListQueryError = unknown


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

export function useGetLockedEventCodeList<TData = Awaited<ReturnType<typeof getLockedEventCodeList>>, TError = unknown>(
 organizationId: string,
    assetId: string,
    params?: GetLockedEventCodeListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getLockedEventCodeList>>, TError, TData>>, }
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

  const queryOptions = getGetLockedEventCodeListQueryOptions(organizationId,assetId,params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const createLockedEventCode = (
    organizationId: string,
    assetId: string,
    createLockedEventCodeRequest: CreateLockedEventCodeRequest,
 signal?: AbortSignal
) => {
      
      
      return customClient<LockedEventCodeModel>(
      {url: `/api/organizations/${organizationId}/assets/${assetId}/locked-event-codes`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: createLockedEventCodeRequest, signal
    },
      );
    }
  


export const getCreateLockedEventCodeMutationOptions = <TError = unknown,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createLockedEventCode>>, TError,{organizationId: string;assetId: string;data: CreateLockedEventCodeRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof createLockedEventCode>>, TError,{organizationId: string;assetId: string;data: CreateLockedEventCodeRequest}, TContext> => {

const mutationKey = ['createLockedEventCode'];
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 createLockedEventCode>>, {organizationId: string;assetId: string;data: CreateLockedEventCodeRequest}> = (props) => {
          const {organizationId,assetId,data} = props ?? {};

          return  createLockedEventCode(organizationId,assetId,data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreateLockedEventCodeMutationResult = NonNullable<Awaited<ReturnType<typeof createLockedEventCode>>>
    export type CreateLockedEventCodeMutationBody = CreateLockedEventCodeRequest
    export type CreateLockedEventCodeMutationError = unknown

    export const useCreateLockedEventCode = <TError = unknown,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createLockedEventCode>>, TError,{organizationId: string;assetId: string;data: CreateLockedEventCodeRequest}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof createLockedEventCode>>,
        TError,
        {organizationId: string;assetId: string;data: CreateLockedEventCodeRequest},
        TContext
      > => {

      const mutationOptions = getCreateLockedEventCodeMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const deleteLockedEventCode = (
    organizationId: string,
    assetId: string,
    id: string,
 ) => {
      
      
      return customClient<void>(
      {url: `/api/organizations/${organizationId}/assets/${assetId}/locked-event-codes/${id}`, method: 'DELETE'
    },
      );
    }
  


export const getDeleteLockedEventCodeMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteLockedEventCode>>, TError,{organizationId: string;assetId: string;id: string}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof deleteLockedEventCode>>, TError,{organizationId: string;assetId: string;id: string}, TContext> => {

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

          return  deleteLockedEventCode(organizationId,assetId,id,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteLockedEventCodeMutationResult = NonNullable<Awaited<ReturnType<typeof deleteLockedEventCode>>>
    
    export type DeleteLockedEventCodeMutationError = string

    export const useDeleteLockedEventCode = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteLockedEventCode>>, TError,{organizationId: string;assetId: string;id: string}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof deleteLockedEventCode>>,
        TError,
        {organizationId: string;assetId: string;id: string},
        TContext
      > => {

      const mutationOptions = getDeleteLockedEventCodeMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const getLockedEventCode = (
    organizationId: string,
    assetId: string,
    id: string,
 signal?: AbortSignal
) => {
      
      
      return customClient<LockedEventCodeModel>(
      {url: `/api/organizations/${organizationId}/assets/${assetId}/locked-event-codes/${id}`, method: 'GET', signal
    },
      );
    }
  

export const getGetLockedEventCodeQueryKey = (organizationId: string,
    assetId: string,
    id: string,) => {
    return [`/api/organizations/${organizationId}/assets/${assetId}/locked-event-codes/${id}`] as const;
    }

    
export const getGetLockedEventCodeQueryOptions = <TData = Awaited<ReturnType<typeof getLockedEventCode>>, TError = string>(organizationId: string,
    assetId: string,
    id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getLockedEventCode>>, TError, TData>>, }
) => {

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

  const queryKey =  queryOptions?.queryKey ?? getGetLockedEventCodeQueryKey(organizationId,assetId,id);

  

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

      

      

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

export type GetLockedEventCodeQueryResult = NonNullable<Awaited<ReturnType<typeof getLockedEventCode>>>
export type GetLockedEventCodeQueryError = string


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

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

  const queryOptions = getGetLockedEventCodeQueryOptions(organizationId,assetId,id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



