{-# 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.ChimeSDKIdentity.Types.ChannelRetentionSettings
-- 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.ChimeSDKIdentity.Types.ChannelRetentionSettings 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 details of the retention settings for a channel.
--
-- /See:/ 'newChannelRetentionSettings' smart constructor.
data ChannelRetentionSettings = ChannelRetentionSettings'
  { -- | The time in days to retain the messages in a channel.
    ChannelRetentionSettings -> Maybe Natural
retentionDays :: Prelude.Maybe Prelude.Natural
  }
  deriving (ChannelRetentionSettings -> ChannelRetentionSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelRetentionSettings -> ChannelRetentionSettings -> Bool
$c/= :: ChannelRetentionSettings -> ChannelRetentionSettings -> Bool
== :: ChannelRetentionSettings -> ChannelRetentionSettings -> Bool
$c== :: ChannelRetentionSettings -> ChannelRetentionSettings -> Bool
Prelude.Eq, ReadPrec [ChannelRetentionSettings]
ReadPrec ChannelRetentionSettings
Int -> ReadS ChannelRetentionSettings
ReadS [ChannelRetentionSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChannelRetentionSettings]
$creadListPrec :: ReadPrec [ChannelRetentionSettings]
readPrec :: ReadPrec ChannelRetentionSettings
$creadPrec :: ReadPrec ChannelRetentionSettings
readList :: ReadS [ChannelRetentionSettings]
$creadList :: ReadS [ChannelRetentionSettings]
readsPrec :: Int -> ReadS ChannelRetentionSettings
$creadsPrec :: Int -> ReadS ChannelRetentionSettings
Prelude.Read, Int -> ChannelRetentionSettings -> ShowS
[ChannelRetentionSettings] -> ShowS
ChannelRetentionSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelRetentionSettings] -> ShowS
$cshowList :: [ChannelRetentionSettings] -> ShowS
show :: ChannelRetentionSettings -> String
$cshow :: ChannelRetentionSettings -> String
showsPrec :: Int -> ChannelRetentionSettings -> ShowS
$cshowsPrec :: Int -> ChannelRetentionSettings -> ShowS
Prelude.Show, forall x.
Rep ChannelRetentionSettings x -> ChannelRetentionSettings
forall x.
ChannelRetentionSettings -> Rep ChannelRetentionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ChannelRetentionSettings x -> ChannelRetentionSettings
$cfrom :: forall x.
ChannelRetentionSettings -> Rep ChannelRetentionSettings x
Prelude.Generic)

-- |
-- Create a value of 'ChannelRetentionSettings' 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:
--
-- 'retentionDays', 'channelRetentionSettings_retentionDays' - The time in days to retain the messages in a channel.
newChannelRetentionSettings ::
  ChannelRetentionSettings
newChannelRetentionSettings :: ChannelRetentionSettings
newChannelRetentionSettings =
  ChannelRetentionSettings'
    { $sel:retentionDays:ChannelRetentionSettings' :: Maybe Natural
retentionDays =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The time in days to retain the messages in a channel.
channelRetentionSettings_retentionDays :: Lens.Lens' ChannelRetentionSettings (Prelude.Maybe Prelude.Natural)
channelRetentionSettings_retentionDays :: Lens' ChannelRetentionSettings (Maybe Natural)
channelRetentionSettings_retentionDays = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelRetentionSettings' {Maybe Natural
retentionDays :: Maybe Natural
$sel:retentionDays:ChannelRetentionSettings' :: ChannelRetentionSettings -> Maybe Natural
retentionDays} -> Maybe Natural
retentionDays) (\s :: ChannelRetentionSettings
s@ChannelRetentionSettings' {} Maybe Natural
a -> ChannelRetentionSettings
s {$sel:retentionDays:ChannelRetentionSettings' :: Maybe Natural
retentionDays = Maybe Natural
a} :: ChannelRetentionSettings)

instance Data.FromJSON ChannelRetentionSettings where
  parseJSON :: Value -> Parser ChannelRetentionSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ChannelRetentionSettings"
      ( \Object
x ->
          Maybe Natural -> ChannelRetentionSettings
ChannelRetentionSettings'
            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
"RetentionDays")
      )

instance Prelude.Hashable ChannelRetentionSettings where
  hashWithSalt :: Int -> ChannelRetentionSettings -> Int
hashWithSalt Int
_salt ChannelRetentionSettings' {Maybe Natural
retentionDays :: Maybe Natural
$sel:retentionDays:ChannelRetentionSettings' :: ChannelRetentionSettings -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
retentionDays

instance Prelude.NFData ChannelRetentionSettings where
  rnf :: ChannelRetentionSettings -> ()
rnf ChannelRetentionSettings' {Maybe Natural
retentionDays :: Maybe Natural
$sel:retentionDays:ChannelRetentionSettings' :: ChannelRetentionSettings -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
retentionDays

instance Data.ToJSON ChannelRetentionSettings where
  toJSON :: ChannelRetentionSettings -> Value
toJSON ChannelRetentionSettings' {Maybe Natural
retentionDays :: Maybe Natural
$sel:retentionDays:ChannelRetentionSettings' :: ChannelRetentionSettings -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RetentionDays" 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 Natural
retentionDays
          ]
      )