{-# 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.CustomerProfiles.Types.TriggerConfig
-- 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.CustomerProfiles.Types.TriggerConfig where

import qualified Amazonka.Core as Core
import Amazonka.CustomerProfiles.Types.TriggerProperties
import Amazonka.CustomerProfiles.Types.TriggerType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The trigger settings that determine how and when Amazon AppFlow runs the
-- specified flow.
--
-- /See:/ 'newTriggerConfig' smart constructor.
data TriggerConfig = TriggerConfig'
  { -- | Specifies the configuration details of a schedule-triggered flow that
    -- you define. Currently, these settings only apply to the Scheduled
    -- trigger type.
    TriggerConfig -> Maybe TriggerProperties
triggerProperties :: Prelude.Maybe TriggerProperties,
    -- | Specifies the type of flow trigger. It can be OnDemand, Scheduled, or
    -- Event.
    TriggerConfig -> TriggerType
triggerType :: TriggerType
  }
  deriving (TriggerConfig -> TriggerConfig -> Bool
(TriggerConfig -> TriggerConfig -> Bool)
-> (TriggerConfig -> TriggerConfig -> Bool) -> Eq TriggerConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TriggerConfig -> TriggerConfig -> Bool
$c/= :: TriggerConfig -> TriggerConfig -> Bool
== :: TriggerConfig -> TriggerConfig -> Bool
$c== :: TriggerConfig -> TriggerConfig -> Bool
Prelude.Eq, ReadPrec [TriggerConfig]
ReadPrec TriggerConfig
Int -> ReadS TriggerConfig
ReadS [TriggerConfig]
(Int -> ReadS TriggerConfig)
-> ReadS [TriggerConfig]
-> ReadPrec TriggerConfig
-> ReadPrec [TriggerConfig]
-> Read TriggerConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TriggerConfig]
$creadListPrec :: ReadPrec [TriggerConfig]
readPrec :: ReadPrec TriggerConfig
$creadPrec :: ReadPrec TriggerConfig
readList :: ReadS [TriggerConfig]
$creadList :: ReadS [TriggerConfig]
readsPrec :: Int -> ReadS TriggerConfig
$creadsPrec :: Int -> ReadS TriggerConfig
Prelude.Read, Int -> TriggerConfig -> ShowS
[TriggerConfig] -> ShowS
TriggerConfig -> String
(Int -> TriggerConfig -> ShowS)
-> (TriggerConfig -> String)
-> ([TriggerConfig] -> ShowS)
-> Show TriggerConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TriggerConfig] -> ShowS
$cshowList :: [TriggerConfig] -> ShowS
show :: TriggerConfig -> String
$cshow :: TriggerConfig -> String
showsPrec :: Int -> TriggerConfig -> ShowS
$cshowsPrec :: Int -> TriggerConfig -> ShowS
Prelude.Show, (forall x. TriggerConfig -> Rep TriggerConfig x)
-> (forall x. Rep TriggerConfig x -> TriggerConfig)
-> Generic TriggerConfig
forall x. Rep TriggerConfig x -> TriggerConfig
forall x. TriggerConfig -> Rep TriggerConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TriggerConfig x -> TriggerConfig
$cfrom :: forall x. TriggerConfig -> Rep TriggerConfig x
Prelude.Generic)

-- |
-- Create a value of 'TriggerConfig' 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:
--
-- 'triggerProperties', 'triggerConfig_triggerProperties' - Specifies the configuration details of a schedule-triggered flow that
-- you define. Currently, these settings only apply to the Scheduled
-- trigger type.
--
-- 'triggerType', 'triggerConfig_triggerType' - Specifies the type of flow trigger. It can be OnDemand, Scheduled, or
-- Event.
newTriggerConfig ::
  -- | 'triggerType'
  TriggerType ->
  TriggerConfig
newTriggerConfig :: TriggerType -> TriggerConfig
newTriggerConfig TriggerType
pTriggerType_ =
  TriggerConfig' :: Maybe TriggerProperties -> TriggerType -> TriggerConfig
TriggerConfig'
    { $sel:triggerProperties:TriggerConfig' :: Maybe TriggerProperties
triggerProperties = Maybe TriggerProperties
forall a. Maybe a
Prelude.Nothing,
      $sel:triggerType:TriggerConfig' :: TriggerType
triggerType = TriggerType
pTriggerType_
    }

-- | Specifies the configuration details of a schedule-triggered flow that
-- you define. Currently, these settings only apply to the Scheduled
-- trigger type.
triggerConfig_triggerProperties :: Lens.Lens' TriggerConfig (Prelude.Maybe TriggerProperties)
triggerConfig_triggerProperties :: (Maybe TriggerProperties -> f (Maybe TriggerProperties))
-> TriggerConfig -> f TriggerConfig
triggerConfig_triggerProperties = (TriggerConfig -> Maybe TriggerProperties)
-> (TriggerConfig -> Maybe TriggerProperties -> TriggerConfig)
-> Lens
     TriggerConfig
     TriggerConfig
     (Maybe TriggerProperties)
     (Maybe TriggerProperties)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TriggerConfig' {Maybe TriggerProperties
triggerProperties :: Maybe TriggerProperties
$sel:triggerProperties:TriggerConfig' :: TriggerConfig -> Maybe TriggerProperties
triggerProperties} -> Maybe TriggerProperties
triggerProperties) (\s :: TriggerConfig
s@TriggerConfig' {} Maybe TriggerProperties
a -> TriggerConfig
s {$sel:triggerProperties:TriggerConfig' :: Maybe TriggerProperties
triggerProperties = Maybe TriggerProperties
a} :: TriggerConfig)

-- | Specifies the type of flow trigger. It can be OnDemand, Scheduled, or
-- Event.
triggerConfig_triggerType :: Lens.Lens' TriggerConfig TriggerType
triggerConfig_triggerType :: (TriggerType -> f TriggerType) -> TriggerConfig -> f TriggerConfig
triggerConfig_triggerType = (TriggerConfig -> TriggerType)
-> (TriggerConfig -> TriggerType -> TriggerConfig)
-> Lens TriggerConfig TriggerConfig TriggerType TriggerType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TriggerConfig' {TriggerType
triggerType :: TriggerType
$sel:triggerType:TriggerConfig' :: TriggerConfig -> TriggerType
triggerType} -> TriggerType
triggerType) (\s :: TriggerConfig
s@TriggerConfig' {} TriggerType
a -> TriggerConfig
s {$sel:triggerType:TriggerConfig' :: TriggerType
triggerType = TriggerType
a} :: TriggerConfig)

instance Prelude.Hashable TriggerConfig

instance Prelude.NFData TriggerConfig

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