{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Budgets.Types.ActionHistory
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Budgets.Types.ActionHistory where

import Amazonka.Budgets.Types.ActionHistoryDetails
import Amazonka.Budgets.Types.ActionStatus
import Amazonka.Budgets.Types.EventType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The historical records for a budget action.
--
-- /See:/ 'newActionHistory' smart constructor.
data ActionHistory = ActionHistory'
  { ActionHistory -> POSIX
timestamp :: Core.POSIX,
    -- | The status of action at the time of the event.
    ActionHistory -> ActionStatus
status :: ActionStatus,
    -- | This distinguishes between whether the events are triggered by the user
    -- or generated by the system.
    ActionHistory -> EventType
eventType :: EventType,
    -- | The description of details of the event.
    ActionHistory -> ActionHistoryDetails
actionHistoryDetails :: ActionHistoryDetails
  }
  deriving (ActionHistory -> ActionHistory -> Bool
(ActionHistory -> ActionHistory -> Bool)
-> (ActionHistory -> ActionHistory -> Bool) -> Eq ActionHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionHistory -> ActionHistory -> Bool
$c/= :: ActionHistory -> ActionHistory -> Bool
== :: ActionHistory -> ActionHistory -> Bool
$c== :: ActionHistory -> ActionHistory -> Bool
Prelude.Eq, Int -> ActionHistory -> ShowS
[ActionHistory] -> ShowS
ActionHistory -> String
(Int -> ActionHistory -> ShowS)
-> (ActionHistory -> String)
-> ([ActionHistory] -> ShowS)
-> Show ActionHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionHistory] -> ShowS
$cshowList :: [ActionHistory] -> ShowS
show :: ActionHistory -> String
$cshow :: ActionHistory -> String
showsPrec :: Int -> ActionHistory -> ShowS
$cshowsPrec :: Int -> ActionHistory -> ShowS
Prelude.Show, (forall x. ActionHistory -> Rep ActionHistory x)
-> (forall x. Rep ActionHistory x -> ActionHistory)
-> Generic ActionHistory
forall x. Rep ActionHistory x -> ActionHistory
forall x. ActionHistory -> Rep ActionHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionHistory x -> ActionHistory
$cfrom :: forall x. ActionHistory -> Rep ActionHistory x
Prelude.Generic)

-- |
-- Create a value of 'ActionHistory' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'timestamp', 'actionHistory_timestamp' - Undocumented member.
--
-- 'status', 'actionHistory_status' - The status of action at the time of the event.
--
-- 'eventType', 'actionHistory_eventType' - This distinguishes between whether the events are triggered by the user
-- or generated by the system.
--
-- 'actionHistoryDetails', 'actionHistory_actionHistoryDetails' - The description of details of the event.
newActionHistory ::
  -- | 'timestamp'
  Prelude.UTCTime ->
  -- | 'status'
  ActionStatus ->
  -- | 'eventType'
  EventType ->
  -- | 'actionHistoryDetails'
  ActionHistoryDetails ->
  ActionHistory
newActionHistory :: UTCTime
-> ActionStatus
-> EventType
-> ActionHistoryDetails
-> ActionHistory
newActionHistory
  UTCTime
pTimestamp_
  ActionStatus
pStatus_
  EventType
pEventType_
  ActionHistoryDetails
pActionHistoryDetails_ =
    ActionHistory' :: POSIX
-> ActionStatus
-> EventType
-> ActionHistoryDetails
-> ActionHistory
ActionHistory'
      { $sel:timestamp:ActionHistory' :: POSIX
timestamp =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pTimestamp_,
        $sel:status:ActionHistory' :: ActionStatus
status = ActionStatus
pStatus_,
        $sel:eventType:ActionHistory' :: EventType
eventType = EventType
pEventType_,
        $sel:actionHistoryDetails:ActionHistory' :: ActionHistoryDetails
actionHistoryDetails = ActionHistoryDetails
pActionHistoryDetails_
      }

-- | Undocumented member.
actionHistory_timestamp :: Lens.Lens' ActionHistory Prelude.UTCTime
actionHistory_timestamp :: (UTCTime -> f UTCTime) -> ActionHistory -> f ActionHistory
actionHistory_timestamp = (ActionHistory -> POSIX)
-> (ActionHistory -> POSIX -> ActionHistory)
-> Lens ActionHistory ActionHistory POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionHistory' {POSIX
timestamp :: POSIX
$sel:timestamp:ActionHistory' :: ActionHistory -> POSIX
timestamp} -> POSIX
timestamp) (\s :: ActionHistory
s@ActionHistory' {} POSIX
a -> ActionHistory
s {$sel:timestamp:ActionHistory' :: POSIX
timestamp = POSIX
a} :: ActionHistory) ((POSIX -> f POSIX) -> ActionHistory -> f ActionHistory)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ActionHistory
-> f ActionHistory
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The status of action at the time of the event.
actionHistory_status :: Lens.Lens' ActionHistory ActionStatus
actionHistory_status :: (ActionStatus -> f ActionStatus)
-> ActionHistory -> f ActionHistory
actionHistory_status = (ActionHistory -> ActionStatus)
-> (ActionHistory -> ActionStatus -> ActionHistory)
-> Lens ActionHistory ActionHistory ActionStatus ActionStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionHistory' {ActionStatus
status :: ActionStatus
$sel:status:ActionHistory' :: ActionHistory -> ActionStatus
status} -> ActionStatus
status) (\s :: ActionHistory
s@ActionHistory' {} ActionStatus
a -> ActionHistory
s {$sel:status:ActionHistory' :: ActionStatus
status = ActionStatus
a} :: ActionHistory)

-- | This distinguishes between whether the events are triggered by the user
-- or generated by the system.
actionHistory_eventType :: Lens.Lens' ActionHistory EventType
actionHistory_eventType :: (EventType -> f EventType) -> ActionHistory -> f ActionHistory
actionHistory_eventType = (ActionHistory -> EventType)
-> (ActionHistory -> EventType -> ActionHistory)
-> Lens ActionHistory ActionHistory EventType EventType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionHistory' {EventType
eventType :: EventType
$sel:eventType:ActionHistory' :: ActionHistory -> EventType
eventType} -> EventType
eventType) (\s :: ActionHistory
s@ActionHistory' {} EventType
a -> ActionHistory
s {$sel:eventType:ActionHistory' :: EventType
eventType = EventType
a} :: ActionHistory)

-- | The description of details of the event.
actionHistory_actionHistoryDetails :: Lens.Lens' ActionHistory ActionHistoryDetails
actionHistory_actionHistoryDetails :: (ActionHistoryDetails -> f ActionHistoryDetails)
-> ActionHistory -> f ActionHistory
actionHistory_actionHistoryDetails = (ActionHistory -> ActionHistoryDetails)
-> (ActionHistory -> ActionHistoryDetails -> ActionHistory)
-> Lens
     ActionHistory
     ActionHistory
     ActionHistoryDetails
     ActionHistoryDetails
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionHistory' {ActionHistoryDetails
actionHistoryDetails :: ActionHistoryDetails
$sel:actionHistoryDetails:ActionHistory' :: ActionHistory -> ActionHistoryDetails
actionHistoryDetails} -> ActionHistoryDetails
actionHistoryDetails) (\s :: ActionHistory
s@ActionHistory' {} ActionHistoryDetails
a -> ActionHistory
s {$sel:actionHistoryDetails:ActionHistory' :: ActionHistoryDetails
actionHistoryDetails = ActionHistoryDetails
a} :: ActionHistory)

instance Core.FromJSON ActionHistory where
  parseJSON :: Value -> Parser ActionHistory
parseJSON =
    String
-> (Object -> Parser ActionHistory)
-> Value
-> Parser ActionHistory
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ActionHistory"
      ( \Object
x ->
          POSIX
-> ActionStatus
-> EventType
-> ActionHistoryDetails
-> ActionHistory
ActionHistory'
            (POSIX
 -> ActionStatus
 -> EventType
 -> ActionHistoryDetails
 -> ActionHistory)
-> Parser POSIX
-> Parser
     (ActionStatus
      -> EventType -> ActionHistoryDetails -> ActionHistory)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Timestamp")
            Parser
  (ActionStatus
   -> EventType -> ActionHistoryDetails -> ActionHistory)
-> Parser ActionStatus
-> Parser (EventType -> ActionHistoryDetails -> ActionHistory)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ActionStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Status")
            Parser (EventType -> ActionHistoryDetails -> ActionHistory)
-> Parser EventType
-> Parser (ActionHistoryDetails -> ActionHistory)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser EventType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EventType")
            Parser (ActionHistoryDetails -> ActionHistory)
-> Parser ActionHistoryDetails -> Parser ActionHistory
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ActionHistoryDetails
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ActionHistoryDetails")
      )

instance Prelude.Hashable ActionHistory

instance Prelude.NFData ActionHistory