{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataExchange.Types.Event where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataExchange.Types.RevisionPublished
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
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]
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
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. 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' {$sel:revisionPublished:Event' :: Maybe RevisionPublished
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 :: Lens' Event (Maybe RevisionPublished)
event_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 Data.FromJSON Event where
  parseJSON :: Value -> Parser Event
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Event"
      ( \Object
x ->
          Maybe RevisionPublished -> Event
Event' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RevisionPublished")
      )

instance Prelude.Hashable Event where
  hashWithSalt :: Int -> Event -> Int
hashWithSalt Int
_salt Event' {Maybe RevisionPublished
revisionPublished :: Maybe RevisionPublished
$sel:revisionPublished:Event' :: Event -> Maybe RevisionPublished
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RevisionPublished
revisionPublished

instance Prelude.NFData Event where
  rnf :: Event -> ()
rnf Event' {Maybe RevisionPublished
revisionPublished :: Maybe RevisionPublished
$sel:revisionPublished:Event' :: Event -> Maybe RevisionPublished
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe RevisionPublished
revisionPublished

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