/*
   This file is part of TALER
   Copyright (C) 2026 Taler Systems SA

   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU General Public License as published by the Free Software
   Foundation; either version 3, or (at your option) any later version.

   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along with
   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
/**
 * @file src/include/auditor-database/iterate_aml_staff.h
 * @brief implementation of the iterate_aml_staff function for Postgres
 * @author Christian Grothoff
 */
#ifndef AUDITOR_DATABASE_ITERATE_AML_STAFF_H
#define AUDITOR_DATABASE_ITERATE_AML_STAFF_H

#include "taler/taler_util.h"
#include "auditordb_lib.h"


#ifndef TALER_AUDITORDB_AML_STAFF_RESULT_CLOSURE
/**
 * Type of the closure for #TALER_AUDITORDB_AmlStaffCallback.
 */
#define TALER_AUDITORDB_AML_STAFF_RESULT_CLOSURE void
#endif

/* Callback typedefs */
/**
 * Function called with an AML staff status change the auditor recorded
 * earlier.
 *
 * @param cls closure
 * @param decider_pub public key of the staff member
 * @param decider_name legal name of the staff member
 * @param is_active true if the staff member could act from @a last_change on
 * @param read_only true if the staff member had read-only access
 * @param master_sig_valid true if the exchange's offline master key really
 *        did sign this status
 * @param last_change when the status took effect
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_AmlStaffCallback)(
  TALER_AUDITORDB_AML_STAFF_RESULT_CLOSURE *cls,
  const struct TALER_AmlOfficerPublicKeyP *decider_pub,
  const char *decider_name,
  bool is_active,
  bool read_only,
  bool master_sig_valid,
  struct GNUNET_TIME_Timestamp last_change);


/**
 * Get all AML staff status changes the auditor has recorded, oldest first,
 * so that the caller can reconstruct who was allowed to decide when.
 *
 * @param pg the database context
 * @param cb function to call with results
 * @param cb_cls closure for @a cb
 * @return query result status
 */
enum GNUNET_DB_QueryStatus
TALER_AUDITORDB_iterate_aml_staff (
  struct TALER_AUDITORDB_PostgresContext *pg,
  TALER_AUDITORDB_AmlStaffCallback cb,
  TALER_AUDITORDB_AML_STAFF_RESULT_CLOSURE *cb_cls);

#endif
