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

import Amazonka.AppFlow.Types.ConnectorType
import Amazonka.AppFlow.Types.DestinationConnectorProperties
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the configuration of destination connectors
-- present in the flow.
--
-- /See:/ 'newDestinationFlowConfig' smart constructor.
data DestinationFlowConfig = DestinationFlowConfig'
  { -- | The name of the connector profile. This name must be unique for each
    -- connector profile in the Amazon Web Services account.
    DestinationFlowConfig -> Maybe Text
connectorProfileName :: Prelude.Maybe Prelude.Text,
    -- | The type of connector, such as Salesforce, Amplitude, and so on.
    DestinationFlowConfig -> ConnectorType
connectorType :: ConnectorType,
    -- | This stores the information that is required to query a particular
    -- connector.
    DestinationFlowConfig -> DestinationConnectorProperties
destinationConnectorProperties :: DestinationConnectorProperties
  }
  deriving (DestinationFlowConfig -> DestinationFlowConfig -> Bool
(DestinationFlowConfig -> DestinationFlowConfig -> Bool)
-> (DestinationFlowConfig -> DestinationFlowConfig -> Bool)
-> Eq DestinationFlowConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DestinationFlowConfig -> DestinationFlowConfig -> Bool
$c/= :: DestinationFlowConfig -> DestinationFlowConfig -> Bool
== :: DestinationFlowConfig -> DestinationFlowConfig -> Bool
$c== :: DestinationFlowConfig -> DestinationFlowConfig -> Bool
Prelude.Eq, ReadPrec [DestinationFlowConfig]
ReadPrec DestinationFlowConfig
Int -> ReadS DestinationFlowConfig
ReadS [DestinationFlowConfig]
(Int -> ReadS DestinationFlowConfig)
-> ReadS [DestinationFlowConfig]
-> ReadPrec DestinationFlowConfig
-> ReadPrec [DestinationFlowConfig]
-> Read DestinationFlowConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DestinationFlowConfig]
$creadListPrec :: ReadPrec [DestinationFlowConfig]
readPrec :: ReadPrec DestinationFlowConfig
$creadPrec :: ReadPrec DestinationFlowConfig
readList :: ReadS [DestinationFlowConfig]
$creadList :: ReadS [DestinationFlowConfig]
readsPrec :: Int -> ReadS DestinationFlowConfig
$creadsPrec :: Int -> ReadS DestinationFlowConfig
Prelude.Read, Int -> DestinationFlowConfig -> ShowS
[DestinationFlowConfig] -> ShowS
DestinationFlowConfig -> String
(Int -> DestinationFlowConfig -> ShowS)
-> (DestinationFlowConfig -> String)
-> ([DestinationFlowConfig] -> ShowS)
-> Show DestinationFlowConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DestinationFlowConfig] -> ShowS
$cshowList :: [DestinationFlowConfig] -> ShowS
show :: DestinationFlowConfig -> String
$cshow :: DestinationFlowConfig -> String
showsPrec :: Int -> DestinationFlowConfig -> ShowS
$cshowsPrec :: Int -> DestinationFlowConfig -> ShowS
Prelude.Show, (forall x. DestinationFlowConfig -> Rep DestinationFlowConfig x)
-> (forall x. Rep DestinationFlowConfig x -> DestinationFlowConfig)
-> Generic DestinationFlowConfig
forall x. Rep DestinationFlowConfig x -> DestinationFlowConfig
forall x. DestinationFlowConfig -> Rep DestinationFlowConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DestinationFlowConfig x -> DestinationFlowConfig
$cfrom :: forall x. DestinationFlowConfig -> Rep DestinationFlowConfig x
Prelude.Generic)

-- |
-- Create a value of 'DestinationFlowConfig' 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:
--
-- 'connectorProfileName', 'destinationFlowConfig_connectorProfileName' - The name of the connector profile. This name must be unique for each
-- connector profile in the Amazon Web Services account.
--
-- 'connectorType', 'destinationFlowConfig_connectorType' - The type of connector, such as Salesforce, Amplitude, and so on.
--
-- 'destinationConnectorProperties', 'destinationFlowConfig_destinationConnectorProperties' - This stores the information that is required to query a particular
-- connector.
newDestinationFlowConfig ::
  -- | 'connectorType'
  ConnectorType ->
  -- | 'destinationConnectorProperties'
  DestinationConnectorProperties ->
  DestinationFlowConfig
newDestinationFlowConfig :: ConnectorType
-> DestinationConnectorProperties -> DestinationFlowConfig
newDestinationFlowConfig
  ConnectorType
pConnectorType_
  DestinationConnectorProperties
pDestinationConnectorProperties_ =
    DestinationFlowConfig' :: Maybe Text
-> ConnectorType
-> DestinationConnectorProperties
-> DestinationFlowConfig
DestinationFlowConfig'
      { $sel:connectorProfileName:DestinationFlowConfig' :: Maybe Text
connectorProfileName =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:connectorType:DestinationFlowConfig' :: ConnectorType
connectorType = ConnectorType
pConnectorType_,
        $sel:destinationConnectorProperties:DestinationFlowConfig' :: DestinationConnectorProperties
destinationConnectorProperties =
          DestinationConnectorProperties
pDestinationConnectorProperties_
      }

-- | The name of the connector profile. This name must be unique for each
-- connector profile in the Amazon Web Services account.
destinationFlowConfig_connectorProfileName :: Lens.Lens' DestinationFlowConfig (Prelude.Maybe Prelude.Text)
destinationFlowConfig_connectorProfileName :: (Maybe Text -> f (Maybe Text))
-> DestinationFlowConfig -> f DestinationFlowConfig
destinationFlowConfig_connectorProfileName = (DestinationFlowConfig -> Maybe Text)
-> (DestinationFlowConfig -> Maybe Text -> DestinationFlowConfig)
-> Lens
     DestinationFlowConfig
     DestinationFlowConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationFlowConfig' {Maybe Text
connectorProfileName :: Maybe Text
$sel:connectorProfileName:DestinationFlowConfig' :: DestinationFlowConfig -> Maybe Text
connectorProfileName} -> Maybe Text
connectorProfileName) (\s :: DestinationFlowConfig
s@DestinationFlowConfig' {} Maybe Text
a -> DestinationFlowConfig
s {$sel:connectorProfileName:DestinationFlowConfig' :: Maybe Text
connectorProfileName = Maybe Text
a} :: DestinationFlowConfig)

-- | The type of connector, such as Salesforce, Amplitude, and so on.
destinationFlowConfig_connectorType :: Lens.Lens' DestinationFlowConfig ConnectorType
destinationFlowConfig_connectorType :: (ConnectorType -> f ConnectorType)
-> DestinationFlowConfig -> f DestinationFlowConfig
destinationFlowConfig_connectorType = (DestinationFlowConfig -> ConnectorType)
-> (DestinationFlowConfig
    -> ConnectorType -> DestinationFlowConfig)
-> Lens
     DestinationFlowConfig
     DestinationFlowConfig
     ConnectorType
     ConnectorType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationFlowConfig' {ConnectorType
connectorType :: ConnectorType
$sel:connectorType:DestinationFlowConfig' :: DestinationFlowConfig -> ConnectorType
connectorType} -> ConnectorType
connectorType) (\s :: DestinationFlowConfig
s@DestinationFlowConfig' {} ConnectorType
a -> DestinationFlowConfig
s {$sel:connectorType:DestinationFlowConfig' :: ConnectorType
connectorType = ConnectorType
a} :: DestinationFlowConfig)

-- | This stores the information that is required to query a particular
-- connector.
destinationFlowConfig_destinationConnectorProperties :: Lens.Lens' DestinationFlowConfig DestinationConnectorProperties
destinationFlowConfig_destinationConnectorProperties :: (DestinationConnectorProperties
 -> f DestinationConnectorProperties)
-> DestinationFlowConfig -> f DestinationFlowConfig
destinationFlowConfig_destinationConnectorProperties = (DestinationFlowConfig -> DestinationConnectorProperties)
-> (DestinationFlowConfig
    -> DestinationConnectorProperties -> DestinationFlowConfig)
-> Lens
     DestinationFlowConfig
     DestinationFlowConfig
     DestinationConnectorProperties
     DestinationConnectorProperties
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationFlowConfig' {DestinationConnectorProperties
destinationConnectorProperties :: DestinationConnectorProperties
$sel:destinationConnectorProperties:DestinationFlowConfig' :: DestinationFlowConfig -> DestinationConnectorProperties
destinationConnectorProperties} -> DestinationConnectorProperties
destinationConnectorProperties) (\s :: DestinationFlowConfig
s@DestinationFlowConfig' {} DestinationConnectorProperties
a -> DestinationFlowConfig
s {$sel:destinationConnectorProperties:DestinationFlowConfig' :: DestinationConnectorProperties
destinationConnectorProperties = DestinationConnectorProperties
a} :: DestinationFlowConfig)

instance Core.FromJSON DestinationFlowConfig where
  parseJSON :: Value -> Parser DestinationFlowConfig
parseJSON =
    String
-> (Object -> Parser DestinationFlowConfig)
-> Value
-> Parser DestinationFlowConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DestinationFlowConfig"
      ( \Object
x ->
          Maybe Text
-> ConnectorType
-> DestinationConnectorProperties
-> DestinationFlowConfig
DestinationFlowConfig'
            (Maybe Text
 -> ConnectorType
 -> DestinationConnectorProperties
 -> DestinationFlowConfig)
-> Parser (Maybe Text)
-> Parser
     (ConnectorType
      -> DestinationConnectorProperties -> DestinationFlowConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"connectorProfileName")
            Parser
  (ConnectorType
   -> DestinationConnectorProperties -> DestinationFlowConfig)
-> Parser ConnectorType
-> Parser (DestinationConnectorProperties -> DestinationFlowConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ConnectorType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"connectorType")
            Parser (DestinationConnectorProperties -> DestinationFlowConfig)
-> Parser DestinationConnectorProperties
-> Parser DestinationFlowConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser DestinationConnectorProperties
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"destinationConnectorProperties")
      )

instance Prelude.Hashable DestinationFlowConfig

instance Prelude.NFData DestinationFlowConfig

instance Core.ToJSON DestinationFlowConfig where
  toJSON :: DestinationFlowConfig -> Value
toJSON DestinationFlowConfig' {Maybe Text
ConnectorType
DestinationConnectorProperties
destinationConnectorProperties :: DestinationConnectorProperties
connectorType :: ConnectorType
connectorProfileName :: Maybe Text
$sel:destinationConnectorProperties:DestinationFlowConfig' :: DestinationFlowConfig -> DestinationConnectorProperties
$sel:connectorType:DestinationFlowConfig' :: DestinationFlowConfig -> ConnectorType
$sel:connectorProfileName:DestinationFlowConfig' :: DestinationFlowConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"connectorProfileName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
connectorProfileName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"connectorType" Text -> ConnectorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConnectorType
connectorType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"destinationConnectorProperties"
                  Text -> DestinationConnectorProperties -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DestinationConnectorProperties
destinationConnectorProperties
              )
          ]
      )