{-# 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.KeySpaces.Types.TimeToLive
-- 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.KeySpaces.Types.TimeToLive where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KeySpaces.Types.TimeToLiveStatus
import qualified Amazonka.Prelude as Prelude

-- | Enable custom Time to Live (TTL) settings for rows and columns without
-- setting a TTL default for the specified table.
--
-- For more information, see
-- <https://docs.aws.amazon.com/keyspaces/latest/devguide/TTL-how-it-works.html#ttl-howitworks_enabling Enabling TTL on tables>
-- in the /Amazon Keyspaces Developer Guide/.
--
-- /See:/ 'newTimeToLive' smart constructor.
data TimeToLive = TimeToLive'
  { -- | Shows how to enable custom Time to Live (TTL) settings for the specified
    -- table.
    TimeToLive -> TimeToLiveStatus
status :: TimeToLiveStatus
  }
  deriving (TimeToLive -> TimeToLive -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeToLive -> TimeToLive -> Bool
$c/= :: TimeToLive -> TimeToLive -> Bool
== :: TimeToLive -> TimeToLive -> Bool
$c== :: TimeToLive -> TimeToLive -> Bool
Prelude.Eq, ReadPrec [TimeToLive]
ReadPrec TimeToLive
Int -> ReadS TimeToLive
ReadS [TimeToLive]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimeToLive]
$creadListPrec :: ReadPrec [TimeToLive]
readPrec :: ReadPrec TimeToLive
$creadPrec :: ReadPrec TimeToLive
readList :: ReadS [TimeToLive]
$creadList :: ReadS [TimeToLive]
readsPrec :: Int -> ReadS TimeToLive
$creadsPrec :: Int -> ReadS TimeToLive
Prelude.Read, Int -> TimeToLive -> ShowS
[TimeToLive] -> ShowS
TimeToLive -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeToLive] -> ShowS
$cshowList :: [TimeToLive] -> ShowS
show :: TimeToLive -> String
$cshow :: TimeToLive -> String
showsPrec :: Int -> TimeToLive -> ShowS
$cshowsPrec :: Int -> TimeToLive -> ShowS
Prelude.Show, forall x. Rep TimeToLive x -> TimeToLive
forall x. TimeToLive -> Rep TimeToLive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeToLive x -> TimeToLive
$cfrom :: forall x. TimeToLive -> Rep TimeToLive x
Prelude.Generic)

-- |
-- Create a value of 'TimeToLive' 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:
--
-- 'status', 'timeToLive_status' - Shows how to enable custom Time to Live (TTL) settings for the specified
-- table.
newTimeToLive ::
  -- | 'status'
  TimeToLiveStatus ->
  TimeToLive
newTimeToLive :: TimeToLiveStatus -> TimeToLive
newTimeToLive TimeToLiveStatus
pStatus_ =
  TimeToLive' {$sel:status:TimeToLive' :: TimeToLiveStatus
status = TimeToLiveStatus
pStatus_}

-- | Shows how to enable custom Time to Live (TTL) settings for the specified
-- table.
timeToLive_status :: Lens.Lens' TimeToLive TimeToLiveStatus
timeToLive_status :: Lens' TimeToLive TimeToLiveStatus
timeToLive_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeToLive' {TimeToLiveStatus
status :: TimeToLiveStatus
$sel:status:TimeToLive' :: TimeToLive -> TimeToLiveStatus
status} -> TimeToLiveStatus
status) (\s :: TimeToLive
s@TimeToLive' {} TimeToLiveStatus
a -> TimeToLive
s {$sel:status:TimeToLive' :: TimeToLiveStatus
status = TimeToLiveStatus
a} :: TimeToLive)

instance Data.FromJSON TimeToLive where
  parseJSON :: Value -> Parser TimeToLive
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TimeToLive"
      (\Object
x -> TimeToLiveStatus -> TimeToLive
TimeToLive' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"status"))

instance Prelude.Hashable TimeToLive where
  hashWithSalt :: Int -> TimeToLive -> Int
hashWithSalt Int
_salt TimeToLive' {TimeToLiveStatus
status :: TimeToLiveStatus
$sel:status:TimeToLive' :: TimeToLive -> TimeToLiveStatus
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TimeToLiveStatus
status

instance Prelude.NFData TimeToLive where
  rnf :: TimeToLive -> ()
rnf TimeToLive' {TimeToLiveStatus
status :: TimeToLiveStatus
$sel:status:TimeToLive' :: TimeToLive -> TimeToLiveStatus
..} = forall a. NFData a => a -> ()
Prelude.rnf TimeToLiveStatus
status

instance Data.ToJSON TimeToLive where
  toJSON :: TimeToLive -> Value
toJSON TimeToLive' {TimeToLiveStatus
status :: TimeToLiveStatus
$sel:status:TimeToLive' :: TimeToLive -> TimeToLiveStatus
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"status" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TimeToLiveStatus
status)]
      )