{-# 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.Event
-- 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.Event where

import qualified Amazonka.Core as Core
import Amazonka.DataExchange.Types.RevisionPublished
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | What occurs to start an action.
--
-- /See:/ 'newEvent' smart constructor.
data Event = Event'
  { -- | What occurs to start the revision publish action.
    Event -> Maybe RevisionPublished
revisionPublished :: Prelude.Maybe RevisionPublished
  }
  deriving (Event -> Event -> Bool
(Event -> Event -> Bool) -> (Event -> Event -> Bool) -> Eq Event
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Event -> Event -> Bool
$c/= :: Event -> Event -> Bool
== :: Event -> Event -> Bool
$c== :: Event -> Event -> Bool
Prelude.Eq, ReadPrec [Event]
ReadPrec Event
Int -> ReadS Event
ReadS [Event]
(Int -> ReadS Event)
-> ReadS [Event]
-> ReadPrec Event
-> ReadPrec [Event]
-> Read Event
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Event]
$creadListPrec :: ReadPrec [Event]
readPrec :: ReadPrec Event
$creadPrec :: ReadPrec Event
readList :: ReadS [Event]
$creadList :: ReadS [Event]
readsPrec :: Int -> ReadS Event
$creadsPrec :: Int -> ReadS Event
Prelude.Read, Int -> Event -> ShowS
[Event] -> ShowS
Event -> String
(Int -> Event -> ShowS)
-> (Event -> String) -> ([Event] -> ShowS) -> Show Event
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Event] -> ShowS
$cshowList :: [Event] -> ShowS
show :: Event -> String
$cshow :: Event -> String
showsPrec :: Int -> Event -> ShowS
$cshowsPrec :: Int -> Event -> ShowS
Prelude.Show, (forall x. Event -> Rep Event x)
-> (forall x. Rep Event x -> Event) -> Generic Event
forall x. Rep Event x -> Event
forall x. Event -> Rep Event x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Event x -> Event
$cfrom :: forall x. Event -> Rep Event x
Prelude.Generic)

-- |
-- Create a value of 'Event' 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:
--
-- 'revisionPublished', 'event_revisionPublished' - What occurs to start the revision publish action.
newEvent ::
  Event
newEvent :: Event
newEvent =
  Event' :: Maybe RevisionPublished -> Event
Event' {$sel:revisionPublished:Event' :: Maybe RevisionPublished
revisionPublished = Maybe RevisionPublished
forall a. Maybe a
Prelude.Nothing}

-- | What occurs to start the revision publish action.
event_revisionPublished :: Lens.Lens' Event (Prelude.Maybe RevisionPublished)
event_revisionPublished :: (Maybe RevisionPublished -> f (Maybe RevisionPublished))
-> Event -> f Event
event_revisionPublished = (Event -> Maybe RevisionPublished)
-> (Event -> Maybe RevisionPublished -> Event)
-> Lens
     Event Event (Maybe RevisionPublished) (Maybe RevisionPublished)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe RevisionPublished
revisionPublished :: Maybe RevisionPublished
$sel:revisionPublished:Event' :: Event -> Maybe RevisionPublished
revisionPublished} -> Maybe RevisionPublished
revisionPublished) (\s :: Event
s@Event' {} Maybe RevisionPublished
a -> Event
s {$sel:revisionPublished:Event' :: Maybe RevisionPublished
revisionPublished = Maybe RevisionPublished
a} :: Event)

instance Core.FromJSON Event where
  parseJSON :: Value -> Parser Event
parseJSON =
    String -> (Object -> Parser Event) -> Value -> Parser Event
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Event"
      ( \Object
x ->
          Maybe RevisionPublished -> Event
Event' (Maybe RevisionPublished -> Event)
-> Parser (Maybe RevisionPublished) -> Parser Event
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RevisionPublished)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RevisionPublished")
      )

instance Prelude.Hashable Event

instance Prelude.NFData Event

instance Core.ToJSON Event where
  toJSON :: Event -> Value
toJSON Event' {Maybe RevisionPublished
revisionPublished :: Maybe RevisionPublished
$sel:revisionPublished:Event' :: Event -> Maybe RevisionPublished
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RevisionPublished" Text -> RevisionPublished -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RevisionPublished -> Pair)
-> Maybe RevisionPublished -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RevisionPublished
revisionPublished
          ]
      )