{-# 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.AppSync.Types.DeltaSyncConfig
-- 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.AppSync.Types.DeltaSyncConfig where

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

-- | Describes a Delta Sync configuration.
--
-- /See:/ 'newDeltaSyncConfig' smart constructor.
data DeltaSyncConfig = DeltaSyncConfig'
  { -- | The number of minutes an Item is stored in the datasource.
    DeltaSyncConfig -> Maybe Integer
baseTableTTL :: Prelude.Maybe Prelude.Integer,
    -- | The Delta Sync table name.
    DeltaSyncConfig -> Maybe Text
deltaSyncTableName :: Prelude.Maybe Prelude.Text,
    -- | The number of minutes a Delta Sync log entry is stored in the Delta Sync
    -- table.
    DeltaSyncConfig -> Maybe Integer
deltaSyncTableTTL :: Prelude.Maybe Prelude.Integer
  }
  deriving (DeltaSyncConfig -> DeltaSyncConfig -> Bool
(DeltaSyncConfig -> DeltaSyncConfig -> Bool)
-> (DeltaSyncConfig -> DeltaSyncConfig -> Bool)
-> Eq DeltaSyncConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeltaSyncConfig -> DeltaSyncConfig -> Bool
$c/= :: DeltaSyncConfig -> DeltaSyncConfig -> Bool
== :: DeltaSyncConfig -> DeltaSyncConfig -> Bool
$c== :: DeltaSyncConfig -> DeltaSyncConfig -> Bool
Prelude.Eq, ReadPrec [DeltaSyncConfig]
ReadPrec DeltaSyncConfig
Int -> ReadS DeltaSyncConfig
ReadS [DeltaSyncConfig]
(Int -> ReadS DeltaSyncConfig)
-> ReadS [DeltaSyncConfig]
-> ReadPrec DeltaSyncConfig
-> ReadPrec [DeltaSyncConfig]
-> Read DeltaSyncConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeltaSyncConfig]
$creadListPrec :: ReadPrec [DeltaSyncConfig]
readPrec :: ReadPrec DeltaSyncConfig
$creadPrec :: ReadPrec DeltaSyncConfig
readList :: ReadS [DeltaSyncConfig]
$creadList :: ReadS [DeltaSyncConfig]
readsPrec :: Int -> ReadS DeltaSyncConfig
$creadsPrec :: Int -> ReadS DeltaSyncConfig
Prelude.Read, Int -> DeltaSyncConfig -> ShowS
[DeltaSyncConfig] -> ShowS
DeltaSyncConfig -> String
(Int -> DeltaSyncConfig -> ShowS)
-> (DeltaSyncConfig -> String)
-> ([DeltaSyncConfig] -> ShowS)
-> Show DeltaSyncConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeltaSyncConfig] -> ShowS
$cshowList :: [DeltaSyncConfig] -> ShowS
show :: DeltaSyncConfig -> String
$cshow :: DeltaSyncConfig -> String
showsPrec :: Int -> DeltaSyncConfig -> ShowS
$cshowsPrec :: Int -> DeltaSyncConfig -> ShowS
Prelude.Show, (forall x. DeltaSyncConfig -> Rep DeltaSyncConfig x)
-> (forall x. Rep DeltaSyncConfig x -> DeltaSyncConfig)
-> Generic DeltaSyncConfig
forall x. Rep DeltaSyncConfig x -> DeltaSyncConfig
forall x. DeltaSyncConfig -> Rep DeltaSyncConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeltaSyncConfig x -> DeltaSyncConfig
$cfrom :: forall x. DeltaSyncConfig -> Rep DeltaSyncConfig x
Prelude.Generic)

-- |
-- Create a value of 'DeltaSyncConfig' 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:
--
-- 'baseTableTTL', 'deltaSyncConfig_baseTableTTL' - The number of minutes an Item is stored in the datasource.
--
-- 'deltaSyncTableName', 'deltaSyncConfig_deltaSyncTableName' - The Delta Sync table name.
--
-- 'deltaSyncTableTTL', 'deltaSyncConfig_deltaSyncTableTTL' - The number of minutes a Delta Sync log entry is stored in the Delta Sync
-- table.
newDeltaSyncConfig ::
  DeltaSyncConfig
newDeltaSyncConfig :: DeltaSyncConfig
newDeltaSyncConfig =
  DeltaSyncConfig' :: Maybe Integer -> Maybe Text -> Maybe Integer -> DeltaSyncConfig
DeltaSyncConfig'
    { $sel:baseTableTTL:DeltaSyncConfig' :: Maybe Integer
baseTableTTL = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:deltaSyncTableName:DeltaSyncConfig' :: Maybe Text
deltaSyncTableName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deltaSyncTableTTL:DeltaSyncConfig' :: Maybe Integer
deltaSyncTableTTL = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of minutes an Item is stored in the datasource.
deltaSyncConfig_baseTableTTL :: Lens.Lens' DeltaSyncConfig (Prelude.Maybe Prelude.Integer)
deltaSyncConfig_baseTableTTL :: (Maybe Integer -> f (Maybe Integer))
-> DeltaSyncConfig -> f DeltaSyncConfig
deltaSyncConfig_baseTableTTL = (DeltaSyncConfig -> Maybe Integer)
-> (DeltaSyncConfig -> Maybe Integer -> DeltaSyncConfig)
-> Lens
     DeltaSyncConfig DeltaSyncConfig (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeltaSyncConfig' {Maybe Integer
baseTableTTL :: Maybe Integer
$sel:baseTableTTL:DeltaSyncConfig' :: DeltaSyncConfig -> Maybe Integer
baseTableTTL} -> Maybe Integer
baseTableTTL) (\s :: DeltaSyncConfig
s@DeltaSyncConfig' {} Maybe Integer
a -> DeltaSyncConfig
s {$sel:baseTableTTL:DeltaSyncConfig' :: Maybe Integer
baseTableTTL = Maybe Integer
a} :: DeltaSyncConfig)

-- | The Delta Sync table name.
deltaSyncConfig_deltaSyncTableName :: Lens.Lens' DeltaSyncConfig (Prelude.Maybe Prelude.Text)
deltaSyncConfig_deltaSyncTableName :: (Maybe Text -> f (Maybe Text))
-> DeltaSyncConfig -> f DeltaSyncConfig
deltaSyncConfig_deltaSyncTableName = (DeltaSyncConfig -> Maybe Text)
-> (DeltaSyncConfig -> Maybe Text -> DeltaSyncConfig)
-> Lens DeltaSyncConfig DeltaSyncConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeltaSyncConfig' {Maybe Text
deltaSyncTableName :: Maybe Text
$sel:deltaSyncTableName:DeltaSyncConfig' :: DeltaSyncConfig -> Maybe Text
deltaSyncTableName} -> Maybe Text
deltaSyncTableName) (\s :: DeltaSyncConfig
s@DeltaSyncConfig' {} Maybe Text
a -> DeltaSyncConfig
s {$sel:deltaSyncTableName:DeltaSyncConfig' :: Maybe Text
deltaSyncTableName = Maybe Text
a} :: DeltaSyncConfig)

-- | The number of minutes a Delta Sync log entry is stored in the Delta Sync
-- table.
deltaSyncConfig_deltaSyncTableTTL :: Lens.Lens' DeltaSyncConfig (Prelude.Maybe Prelude.Integer)
deltaSyncConfig_deltaSyncTableTTL :: (Maybe Integer -> f (Maybe Integer))
-> DeltaSyncConfig -> f DeltaSyncConfig
deltaSyncConfig_deltaSyncTableTTL = (DeltaSyncConfig -> Maybe Integer)
-> (DeltaSyncConfig -> Maybe Integer -> DeltaSyncConfig)
-> Lens
     DeltaSyncConfig DeltaSyncConfig (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeltaSyncConfig' {Maybe Integer
deltaSyncTableTTL :: Maybe Integer
$sel:deltaSyncTableTTL:DeltaSyncConfig' :: DeltaSyncConfig -> Maybe Integer
deltaSyncTableTTL} -> Maybe Integer
deltaSyncTableTTL) (\s :: DeltaSyncConfig
s@DeltaSyncConfig' {} Maybe Integer
a -> DeltaSyncConfig
s {$sel:deltaSyncTableTTL:DeltaSyncConfig' :: Maybe Integer
deltaSyncTableTTL = Maybe Integer
a} :: DeltaSyncConfig)

instance Core.FromJSON DeltaSyncConfig where
  parseJSON :: Value -> Parser DeltaSyncConfig
parseJSON =
    String
-> (Object -> Parser DeltaSyncConfig)
-> Value
-> Parser DeltaSyncConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeltaSyncConfig"
      ( \Object
x ->
          Maybe Integer -> Maybe Text -> Maybe Integer -> DeltaSyncConfig
DeltaSyncConfig'
            (Maybe Integer -> Maybe Text -> Maybe Integer -> DeltaSyncConfig)
-> Parser (Maybe Integer)
-> Parser (Maybe Text -> Maybe Integer -> DeltaSyncConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"baseTableTTL")
            Parser (Maybe Text -> Maybe Integer -> DeltaSyncConfig)
-> Parser (Maybe Text) -> Parser (Maybe Integer -> DeltaSyncConfig)
forall (f :: * -> *) a b. Applicative f => 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
"deltaSyncTableName")
            Parser (Maybe Integer -> DeltaSyncConfig)
-> Parser (Maybe Integer) -> Parser DeltaSyncConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"deltaSyncTableTTL")
      )

instance Prelude.Hashable DeltaSyncConfig

instance Prelude.NFData DeltaSyncConfig

instance Core.ToJSON DeltaSyncConfig where
  toJSON :: DeltaSyncConfig -> Value
toJSON DeltaSyncConfig' {Maybe Integer
Maybe Text
deltaSyncTableTTL :: Maybe Integer
deltaSyncTableName :: Maybe Text
baseTableTTL :: Maybe Integer
$sel:deltaSyncTableTTL:DeltaSyncConfig' :: DeltaSyncConfig -> Maybe Integer
$sel:deltaSyncTableName:DeltaSyncConfig' :: DeltaSyncConfig -> Maybe Text
$sel:baseTableTTL:DeltaSyncConfig' :: DeltaSyncConfig -> Maybe Integer
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"baseTableTTL" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
baseTableTTL,
            (Text
"deltaSyncTableName" 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
deltaSyncTableName,
            (Text
"deltaSyncTableTTL" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
deltaSyncTableTTL
          ]
      )