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

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

-- | Specifies the configuration used when importing incremental records from
-- the source.
--
-- /See:/ 'newIncrementalPullConfig' smart constructor.
data IncrementalPullConfig = IncrementalPullConfig'
  { -- | A field that specifies the date time or timestamp field as the criteria
    -- to use when importing incremental records from the source.
    IncrementalPullConfig -> Maybe Text
datetimeTypeFieldName :: Prelude.Maybe Prelude.Text
  }
  deriving (IncrementalPullConfig -> IncrementalPullConfig -> Bool
(IncrementalPullConfig -> IncrementalPullConfig -> Bool)
-> (IncrementalPullConfig -> IncrementalPullConfig -> Bool)
-> Eq IncrementalPullConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IncrementalPullConfig -> IncrementalPullConfig -> Bool
$c/= :: IncrementalPullConfig -> IncrementalPullConfig -> Bool
== :: IncrementalPullConfig -> IncrementalPullConfig -> Bool
$c== :: IncrementalPullConfig -> IncrementalPullConfig -> Bool
Prelude.Eq, ReadPrec [IncrementalPullConfig]
ReadPrec IncrementalPullConfig
Int -> ReadS IncrementalPullConfig
ReadS [IncrementalPullConfig]
(Int -> ReadS IncrementalPullConfig)
-> ReadS [IncrementalPullConfig]
-> ReadPrec IncrementalPullConfig
-> ReadPrec [IncrementalPullConfig]
-> Read IncrementalPullConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IncrementalPullConfig]
$creadListPrec :: ReadPrec [IncrementalPullConfig]
readPrec :: ReadPrec IncrementalPullConfig
$creadPrec :: ReadPrec IncrementalPullConfig
readList :: ReadS [IncrementalPullConfig]
$creadList :: ReadS [IncrementalPullConfig]
readsPrec :: Int -> ReadS IncrementalPullConfig
$creadsPrec :: Int -> ReadS IncrementalPullConfig
Prelude.Read, Int -> IncrementalPullConfig -> ShowS
[IncrementalPullConfig] -> ShowS
IncrementalPullConfig -> String
(Int -> IncrementalPullConfig -> ShowS)
-> (IncrementalPullConfig -> String)
-> ([IncrementalPullConfig] -> ShowS)
-> Show IncrementalPullConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IncrementalPullConfig] -> ShowS
$cshowList :: [IncrementalPullConfig] -> ShowS
show :: IncrementalPullConfig -> String
$cshow :: IncrementalPullConfig -> String
showsPrec :: Int -> IncrementalPullConfig -> ShowS
$cshowsPrec :: Int -> IncrementalPullConfig -> ShowS
Prelude.Show, (forall x. IncrementalPullConfig -> Rep IncrementalPullConfig x)
-> (forall x. Rep IncrementalPullConfig x -> IncrementalPullConfig)
-> Generic IncrementalPullConfig
forall x. Rep IncrementalPullConfig x -> IncrementalPullConfig
forall x. IncrementalPullConfig -> Rep IncrementalPullConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IncrementalPullConfig x -> IncrementalPullConfig
$cfrom :: forall x. IncrementalPullConfig -> Rep IncrementalPullConfig x
Prelude.Generic)

-- |
-- Create a value of 'IncrementalPullConfig' 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:
--
-- 'datetimeTypeFieldName', 'incrementalPullConfig_datetimeTypeFieldName' - A field that specifies the date time or timestamp field as the criteria
-- to use when importing incremental records from the source.
newIncrementalPullConfig ::
  IncrementalPullConfig
newIncrementalPullConfig :: IncrementalPullConfig
newIncrementalPullConfig =
  IncrementalPullConfig' :: Maybe Text -> IncrementalPullConfig
IncrementalPullConfig'
    { $sel:datetimeTypeFieldName:IncrementalPullConfig' :: Maybe Text
datetimeTypeFieldName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A field that specifies the date time or timestamp field as the criteria
-- to use when importing incremental records from the source.
incrementalPullConfig_datetimeTypeFieldName :: Lens.Lens' IncrementalPullConfig (Prelude.Maybe Prelude.Text)
incrementalPullConfig_datetimeTypeFieldName :: (Maybe Text -> f (Maybe Text))
-> IncrementalPullConfig -> f IncrementalPullConfig
incrementalPullConfig_datetimeTypeFieldName = (IncrementalPullConfig -> Maybe Text)
-> (IncrementalPullConfig -> Maybe Text -> IncrementalPullConfig)
-> Lens
     IncrementalPullConfig
     IncrementalPullConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncrementalPullConfig' {Maybe Text
datetimeTypeFieldName :: Maybe Text
$sel:datetimeTypeFieldName:IncrementalPullConfig' :: IncrementalPullConfig -> Maybe Text
datetimeTypeFieldName} -> Maybe Text
datetimeTypeFieldName) (\s :: IncrementalPullConfig
s@IncrementalPullConfig' {} Maybe Text
a -> IncrementalPullConfig
s {$sel:datetimeTypeFieldName:IncrementalPullConfig' :: Maybe Text
datetimeTypeFieldName = Maybe Text
a} :: IncrementalPullConfig)

instance Core.FromJSON IncrementalPullConfig where
  parseJSON :: Value -> Parser IncrementalPullConfig
parseJSON =
    String
-> (Object -> Parser IncrementalPullConfig)
-> Value
-> Parser IncrementalPullConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IncrementalPullConfig"
      ( \Object
x ->
          Maybe Text -> IncrementalPullConfig
IncrementalPullConfig'
            (Maybe Text -> IncrementalPullConfig)
-> Parser (Maybe Text) -> Parser IncrementalPullConfig
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
"datetimeTypeFieldName")
      )

instance Prelude.Hashable IncrementalPullConfig

instance Prelude.NFData IncrementalPullConfig

instance Core.ToJSON IncrementalPullConfig where
  toJSON :: IncrementalPullConfig -> Value
toJSON IncrementalPullConfig' {Maybe Text
datetimeTypeFieldName :: Maybe Text
$sel:datetimeTypeFieldName:IncrementalPullConfig' :: IncrementalPullConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"datetimeTypeFieldName" 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
datetimeTypeFieldName
          ]
      )