-- SPDX-FileCopyrightText: 2023-2024 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor.kleen@ifi.lmu.de>, David Mosbach <david.mosbach@uniworx.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later

module Foundation.Types
  ( UpsertUserMode(..)
  , _UpsertUserLogin, _UpsertUserLoginDummy, _UpsertUserLoginOther, _UpsertUserSync, _UpsertUserGuessUser
  , _upsertUserSource, _upsertUserIdent
  , UpsertUserData(..)
  , _UpsertUserDataAzure, _UpsertUserDataLdap
  , _upsertUserAzureTenantId, _upsertUserAzureData, _upsertUserLdapHost, _upsertUserLdapData
  ) where

import Import.NoFoundation

import qualified Ldap.Client as Ldap


-- TODO: rename?
data UpsertUserMode
  = UpsertUserLogin      { upsertUserSource :: Text } -- TODO: use type synonym?
  | UpsertUserLoginDummy { upsertUserIdent  :: UserIdent }
  | UpsertUserLoginOther { upsertUserIdent  :: UserIdent } -- does not allow further login
  | UpsertUserSync       { upsertUserIdent  :: UserIdent }
  | UpsertUserGuessUser
  deriving (Show)

makeLenses_ ''UpsertUserMode
makePrisms ''UpsertUserMode


data UpsertUserData
  = UpsertUserDataAzure
    { upsertUserAzureTenantId :: UUID
    , upsertUserAzureData     :: [(Text, [ByteString])]  -- TODO: use type synonym?
    }
  | UpsertUserDataLdap
    { upsertUserLdapHost      :: Text
    , upsertUserLdapData      :: Ldap.AttrList []
    }
  deriving (Show)

makeLenses_ ''UpsertUserData
makePrisms ''UpsertUserData
