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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The properties that are applied when the custom connector is being used
-- as a source.
--
-- /See:/ 'newCustomConnectorSourceProperties' smart constructor.
data CustomConnectorSourceProperties = CustomConnectorSourceProperties'
  { -- | Custom properties that are required to use the custom connector as a
    -- source.
    CustomConnectorSourceProperties -> Maybe (HashMap Text Text)
customProperties :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The entity specified in the custom connector as a source in the flow.
    CustomConnectorSourceProperties -> Text
entityName :: Prelude.Text
  }
  deriving (CustomConnectorSourceProperties
-> CustomConnectorSourceProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomConnectorSourceProperties
-> CustomConnectorSourceProperties -> Bool
$c/= :: CustomConnectorSourceProperties
-> CustomConnectorSourceProperties -> Bool
== :: CustomConnectorSourceProperties
-> CustomConnectorSourceProperties -> Bool
$c== :: CustomConnectorSourceProperties
-> CustomConnectorSourceProperties -> Bool
Prelude.Eq, ReadPrec [CustomConnectorSourceProperties]
ReadPrec CustomConnectorSourceProperties
Int -> ReadS CustomConnectorSourceProperties
ReadS [CustomConnectorSourceProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomConnectorSourceProperties]
$creadListPrec :: ReadPrec [CustomConnectorSourceProperties]
readPrec :: ReadPrec CustomConnectorSourceProperties
$creadPrec :: ReadPrec CustomConnectorSourceProperties
readList :: ReadS [CustomConnectorSourceProperties]
$creadList :: ReadS [CustomConnectorSourceProperties]
readsPrec :: Int -> ReadS CustomConnectorSourceProperties
$creadsPrec :: Int -> ReadS CustomConnectorSourceProperties
Prelude.Read, Int -> CustomConnectorSourceProperties -> ShowS
[CustomConnectorSourceProperties] -> ShowS
CustomConnectorSourceProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomConnectorSourceProperties] -> ShowS
$cshowList :: [CustomConnectorSourceProperties] -> ShowS
show :: CustomConnectorSourceProperties -> String
$cshow :: CustomConnectorSourceProperties -> String
showsPrec :: Int -> CustomConnectorSourceProperties -> ShowS
$cshowsPrec :: Int -> CustomConnectorSourceProperties -> ShowS
Prelude.Show, forall x.
Rep CustomConnectorSourceProperties x
-> CustomConnectorSourceProperties
forall x.
CustomConnectorSourceProperties
-> Rep CustomConnectorSourceProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomConnectorSourceProperties x
-> CustomConnectorSourceProperties
$cfrom :: forall x.
CustomConnectorSourceProperties
-> Rep CustomConnectorSourceProperties x
Prelude.Generic)

-- |
-- Create a value of 'CustomConnectorSourceProperties' 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:
--
-- 'customProperties', 'customConnectorSourceProperties_customProperties' - Custom properties that are required to use the custom connector as a
-- source.
--
-- 'entityName', 'customConnectorSourceProperties_entityName' - The entity specified in the custom connector as a source in the flow.
newCustomConnectorSourceProperties ::
  -- | 'entityName'
  Prelude.Text ->
  CustomConnectorSourceProperties
newCustomConnectorSourceProperties :: Text -> CustomConnectorSourceProperties
newCustomConnectorSourceProperties Text
pEntityName_ =
  CustomConnectorSourceProperties'
    { $sel:customProperties:CustomConnectorSourceProperties' :: Maybe (HashMap Text Text)
customProperties =
        forall a. Maybe a
Prelude.Nothing,
      $sel:entityName:CustomConnectorSourceProperties' :: Text
entityName = Text
pEntityName_
    }

-- | Custom properties that are required to use the custom connector as a
-- source.
customConnectorSourceProperties_customProperties :: Lens.Lens' CustomConnectorSourceProperties (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
customConnectorSourceProperties_customProperties :: Lens' CustomConnectorSourceProperties (Maybe (HashMap Text Text))
customConnectorSourceProperties_customProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomConnectorSourceProperties' {Maybe (HashMap Text Text)
customProperties :: Maybe (HashMap Text Text)
$sel:customProperties:CustomConnectorSourceProperties' :: CustomConnectorSourceProperties -> Maybe (HashMap Text Text)
customProperties} -> Maybe (HashMap Text Text)
customProperties) (\s :: CustomConnectorSourceProperties
s@CustomConnectorSourceProperties' {} Maybe (HashMap Text Text)
a -> CustomConnectorSourceProperties
s {$sel:customProperties:CustomConnectorSourceProperties' :: Maybe (HashMap Text Text)
customProperties = Maybe (HashMap Text Text)
a} :: CustomConnectorSourceProperties) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The entity specified in the custom connector as a source in the flow.
customConnectorSourceProperties_entityName :: Lens.Lens' CustomConnectorSourceProperties Prelude.Text
customConnectorSourceProperties_entityName :: Lens' CustomConnectorSourceProperties Text
customConnectorSourceProperties_entityName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomConnectorSourceProperties' {Text
entityName :: Text
$sel:entityName:CustomConnectorSourceProperties' :: CustomConnectorSourceProperties -> Text
entityName} -> Text
entityName) (\s :: CustomConnectorSourceProperties
s@CustomConnectorSourceProperties' {} Text
a -> CustomConnectorSourceProperties
s {$sel:entityName:CustomConnectorSourceProperties' :: Text
entityName = Text
a} :: CustomConnectorSourceProperties)

instance
  Data.FromJSON
    CustomConnectorSourceProperties
  where
  parseJSON :: Value -> Parser CustomConnectorSourceProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomConnectorSourceProperties"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Text -> CustomConnectorSourceProperties
CustomConnectorSourceProperties'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"customProperties"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"entityName")
      )

instance
  Prelude.Hashable
    CustomConnectorSourceProperties
  where
  hashWithSalt :: Int -> CustomConnectorSourceProperties -> Int
hashWithSalt
    Int
_salt
    CustomConnectorSourceProperties' {Maybe (HashMap Text Text)
Text
entityName :: Text
customProperties :: Maybe (HashMap Text Text)
$sel:entityName:CustomConnectorSourceProperties' :: CustomConnectorSourceProperties -> Text
$sel:customProperties:CustomConnectorSourceProperties' :: CustomConnectorSourceProperties -> Maybe (HashMap Text Text)
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
customProperties
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entityName

instance
  Prelude.NFData
    CustomConnectorSourceProperties
  where
  rnf :: CustomConnectorSourceProperties -> ()
rnf CustomConnectorSourceProperties' {Maybe (HashMap Text Text)
Text
entityName :: Text
customProperties :: Maybe (HashMap Text Text)
$sel:entityName:CustomConnectorSourceProperties' :: CustomConnectorSourceProperties -> Text
$sel:customProperties:CustomConnectorSourceProperties' :: CustomConnectorSourceProperties -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
customProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
entityName

instance Data.ToJSON CustomConnectorSourceProperties where
  toJSON :: CustomConnectorSourceProperties -> Value
toJSON CustomConnectorSourceProperties' {Maybe (HashMap Text Text)
Text
entityName :: Text
customProperties :: Maybe (HashMap Text Text)
$sel:entityName:CustomConnectorSourceProperties' :: CustomConnectorSourceProperties -> Text
$sel:customProperties:CustomConnectorSourceProperties' :: CustomConnectorSourceProperties -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"customProperties" 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 (HashMap Text Text)
customProperties,
            forall a. a -> Maybe a
Prelude.Just (Key
"entityName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
entityName)
          ]
      )