{-# LANGUAGE TemplateHaskell #-}

-- | Audit Log models
module Calamity.Types.Model.Guild.AuditLog (
  AuditLog (..),
  AuditLogEntry (..),
  AuditLogEntryInfo (..),
  AuditLogChange (..),
  AuditLogAction (..),
) where

import Calamity.Internal.SnowflakeMap (SnowflakeMap)
import Calamity.Types.Model.Channel
import Calamity.Types.Model.User
import Calamity.Types.Snowflake
import Data.Aeson ((.:), (.:?))
import qualified Data.Aeson as Aeson
import Data.Scientific
import Data.Text (Text)
import Optics.TH
import qualified TextShow
import TextShow.TH

data AuditLog = AuditLog
  { AuditLog -> SnowflakeMap Webhook
webhooks :: SnowflakeMap Webhook
  , AuditLog -> SnowflakeMap User
users :: SnowflakeMap User
  , AuditLog -> SnowflakeMap AuditLogEntry
auditLogEntries :: SnowflakeMap AuditLogEntry
  }
  deriving (Int -> AuditLog -> ShowS
[AuditLog] -> ShowS
AuditLog -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuditLog] -> ShowS
$cshowList :: [AuditLog] -> ShowS
show :: AuditLog -> String
$cshow :: AuditLog -> String
showsPrec :: Int -> AuditLog -> ShowS
$cshowsPrec :: Int -> AuditLog -> ShowS
Show)

data AuditLogEntry = AuditLogEntry
  { AuditLogEntry -> Maybe (Snowflake ())
targetID :: Maybe (Snowflake ())
  , AuditLogEntry -> [AuditLogChange]
changes :: [AuditLogChange]
  , AuditLogEntry -> Snowflake User
userID :: Snowflake User
  , AuditLogEntry -> Snowflake AuditLogEntry
id :: Snowflake AuditLogEntry
  , AuditLogEntry -> AuditLogAction
actionType :: AuditLogAction
  , AuditLogEntry -> Maybe AuditLogEntryInfo
options :: Maybe AuditLogEntryInfo
  , AuditLogEntry -> Maybe Text
reason :: Maybe Text
  }
  deriving (Int -> AuditLogEntry -> ShowS
[AuditLogEntry] -> ShowS
AuditLogEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuditLogEntry] -> ShowS
$cshowList :: [AuditLogEntry] -> ShowS
show :: AuditLogEntry -> String
$cshow :: AuditLogEntry -> String
showsPrec :: Int -> AuditLogEntry -> ShowS
$cshowsPrec :: Int -> AuditLogEntry -> ShowS
Show)
  deriving (HasID User) via HasIDField "userID" AuditLogEntry
  deriving (HasID AuditLogEntry) via HasIDField "id" AuditLogEntry

instance Aeson.FromJSON AuditLogEntry where
  parseJSON :: Value -> Parser AuditLogEntry
parseJSON = forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"AuditLogEntry" forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Maybe (Snowflake ())
-> [AuditLogChange]
-> Snowflake User
-> Snowflake AuditLogEntry
-> AuditLogAction
-> Maybe AuditLogEntryInfo
-> Maybe Text
-> AuditLogEntry
AuditLogEntry
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"target_id"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"changes"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"user_id"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"action_type"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"options"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"reason"

data AuditLogEntryInfo = AuditLogEntryInfo
  { AuditLogEntryInfo -> Maybe Text
deleteMemberDays :: Maybe Text
  , AuditLogEntryInfo -> Maybe Text
membersRemoved :: Maybe Text
  , AuditLogEntryInfo -> Maybe (Snowflake Channel)
channelID :: Maybe (Snowflake Channel)
  , AuditLogEntryInfo -> Maybe (Snowflake Message)
messageID :: Maybe (Snowflake Message)
  , AuditLogEntryInfo -> Maybe Text
count :: Maybe Text
  , AuditLogEntryInfo -> Maybe (Snowflake ())
id :: Maybe (Snowflake ())
  , AuditLogEntryInfo -> Maybe Text
type_ :: Maybe Text
  , AuditLogEntryInfo -> Maybe Text
roleName :: Maybe Text
  }
  deriving (Int -> AuditLogEntryInfo -> ShowS
[AuditLogEntryInfo] -> ShowS
AuditLogEntryInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuditLogEntryInfo] -> ShowS
$cshowList :: [AuditLogEntryInfo] -> ShowS
show :: AuditLogEntryInfo -> String
$cshow :: AuditLogEntryInfo -> String
showsPrec :: Int -> AuditLogEntryInfo -> ShowS
$cshowsPrec :: Int -> AuditLogEntryInfo -> ShowS
Show)

instance Aeson.FromJSON AuditLogEntryInfo where
  parseJSON :: Value -> Parser AuditLogEntryInfo
parseJSON = forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"AudotLogEntryInfo" forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Maybe Text
-> Maybe Text
-> Maybe (Snowflake Channel)
-> Maybe (Snowflake Message)
-> Maybe Text
-> Maybe (Snowflake ())
-> Maybe Text
-> Maybe Text
-> AuditLogEntryInfo
AuditLogEntryInfo
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"delete_member_days"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"members_removed"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"channel_id"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"message_id"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"count"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"id"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"type"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"role_name"

data AuditLogChange = AuditLogChange
  { AuditLogChange -> Maybe Value
newValue :: Maybe Aeson.Value
  , AuditLogChange -> Maybe Value
oldValue :: Maybe Aeson.Value
  , AuditLogChange -> Text
key :: Text
  }
  deriving (Int -> AuditLogChange -> ShowS
[AuditLogChange] -> ShowS
AuditLogChange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuditLogChange] -> ShowS
$cshowList :: [AuditLogChange] -> ShowS
show :: AuditLogChange -> String
$cshow :: AuditLogChange -> String
showsPrec :: Int -> AuditLogChange -> ShowS
$cshowsPrec :: Int -> AuditLogChange -> ShowS
Show)
  deriving (Int -> AuditLogChange -> Builder
Int -> AuditLogChange -> Text
Int -> AuditLogChange -> Text
[AuditLogChange] -> Builder
[AuditLogChange] -> Text
[AuditLogChange] -> Text
AuditLogChange -> Builder
AuditLogChange -> Text
AuditLogChange -> Text
forall a.
(Int -> a -> Builder)
-> (a -> Builder)
-> ([a] -> Builder)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> TextShow a
showtlList :: [AuditLogChange] -> Text
$cshowtlList :: [AuditLogChange] -> Text
showtl :: AuditLogChange -> Text
$cshowtl :: AuditLogChange -> Text
showtlPrec :: Int -> AuditLogChange -> Text
$cshowtlPrec :: Int -> AuditLogChange -> Text
showtList :: [AuditLogChange] -> Text
$cshowtList :: [AuditLogChange] -> Text
showt :: AuditLogChange -> Text
$cshowt :: AuditLogChange -> Text
showtPrec :: Int -> AuditLogChange -> Text
$cshowtPrec :: Int -> AuditLogChange -> Text
showbList :: [AuditLogChange] -> Builder
$cshowbList :: [AuditLogChange] -> Builder
showb :: AuditLogChange -> Builder
$cshowb :: AuditLogChange -> Builder
showbPrec :: Int -> AuditLogChange -> Builder
$cshowbPrec :: Int -> AuditLogChange -> Builder
TextShow.TextShow) via TextShow.FromStringShow AuditLogChange

instance Aeson.FromJSON AuditLogChange where
  parseJSON :: Value -> Parser AuditLogChange
parseJSON = forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"AudotLogChange" forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Maybe Value -> Maybe Value -> Text -> AuditLogChange
AuditLogChange
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"new_value"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"old_value"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"key"

data AuditLogAction
  = GUILD_UPDATE
  | CHANNEL_CREATE
  | CHANNEL_UPDATE
  | CHANNEL_DELETE
  | CHANNEL_OVERWRITE_CREATE
  | CHANNEL_OVERWRITE_UPDATE
  | CHANNEL_OVERWRITE_DELETE
  | MEMBER_KICK
  | MEMBER_PRUNE
  | MEMBER_BAN_ADD
  | MEMBER_BAN_REMOVE
  | MEMBER_UPDATE
  | MEMBER_ROLE_UPDATE
  | MEMBER_MOVE
  | MEMBER_DISCONNECT
  | BOT_ADD
  | ROLE_CREATE
  | ROLE_UPDATE
  | ROLE_DELETE
  | INVITE_CREATE
  | INVITE_UPDATE
  | INVITE_DELETE
  | WEBHOOK_CREATE
  | WEBHOOK_UPDATE
  | WEBHOOK_DELETE
  | EMOJI_CREATE
  | EMOJI_UPDATE
  | EMOJI_DELETE
  | MESSAGE_DELETE
  | MESSAGE_BULK_DELETE
  | MESSAGE_PIN
  | MESSAGE_UNPIN
  | INTEGRATION_CREATE
  | INTEGRATION_UPDATE
  | INTEGRATION_DELETE
  deriving (Int -> AuditLogAction -> ShowS
[AuditLogAction] -> ShowS
AuditLogAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuditLogAction] -> ShowS
$cshowList :: [AuditLogAction] -> ShowS
show :: AuditLogAction -> String
$cshow :: AuditLogAction -> String
showsPrec :: Int -> AuditLogAction -> ShowS
$cshowsPrec :: Int -> AuditLogAction -> ShowS
Show)

instance Enum AuditLogAction where
  toEnum :: Int -> AuditLogAction
toEnum Int
v = case Int
v of
    Int
1 -> AuditLogAction
GUILD_UPDATE
    Int
10 -> AuditLogAction
CHANNEL_CREATE
    Int
11 -> AuditLogAction
CHANNEL_UPDATE
    Int
12 -> AuditLogAction
CHANNEL_DELETE
    Int
13 -> AuditLogAction
CHANNEL_OVERWRITE_CREATE
    Int
14 -> AuditLogAction
CHANNEL_OVERWRITE_UPDATE
    Int
15 -> AuditLogAction
CHANNEL_OVERWRITE_DELETE
    Int
20 -> AuditLogAction
MEMBER_KICK
    Int
21 -> AuditLogAction
MEMBER_PRUNE
    Int
22 -> AuditLogAction
MEMBER_BAN_ADD
    Int
23 -> AuditLogAction
MEMBER_BAN_REMOVE
    Int
24 -> AuditLogAction
MEMBER_UPDATE
    Int
25 -> AuditLogAction
MEMBER_ROLE_UPDATE
    Int
26 -> AuditLogAction
MEMBER_MOVE
    Int
27 -> AuditLogAction
MEMBER_DISCONNECT
    Int
28 -> AuditLogAction
BOT_ADD
    Int
30 -> AuditLogAction
ROLE_CREATE
    Int
31 -> AuditLogAction
ROLE_UPDATE
    Int
32 -> AuditLogAction
ROLE_DELETE
    Int
40 -> AuditLogAction
INVITE_CREATE
    Int
41 -> AuditLogAction
INVITE_UPDATE
    Int
42 -> AuditLogAction
INVITE_DELETE
    Int
50 -> AuditLogAction
WEBHOOK_CREATE
    Int
51 -> AuditLogAction
WEBHOOK_UPDATE
    Int
52 -> AuditLogAction
WEBHOOK_DELETE
    Int
60 -> AuditLogAction
EMOJI_CREATE
    Int
61 -> AuditLogAction
EMOJI_UPDATE
    Int
62 -> AuditLogAction
EMOJI_DELETE
    Int
72 -> AuditLogAction
MESSAGE_DELETE
    Int
73 -> AuditLogAction
MESSAGE_BULK_DELETE
    Int
74 -> AuditLogAction
MESSAGE_PIN
    Int
75 -> AuditLogAction
MESSAGE_UNPIN
    Int
80 -> AuditLogAction
INTEGRATION_CREATE
    Int
81 -> AuditLogAction
INTEGRATION_UPDATE
    Int
82 -> AuditLogAction
INTEGRATION_DELETE
    Int
_ -> forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String
"Invalid AuditLogAction: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Int
v

  fromEnum :: AuditLogAction -> Int
fromEnum AuditLogAction
v = case AuditLogAction
v of
    AuditLogAction
GUILD_UPDATE -> Int
1
    AuditLogAction
CHANNEL_CREATE -> Int
10
    AuditLogAction
CHANNEL_UPDATE -> Int
11
    AuditLogAction
CHANNEL_DELETE -> Int
12
    AuditLogAction
CHANNEL_OVERWRITE_CREATE -> Int
13
    AuditLogAction
CHANNEL_OVERWRITE_UPDATE -> Int
14
    AuditLogAction
CHANNEL_OVERWRITE_DELETE -> Int
15
    AuditLogAction
MEMBER_KICK -> Int
20
    AuditLogAction
MEMBER_PRUNE -> Int
21
    AuditLogAction
MEMBER_BAN_ADD -> Int
22
    AuditLogAction
MEMBER_BAN_REMOVE -> Int
23
    AuditLogAction
MEMBER_UPDATE -> Int
24
    AuditLogAction
MEMBER_ROLE_UPDATE -> Int
25
    AuditLogAction
MEMBER_MOVE -> Int
26
    AuditLogAction
MEMBER_DISCONNECT -> Int
27
    AuditLogAction
BOT_ADD -> Int
28
    AuditLogAction
ROLE_CREATE -> Int
30
    AuditLogAction
ROLE_UPDATE -> Int
31
    AuditLogAction
ROLE_DELETE -> Int
32
    AuditLogAction
INVITE_CREATE -> Int
40
    AuditLogAction
INVITE_UPDATE -> Int
41
    AuditLogAction
INVITE_DELETE -> Int
42
    AuditLogAction
WEBHOOK_CREATE -> Int
50
    AuditLogAction
WEBHOOK_UPDATE -> Int
51
    AuditLogAction
WEBHOOK_DELETE -> Int
52
    AuditLogAction
EMOJI_CREATE -> Int
60
    AuditLogAction
EMOJI_UPDATE -> Int
61
    AuditLogAction
EMOJI_DELETE -> Int
62
    AuditLogAction
MESSAGE_DELETE -> Int
72
    AuditLogAction
MESSAGE_BULK_DELETE -> Int
73
    AuditLogAction
MESSAGE_PIN -> Int
74
    AuditLogAction
MESSAGE_UNPIN -> Int
75
    AuditLogAction
INTEGRATION_CREATE -> Int
80
    AuditLogAction
INTEGRATION_UPDATE -> Int
81
    AuditLogAction
INTEGRATION_DELETE -> Int
82

instance Aeson.FromJSON AuditLogAction where
  parseJSON :: Value -> Parser AuditLogAction
parseJSON = forall a. String -> (Scientific -> Parser a) -> Value -> Parser a
Aeson.withScientific String
"AuditLogAction" forall a b. (a -> b) -> a -> b
$ \Scientific
n -> case forall i. (Integral i, Bounded i) => Scientific -> Maybe i
toBoundedInteger @Int Scientific
n of
    Just Int
v -> case Int
v of --  no safe toEnum :S
      Int
1 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
GUILD_UPDATE
      Int
10 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
CHANNEL_CREATE
      Int
11 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
CHANNEL_UPDATE
      Int
12 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
CHANNEL_DELETE
      Int
13 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
CHANNEL_OVERWRITE_CREATE
      Int
14 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
CHANNEL_OVERWRITE_UPDATE
      Int
15 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
CHANNEL_OVERWRITE_DELETE
      Int
20 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MEMBER_KICK
      Int
21 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MEMBER_PRUNE
      Int
22 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MEMBER_BAN_ADD
      Int
23 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MEMBER_BAN_REMOVE
      Int
24 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MEMBER_UPDATE
      Int
25 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MEMBER_ROLE_UPDATE
      Int
26 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MEMBER_MOVE
      Int
27 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MEMBER_DISCONNECT
      Int
28 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
BOT_ADD
      Int
30 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
ROLE_CREATE
      Int
31 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
ROLE_UPDATE
      Int
32 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
ROLE_DELETE
      Int
40 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
INVITE_CREATE
      Int
41 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
INVITE_UPDATE
      Int
42 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
INVITE_DELETE
      Int
50 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
WEBHOOK_CREATE
      Int
51 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
WEBHOOK_UPDATE
      Int
52 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
WEBHOOK_DELETE
      Int
60 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
EMOJI_CREATE
      Int
61 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
EMOJI_UPDATE
      Int
62 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
EMOJI_DELETE
      Int
72 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MESSAGE_DELETE
      Int
73 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MESSAGE_BULK_DELETE
      Int
74 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MESSAGE_PIN
      Int
75 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
MESSAGE_UNPIN
      Int
80 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
INTEGRATION_CREATE
      Int
81 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
INTEGRATION_UPDATE
      Int
82 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure AuditLogAction
INTEGRATION_DELETE
      Int
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid AuditLogAction: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Scientific
n
    Maybe Int
Nothing -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid AuditLogAction: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Scientific
n

instance Aeson.ToJSON AuditLogAction where
  toJSON :: AuditLogAction -> Value
toJSON = forall a. ToJSON a => a -> Value
Aeson.toJSON @Int forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => a -> Int
fromEnum
  toEncoding :: AuditLogAction -> Encoding
toEncoding = forall a. ToJSON a => a -> Encoding
Aeson.toEncoding @Int forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => a -> Int
fromEnum

$(deriveTextShow ''AuditLogAction)
$(deriveTextShow ''AuditLogEntryInfo)
$(deriveTextShow ''AuditLogEntry)
$(deriveTextShow ''AuditLog)

$(makeFieldLabelsNoPrefix ''AuditLog)
$(makeFieldLabelsNoPrefix ''AuditLogEntry)
$(makeFieldLabelsNoPrefix ''AuditLogEntryInfo)
$(makeFieldLabelsNoPrefix ''AuditLogChange)