{-# 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.DataExchange.Types.EventActionEntry
-- 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.DataExchange.Types.EventActionEntry where

import qualified Amazonka.Core as Core
import Amazonka.DataExchange.Types.Action
import Amazonka.DataExchange.Types.Event
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An event action is an object that defines the relationship between a
-- specific event and an automated action that will be taken on behalf of
-- the customer.
--
-- /See:/ 'newEventActionEntry' smart constructor.
data EventActionEntry = EventActionEntry'
  { -- | What occurs after a certain event.
    EventActionEntry -> Action
action :: Action,
    -- | The date and time that the event action was created, in ISO 8601 format.
    EventActionEntry -> POSIX
createdAt :: Core.POSIX,
    -- | What occurs to start an action.
    EventActionEntry -> Event
event :: Event,
    -- | The unique identifier for the event action.
    EventActionEntry -> Text
id :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) for the event action.
    EventActionEntry -> Text
arn :: Prelude.Text,
    -- | The date and time that the event action was last updated, in ISO 8601
    -- format.
    EventActionEntry -> POSIX
updatedAt :: Core.POSIX
  }
  deriving (EventActionEntry -> EventActionEntry -> Bool
(EventActionEntry -> EventActionEntry -> Bool)
-> (EventActionEntry -> EventActionEntry -> Bool)
-> Eq EventActionEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventActionEntry -> EventActionEntry -> Bool
$c/= :: EventActionEntry -> EventActionEntry -> Bool
== :: EventActionEntry -> EventActionEntry -> Bool
$c== :: EventActionEntry -> EventActionEntry -> Bool
Prelude.Eq, ReadPrec [EventActionEntry]
ReadPrec EventActionEntry
Int -> ReadS EventActionEntry
ReadS [EventActionEntry]
(Int -> ReadS EventActionEntry)
-> ReadS [EventActionEntry]
-> ReadPrec EventActionEntry
-> ReadPrec [EventActionEntry]
-> Read EventActionEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventActionEntry]
$creadListPrec :: ReadPrec [EventActionEntry]
readPrec :: ReadPrec EventActionEntry
$creadPrec :: ReadPrec EventActionEntry
readList :: ReadS [EventActionEntry]
$creadList :: ReadS [EventActionEntry]
readsPrec :: Int -> ReadS EventActionEntry
$creadsPrec :: Int -> ReadS EventActionEntry
Prelude.Read, Int -> EventActionEntry -> ShowS
[EventActionEntry] -> ShowS
EventActionEntry -> String
(Int -> EventActionEntry -> ShowS)
-> (EventActionEntry -> String)
-> ([EventActionEntry] -> ShowS)
-> Show EventActionEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventActionEntry] -> ShowS
$cshowList :: [EventActionEntry] -> ShowS
show :: EventActionEntry -> String
$cshow :: EventActionEntry -> String
showsPrec :: Int -> EventActionEntry -> ShowS
$cshowsPrec :: Int -> EventActionEntry -> ShowS
Prelude.Show, (forall x. EventActionEntry -> Rep EventActionEntry x)
-> (forall x. Rep EventActionEntry x -> EventActionEntry)
-> Generic EventActionEntry
forall x. Rep EventActionEntry x -> EventActionEntry
forall x. EventActionEntry -> Rep EventActionEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventActionEntry x -> EventActionEntry
$cfrom :: forall x. EventActionEntry -> Rep EventActionEntry x
Prelude.Generic)

-- |
-- Create a value of 'EventActionEntry' 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:
--
-- 'action', 'eventActionEntry_action' - What occurs after a certain event.
--
-- 'createdAt', 'eventActionEntry_createdAt' - The date and time that the event action was created, in ISO 8601 format.
--
-- 'event', 'eventActionEntry_event' - What occurs to start an action.
--
-- 'id', 'eventActionEntry_id' - The unique identifier for the event action.
--
-- 'arn', 'eventActionEntry_arn' - The Amazon Resource Name (ARN) for the event action.
--
-- 'updatedAt', 'eventActionEntry_updatedAt' - The date and time that the event action was last updated, in ISO 8601
-- format.
newEventActionEntry ::
  -- | 'action'
  Action ->
  -- | 'createdAt'
  Prelude.UTCTime ->
  -- | 'event'
  Event ->
  -- | 'id'
  Prelude.Text ->
  -- | 'arn'
  Prelude.Text ->
  -- | 'updatedAt'
  Prelude.UTCTime ->
  EventActionEntry
newEventActionEntry :: Action
-> UTCTime -> Event -> Text -> Text -> UTCTime -> EventActionEntry
newEventActionEntry
  Action
pAction_
  UTCTime
pCreatedAt_
  Event
pEvent_
  Text
pId_
  Text
pArn_
  UTCTime
pUpdatedAt_ =
    EventActionEntry' :: Action
-> POSIX -> Event -> Text -> Text -> POSIX -> EventActionEntry
EventActionEntry'
      { $sel:action:EventActionEntry' :: Action
action = Action
pAction_,
        $sel:createdAt:EventActionEntry' :: POSIX
createdAt = 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
pCreatedAt_,
        $sel:event:EventActionEntry' :: Event
event = Event
pEvent_,
        $sel:id:EventActionEntry' :: Text
id = Text
pId_,
        $sel:arn:EventActionEntry' :: Text
arn = Text
pArn_,
        $sel:updatedAt:EventActionEntry' :: POSIX
updatedAt = 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
pUpdatedAt_
      }

-- | What occurs after a certain event.
eventActionEntry_action :: Lens.Lens' EventActionEntry Action
eventActionEntry_action :: (Action -> f Action) -> EventActionEntry -> f EventActionEntry
eventActionEntry_action = (EventActionEntry -> Action)
-> (EventActionEntry -> Action -> EventActionEntry)
-> Lens EventActionEntry EventActionEntry Action Action
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventActionEntry' {Action
action :: Action
$sel:action:EventActionEntry' :: EventActionEntry -> Action
action} -> Action
action) (\s :: EventActionEntry
s@EventActionEntry' {} Action
a -> EventActionEntry
s {$sel:action:EventActionEntry' :: Action
action = Action
a} :: EventActionEntry)

-- | The date and time that the event action was created, in ISO 8601 format.
eventActionEntry_createdAt :: Lens.Lens' EventActionEntry Prelude.UTCTime
eventActionEntry_createdAt :: (UTCTime -> f UTCTime) -> EventActionEntry -> f EventActionEntry
eventActionEntry_createdAt = (EventActionEntry -> POSIX)
-> (EventActionEntry -> POSIX -> EventActionEntry)
-> Lens EventActionEntry EventActionEntry POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventActionEntry' {POSIX
createdAt :: POSIX
$sel:createdAt:EventActionEntry' :: EventActionEntry -> POSIX
createdAt} -> POSIX
createdAt) (\s :: EventActionEntry
s@EventActionEntry' {} POSIX
a -> EventActionEntry
s {$sel:createdAt:EventActionEntry' :: POSIX
createdAt = POSIX
a} :: EventActionEntry) ((POSIX -> f POSIX) -> EventActionEntry -> f EventActionEntry)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> EventActionEntry
-> f EventActionEntry
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

-- | What occurs to start an action.
eventActionEntry_event :: Lens.Lens' EventActionEntry Event
eventActionEntry_event :: (Event -> f Event) -> EventActionEntry -> f EventActionEntry
eventActionEntry_event = (EventActionEntry -> Event)
-> (EventActionEntry -> Event -> EventActionEntry)
-> Lens EventActionEntry EventActionEntry Event Event
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventActionEntry' {Event
event :: Event
$sel:event:EventActionEntry' :: EventActionEntry -> Event
event} -> Event
event) (\s :: EventActionEntry
s@EventActionEntry' {} Event
a -> EventActionEntry
s {$sel:event:EventActionEntry' :: Event
event = Event
a} :: EventActionEntry)

-- | The unique identifier for the event action.
eventActionEntry_id :: Lens.Lens' EventActionEntry Prelude.Text
eventActionEntry_id :: (Text -> f Text) -> EventActionEntry -> f EventActionEntry
eventActionEntry_id = (EventActionEntry -> Text)
-> (EventActionEntry -> Text -> EventActionEntry)
-> Lens EventActionEntry EventActionEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventActionEntry' {Text
id :: Text
$sel:id:EventActionEntry' :: EventActionEntry -> Text
id} -> Text
id) (\s :: EventActionEntry
s@EventActionEntry' {} Text
a -> EventActionEntry
s {$sel:id:EventActionEntry' :: Text
id = Text
a} :: EventActionEntry)

-- | The Amazon Resource Name (ARN) for the event action.
eventActionEntry_arn :: Lens.Lens' EventActionEntry Prelude.Text
eventActionEntry_arn :: (Text -> f Text) -> EventActionEntry -> f EventActionEntry
eventActionEntry_arn = (EventActionEntry -> Text)
-> (EventActionEntry -> Text -> EventActionEntry)
-> Lens EventActionEntry EventActionEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventActionEntry' {Text
arn :: Text
$sel:arn:EventActionEntry' :: EventActionEntry -> Text
arn} -> Text
arn) (\s :: EventActionEntry
s@EventActionEntry' {} Text
a -> EventActionEntry
s {$sel:arn:EventActionEntry' :: Text
arn = Text
a} :: EventActionEntry)

-- | The date and time that the event action was last updated, in ISO 8601
-- format.
eventActionEntry_updatedAt :: Lens.Lens' EventActionEntry Prelude.UTCTime
eventActionEntry_updatedAt :: (UTCTime -> f UTCTime) -> EventActionEntry -> f EventActionEntry
eventActionEntry_updatedAt = (EventActionEntry -> POSIX)
-> (EventActionEntry -> POSIX -> EventActionEntry)
-> Lens EventActionEntry EventActionEntry POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventActionEntry' {POSIX
updatedAt :: POSIX
$sel:updatedAt:EventActionEntry' :: EventActionEntry -> POSIX
updatedAt} -> POSIX
updatedAt) (\s :: EventActionEntry
s@EventActionEntry' {} POSIX
a -> EventActionEntry
s {$sel:updatedAt:EventActionEntry' :: POSIX
updatedAt = POSIX
a} :: EventActionEntry) ((POSIX -> f POSIX) -> EventActionEntry -> f EventActionEntry)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> EventActionEntry
-> f EventActionEntry
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

instance Core.FromJSON EventActionEntry where
  parseJSON :: Value -> Parser EventActionEntry
parseJSON =
    String
-> (Object -> Parser EventActionEntry)
-> Value
-> Parser EventActionEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventActionEntry"
      ( \Object
x ->
          Action
-> POSIX -> Event -> Text -> Text -> POSIX -> EventActionEntry
EventActionEntry'
            (Action
 -> POSIX -> Event -> Text -> Text -> POSIX -> EventActionEntry)
-> Parser Action
-> Parser
     (POSIX -> Event -> Text -> Text -> POSIX -> EventActionEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Action
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Action")
            Parser
  (POSIX -> Event -> Text -> Text -> POSIX -> EventActionEntry)
-> Parser POSIX
-> Parser (Event -> Text -> Text -> POSIX -> EventActionEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CreatedAt")
            Parser (Event -> Text -> Text -> POSIX -> EventActionEntry)
-> Parser Event
-> Parser (Text -> Text -> POSIX -> EventActionEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Event
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Event")
            Parser (Text -> Text -> POSIX -> EventActionEntry)
-> Parser Text -> Parser (Text -> POSIX -> EventActionEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
            Parser (Text -> POSIX -> EventActionEntry)
-> Parser Text -> Parser (POSIX -> EventActionEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Arn")
            Parser (POSIX -> EventActionEntry)
-> Parser POSIX -> Parser EventActionEntry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"UpdatedAt")
      )

instance Prelude.Hashable EventActionEntry

instance Prelude.NFData EventActionEntry