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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.CustomerProfiles.Types.SourceFlowConfig
import Amazonka.CustomerProfiles.Types.Task
import Amazonka.CustomerProfiles.Types.TriggerConfig
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The configurations that control how Customer Profiles retrieves data
-- from the source, Amazon AppFlow. Customer Profiles uses this information
-- to create an AppFlow flow on behalf of customers.
--
-- /See:/ 'newFlowDefinition' smart constructor.
data FlowDefinition = FlowDefinition'
  { -- | A description of the flow you want to create.
    FlowDefinition -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The specified name of the flow. Use underscores (_) or hyphens (-) only.
    -- Spaces are not allowed.
    FlowDefinition -> Text
flowName :: Prelude.Text,
    -- | The Amazon Resource Name of the AWS Key Management Service (KMS) key you
    -- provide for encryption.
    FlowDefinition -> Text
kmsArn :: Prelude.Text,
    -- | The configuration that controls how Customer Profiles retrieves data
    -- from the source.
    FlowDefinition -> SourceFlowConfig
sourceFlowConfig :: SourceFlowConfig,
    -- | A list of tasks that Customer Profiles performs while transferring the
    -- data in the flow run.
    FlowDefinition -> [Task]
tasks :: [Task],
    -- | The trigger settings that determine how and when the flow runs.
    FlowDefinition -> TriggerConfig
triggerConfig :: TriggerConfig
  }
  deriving (FlowDefinition -> FlowDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FlowDefinition -> FlowDefinition -> Bool
$c/= :: FlowDefinition -> FlowDefinition -> Bool
== :: FlowDefinition -> FlowDefinition -> Bool
$c== :: FlowDefinition -> FlowDefinition -> Bool
Prelude.Eq, ReadPrec [FlowDefinition]
ReadPrec FlowDefinition
Int -> ReadS FlowDefinition
ReadS [FlowDefinition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FlowDefinition]
$creadListPrec :: ReadPrec [FlowDefinition]
readPrec :: ReadPrec FlowDefinition
$creadPrec :: ReadPrec FlowDefinition
readList :: ReadS [FlowDefinition]
$creadList :: ReadS [FlowDefinition]
readsPrec :: Int -> ReadS FlowDefinition
$creadsPrec :: Int -> ReadS FlowDefinition
Prelude.Read, Int -> FlowDefinition -> ShowS
[FlowDefinition] -> ShowS
FlowDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FlowDefinition] -> ShowS
$cshowList :: [FlowDefinition] -> ShowS
show :: FlowDefinition -> String
$cshow :: FlowDefinition -> String
showsPrec :: Int -> FlowDefinition -> ShowS
$cshowsPrec :: Int -> FlowDefinition -> ShowS
Prelude.Show, forall x. Rep FlowDefinition x -> FlowDefinition
forall x. FlowDefinition -> Rep FlowDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FlowDefinition x -> FlowDefinition
$cfrom :: forall x. FlowDefinition -> Rep FlowDefinition x
Prelude.Generic)

-- |
-- Create a value of 'FlowDefinition' 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:
--
-- 'description', 'flowDefinition_description' - A description of the flow you want to create.
--
-- 'flowName', 'flowDefinition_flowName' - The specified name of the flow. Use underscores (_) or hyphens (-) only.
-- Spaces are not allowed.
--
-- 'kmsArn', 'flowDefinition_kmsArn' - The Amazon Resource Name of the AWS Key Management Service (KMS) key you
-- provide for encryption.
--
-- 'sourceFlowConfig', 'flowDefinition_sourceFlowConfig' - The configuration that controls how Customer Profiles retrieves data
-- from the source.
--
-- 'tasks', 'flowDefinition_tasks' - A list of tasks that Customer Profiles performs while transferring the
-- data in the flow run.
--
-- 'triggerConfig', 'flowDefinition_triggerConfig' - The trigger settings that determine how and when the flow runs.
newFlowDefinition ::
  -- | 'flowName'
  Prelude.Text ->
  -- | 'kmsArn'
  Prelude.Text ->
  -- | 'sourceFlowConfig'
  SourceFlowConfig ->
  -- | 'triggerConfig'
  TriggerConfig ->
  FlowDefinition
newFlowDefinition :: Text -> Text -> SourceFlowConfig -> TriggerConfig -> FlowDefinition
newFlowDefinition
  Text
pFlowName_
  Text
pKmsArn_
  SourceFlowConfig
pSourceFlowConfig_
  TriggerConfig
pTriggerConfig_ =
    FlowDefinition'
      { $sel:description:FlowDefinition' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
        $sel:flowName:FlowDefinition' :: Text
flowName = Text
pFlowName_,
        $sel:kmsArn:FlowDefinition' :: Text
kmsArn = Text
pKmsArn_,
        $sel:sourceFlowConfig:FlowDefinition' :: SourceFlowConfig
sourceFlowConfig = SourceFlowConfig
pSourceFlowConfig_,
        $sel:tasks:FlowDefinition' :: [Task]
tasks = forall a. Monoid a => a
Prelude.mempty,
        $sel:triggerConfig:FlowDefinition' :: TriggerConfig
triggerConfig = TriggerConfig
pTriggerConfig_
      }

-- | A description of the flow you want to create.
flowDefinition_description :: Lens.Lens' FlowDefinition (Prelude.Maybe Prelude.Text)
flowDefinition_description :: Lens' FlowDefinition (Maybe Text)
flowDefinition_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FlowDefinition' {Maybe Text
description :: Maybe Text
$sel:description:FlowDefinition' :: FlowDefinition -> Maybe Text
description} -> Maybe Text
description) (\s :: FlowDefinition
s@FlowDefinition' {} Maybe Text
a -> FlowDefinition
s {$sel:description:FlowDefinition' :: Maybe Text
description = Maybe Text
a} :: FlowDefinition)

-- | The specified name of the flow. Use underscores (_) or hyphens (-) only.
-- Spaces are not allowed.
flowDefinition_flowName :: Lens.Lens' FlowDefinition Prelude.Text
flowDefinition_flowName :: Lens' FlowDefinition Text
flowDefinition_flowName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FlowDefinition' {Text
flowName :: Text
$sel:flowName:FlowDefinition' :: FlowDefinition -> Text
flowName} -> Text
flowName) (\s :: FlowDefinition
s@FlowDefinition' {} Text
a -> FlowDefinition
s {$sel:flowName:FlowDefinition' :: Text
flowName = Text
a} :: FlowDefinition)

-- | The Amazon Resource Name of the AWS Key Management Service (KMS) key you
-- provide for encryption.
flowDefinition_kmsArn :: Lens.Lens' FlowDefinition Prelude.Text
flowDefinition_kmsArn :: Lens' FlowDefinition Text
flowDefinition_kmsArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FlowDefinition' {Text
kmsArn :: Text
$sel:kmsArn:FlowDefinition' :: FlowDefinition -> Text
kmsArn} -> Text
kmsArn) (\s :: FlowDefinition
s@FlowDefinition' {} Text
a -> FlowDefinition
s {$sel:kmsArn:FlowDefinition' :: Text
kmsArn = Text
a} :: FlowDefinition)

-- | The configuration that controls how Customer Profiles retrieves data
-- from the source.
flowDefinition_sourceFlowConfig :: Lens.Lens' FlowDefinition SourceFlowConfig
flowDefinition_sourceFlowConfig :: Lens' FlowDefinition SourceFlowConfig
flowDefinition_sourceFlowConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FlowDefinition' {SourceFlowConfig
sourceFlowConfig :: SourceFlowConfig
$sel:sourceFlowConfig:FlowDefinition' :: FlowDefinition -> SourceFlowConfig
sourceFlowConfig} -> SourceFlowConfig
sourceFlowConfig) (\s :: FlowDefinition
s@FlowDefinition' {} SourceFlowConfig
a -> FlowDefinition
s {$sel:sourceFlowConfig:FlowDefinition' :: SourceFlowConfig
sourceFlowConfig = SourceFlowConfig
a} :: FlowDefinition)

-- | A list of tasks that Customer Profiles performs while transferring the
-- data in the flow run.
flowDefinition_tasks :: Lens.Lens' FlowDefinition [Task]
flowDefinition_tasks :: Lens' FlowDefinition [Task]
flowDefinition_tasks = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FlowDefinition' {[Task]
tasks :: [Task]
$sel:tasks:FlowDefinition' :: FlowDefinition -> [Task]
tasks} -> [Task]
tasks) (\s :: FlowDefinition
s@FlowDefinition' {} [Task]
a -> FlowDefinition
s {$sel:tasks:FlowDefinition' :: [Task]
tasks = [Task]
a} :: FlowDefinition) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The trigger settings that determine how and when the flow runs.
flowDefinition_triggerConfig :: Lens.Lens' FlowDefinition TriggerConfig
flowDefinition_triggerConfig :: Lens' FlowDefinition TriggerConfig
flowDefinition_triggerConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FlowDefinition' {TriggerConfig
triggerConfig :: TriggerConfig
$sel:triggerConfig:FlowDefinition' :: FlowDefinition -> TriggerConfig
triggerConfig} -> TriggerConfig
triggerConfig) (\s :: FlowDefinition
s@FlowDefinition' {} TriggerConfig
a -> FlowDefinition
s {$sel:triggerConfig:FlowDefinition' :: TriggerConfig
triggerConfig = TriggerConfig
a} :: FlowDefinition)

instance Prelude.Hashable FlowDefinition where
  hashWithSalt :: Int -> FlowDefinition -> Int
hashWithSalt Int
_salt FlowDefinition' {[Task]
Maybe Text
Text
TriggerConfig
SourceFlowConfig
triggerConfig :: TriggerConfig
tasks :: [Task]
sourceFlowConfig :: SourceFlowConfig
kmsArn :: Text
flowName :: Text
description :: Maybe Text
$sel:triggerConfig:FlowDefinition' :: FlowDefinition -> TriggerConfig
$sel:tasks:FlowDefinition' :: FlowDefinition -> [Task]
$sel:sourceFlowConfig:FlowDefinition' :: FlowDefinition -> SourceFlowConfig
$sel:kmsArn:FlowDefinition' :: FlowDefinition -> Text
$sel:flowName:FlowDefinition' :: FlowDefinition -> Text
$sel:description:FlowDefinition' :: FlowDefinition -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
flowName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
kmsArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SourceFlowConfig
sourceFlowConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Task]
tasks
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TriggerConfig
triggerConfig

instance Prelude.NFData FlowDefinition where
  rnf :: FlowDefinition -> ()
rnf FlowDefinition' {[Task]
Maybe Text
Text
TriggerConfig
SourceFlowConfig
triggerConfig :: TriggerConfig
tasks :: [Task]
sourceFlowConfig :: SourceFlowConfig
kmsArn :: Text
flowName :: Text
description :: Maybe Text
$sel:triggerConfig:FlowDefinition' :: FlowDefinition -> TriggerConfig
$sel:tasks:FlowDefinition' :: FlowDefinition -> [Task]
$sel:sourceFlowConfig:FlowDefinition' :: FlowDefinition -> SourceFlowConfig
$sel:kmsArn:FlowDefinition' :: FlowDefinition -> Text
$sel:flowName:FlowDefinition' :: FlowDefinition -> Text
$sel:description:FlowDefinition' :: FlowDefinition -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
flowName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
kmsArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SourceFlowConfig
sourceFlowConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Task]
tasks
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TriggerConfig
triggerConfig

instance Data.ToJSON FlowDefinition where
  toJSON :: FlowDefinition -> Value
toJSON FlowDefinition' {[Task]
Maybe Text
Text
TriggerConfig
SourceFlowConfig
triggerConfig :: TriggerConfig
tasks :: [Task]
sourceFlowConfig :: SourceFlowConfig
kmsArn :: Text
flowName :: Text
description :: Maybe Text
$sel:triggerConfig:FlowDefinition' :: FlowDefinition -> TriggerConfig
$sel:tasks:FlowDefinition' :: FlowDefinition -> [Task]
$sel:sourceFlowConfig:FlowDefinition' :: FlowDefinition -> SourceFlowConfig
$sel:kmsArn:FlowDefinition' :: FlowDefinition -> Text
$sel:flowName:FlowDefinition' :: FlowDefinition -> Text
$sel:description:FlowDefinition' :: FlowDefinition -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" 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 Text
description,
            forall a. a -> Maybe a
Prelude.Just (Key
"FlowName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
flowName),
            forall a. a -> Maybe a
Prelude.Just (Key
"KmsArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
kmsArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"SourceFlowConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SourceFlowConfig
sourceFlowConfig),
            forall a. a -> Maybe a
Prelude.Just (Key
"Tasks" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Task]
tasks),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"TriggerConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TriggerConfig
triggerConfig)
          ]
      )