{-# 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.AppFlow.Types.TriggerProperties
-- 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.AppFlow.Types.TriggerProperties where

import Amazonka.AppFlow.Types.ScheduledTriggerProperties
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the configuration details that control the trigger for a flow.
-- Currently, these settings only apply to the @Scheduled@ trigger type.
--
-- /See:/ 'newTriggerProperties' smart constructor.
data TriggerProperties = TriggerProperties'
  { -- | Specifies the configuration details of a schedule-triggered flow as
    -- defined by the user.
    TriggerProperties -> Maybe ScheduledTriggerProperties
scheduled :: Prelude.Maybe ScheduledTriggerProperties
  }
  deriving (TriggerProperties -> TriggerProperties -> Bool
(TriggerProperties -> TriggerProperties -> Bool)
-> (TriggerProperties -> TriggerProperties -> Bool)
-> Eq TriggerProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TriggerProperties -> TriggerProperties -> Bool
$c/= :: TriggerProperties -> TriggerProperties -> Bool
== :: TriggerProperties -> TriggerProperties -> Bool
$c== :: TriggerProperties -> TriggerProperties -> Bool
Prelude.Eq, ReadPrec [TriggerProperties]
ReadPrec TriggerProperties
Int -> ReadS TriggerProperties
ReadS [TriggerProperties]
(Int -> ReadS TriggerProperties)
-> ReadS [TriggerProperties]
-> ReadPrec TriggerProperties
-> ReadPrec [TriggerProperties]
-> Read TriggerProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TriggerProperties]
$creadListPrec :: ReadPrec [TriggerProperties]
readPrec :: ReadPrec TriggerProperties
$creadPrec :: ReadPrec TriggerProperties
readList :: ReadS [TriggerProperties]
$creadList :: ReadS [TriggerProperties]
readsPrec :: Int -> ReadS TriggerProperties
$creadsPrec :: Int -> ReadS TriggerProperties
Prelude.Read, Int -> TriggerProperties -> ShowS
[TriggerProperties] -> ShowS
TriggerProperties -> String
(Int -> TriggerProperties -> ShowS)
-> (TriggerProperties -> String)
-> ([TriggerProperties] -> ShowS)
-> Show TriggerProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TriggerProperties] -> ShowS
$cshowList :: [TriggerProperties] -> ShowS
show :: TriggerProperties -> String
$cshow :: TriggerProperties -> String
showsPrec :: Int -> TriggerProperties -> ShowS
$cshowsPrec :: Int -> TriggerProperties -> ShowS
Prelude.Show, (forall x. TriggerProperties -> Rep TriggerProperties x)
-> (forall x. Rep TriggerProperties x -> TriggerProperties)
-> Generic TriggerProperties
forall x. Rep TriggerProperties x -> TriggerProperties
forall x. TriggerProperties -> Rep TriggerProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TriggerProperties x -> TriggerProperties
$cfrom :: forall x. TriggerProperties -> Rep TriggerProperties x
Prelude.Generic)

-- |
-- Create a value of 'TriggerProperties' 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:
--
-- 'scheduled', 'triggerProperties_scheduled' - Specifies the configuration details of a schedule-triggered flow as
-- defined by the user.
newTriggerProperties ::
  TriggerProperties
newTriggerProperties :: TriggerProperties
newTriggerProperties =
  TriggerProperties' :: Maybe ScheduledTriggerProperties -> TriggerProperties
TriggerProperties' {$sel:scheduled:TriggerProperties' :: Maybe ScheduledTriggerProperties
scheduled = Maybe ScheduledTriggerProperties
forall a. Maybe a
Prelude.Nothing}

-- | Specifies the configuration details of a schedule-triggered flow as
-- defined by the user.
triggerProperties_scheduled :: Lens.Lens' TriggerProperties (Prelude.Maybe ScheduledTriggerProperties)
triggerProperties_scheduled :: (Maybe ScheduledTriggerProperties
 -> f (Maybe ScheduledTriggerProperties))
-> TriggerProperties -> f TriggerProperties
triggerProperties_scheduled = (TriggerProperties -> Maybe ScheduledTriggerProperties)
-> (TriggerProperties
    -> Maybe ScheduledTriggerProperties -> TriggerProperties)
-> Lens
     TriggerProperties
     TriggerProperties
     (Maybe ScheduledTriggerProperties)
     (Maybe ScheduledTriggerProperties)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TriggerProperties' {Maybe ScheduledTriggerProperties
scheduled :: Maybe ScheduledTriggerProperties
$sel:scheduled:TriggerProperties' :: TriggerProperties -> Maybe ScheduledTriggerProperties
scheduled} -> Maybe ScheduledTriggerProperties
scheduled) (\s :: TriggerProperties
s@TriggerProperties' {} Maybe ScheduledTriggerProperties
a -> TriggerProperties
s {$sel:scheduled:TriggerProperties' :: Maybe ScheduledTriggerProperties
scheduled = Maybe ScheduledTriggerProperties
a} :: TriggerProperties)

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

instance Prelude.Hashable TriggerProperties

instance Prelude.NFData TriggerProperties

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