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

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

-- | What occurs after a certain event.
--
-- /See:/ 'newAction' smart constructor.
data Action = Action'
  { -- | Details for the export revision to Amazon S3 action.
    Action -> Maybe AutoExportRevisionToS3RequestDetails
exportRevisionToS3 :: Prelude.Maybe AutoExportRevisionToS3RequestDetails
  }
  deriving (Action -> Action -> Bool
(Action -> Action -> Bool)
-> (Action -> Action -> Bool) -> Eq Action
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Action -> Action -> Bool
$c/= :: Action -> Action -> Bool
== :: Action -> Action -> Bool
$c== :: Action -> Action -> Bool
Prelude.Eq, ReadPrec [Action]
ReadPrec Action
Int -> ReadS Action
ReadS [Action]
(Int -> ReadS Action)
-> ReadS [Action]
-> ReadPrec Action
-> ReadPrec [Action]
-> Read Action
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Action]
$creadListPrec :: ReadPrec [Action]
readPrec :: ReadPrec Action
$creadPrec :: ReadPrec Action
readList :: ReadS [Action]
$creadList :: ReadS [Action]
readsPrec :: Int -> ReadS Action
$creadsPrec :: Int -> ReadS Action
Prelude.Read, Int -> Action -> ShowS
[Action] -> ShowS
Action -> String
(Int -> Action -> ShowS)
-> (Action -> String) -> ([Action] -> ShowS) -> Show Action
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Action] -> ShowS
$cshowList :: [Action] -> ShowS
show :: Action -> String
$cshow :: Action -> String
showsPrec :: Int -> Action -> ShowS
$cshowsPrec :: Int -> Action -> ShowS
Prelude.Show, (forall x. Action -> Rep Action x)
-> (forall x. Rep Action x -> Action) -> Generic Action
forall x. Rep Action x -> Action
forall x. Action -> Rep Action x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Action x -> Action
$cfrom :: forall x. Action -> Rep Action x
Prelude.Generic)

-- |
-- Create a value of 'Action' 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:
--
-- 'exportRevisionToS3', 'action_exportRevisionToS3' - Details for the export revision to Amazon S3 action.
newAction ::
  Action
newAction :: Action
newAction =
  Action' :: Maybe AutoExportRevisionToS3RequestDetails -> Action
Action' {$sel:exportRevisionToS3:Action' :: Maybe AutoExportRevisionToS3RequestDetails
exportRevisionToS3 = Maybe AutoExportRevisionToS3RequestDetails
forall a. Maybe a
Prelude.Nothing}

-- | Details for the export revision to Amazon S3 action.
action_exportRevisionToS3 :: Lens.Lens' Action (Prelude.Maybe AutoExportRevisionToS3RequestDetails)
action_exportRevisionToS3 :: (Maybe AutoExportRevisionToS3RequestDetails
 -> f (Maybe AutoExportRevisionToS3RequestDetails))
-> Action -> f Action
action_exportRevisionToS3 = (Action -> Maybe AutoExportRevisionToS3RequestDetails)
-> (Action -> Maybe AutoExportRevisionToS3RequestDetails -> Action)
-> Lens
     Action
     Action
     (Maybe AutoExportRevisionToS3RequestDetails)
     (Maybe AutoExportRevisionToS3RequestDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe AutoExportRevisionToS3RequestDetails
exportRevisionToS3 :: Maybe AutoExportRevisionToS3RequestDetails
$sel:exportRevisionToS3:Action' :: Action -> Maybe AutoExportRevisionToS3RequestDetails
exportRevisionToS3} -> Maybe AutoExportRevisionToS3RequestDetails
exportRevisionToS3) (\s :: Action
s@Action' {} Maybe AutoExportRevisionToS3RequestDetails
a -> Action
s {$sel:exportRevisionToS3:Action' :: Maybe AutoExportRevisionToS3RequestDetails
exportRevisionToS3 = Maybe AutoExportRevisionToS3RequestDetails
a} :: Action)

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

instance Prelude.Hashable Action

instance Prelude.NFData Action

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