{-# 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.Chime.Types.RoomRetentionSettings
-- 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.Chime.Types.RoomRetentionSettings 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 retention settings that determine how long to retain chat-room
-- messages for an Amazon Chime Enterprise account.
--
-- /See:/ 'newRoomRetentionSettings' smart constructor.
data RoomRetentionSettings = RoomRetentionSettings'
  { -- | The number of days for which to retain chat-room messages.
    RoomRetentionSettings -> Maybe Natural
retentionDays :: Prelude.Maybe Prelude.Natural
  }
  deriving (RoomRetentionSettings -> RoomRetentionSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RoomRetentionSettings -> RoomRetentionSettings -> Bool
$c/= :: RoomRetentionSettings -> RoomRetentionSettings -> Bool
== :: RoomRetentionSettings -> RoomRetentionSettings -> Bool
$c== :: RoomRetentionSettings -> RoomRetentionSettings -> Bool
Prelude.Eq, ReadPrec [RoomRetentionSettings]
ReadPrec RoomRetentionSettings
Int -> ReadS RoomRetentionSettings
ReadS [RoomRetentionSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RoomRetentionSettings]
$creadListPrec :: ReadPrec [RoomRetentionSettings]
readPrec :: ReadPrec RoomRetentionSettings
$creadPrec :: ReadPrec RoomRetentionSettings
readList :: ReadS [RoomRetentionSettings]
$creadList :: ReadS [RoomRetentionSettings]
readsPrec :: Int -> ReadS RoomRetentionSettings
$creadsPrec :: Int -> ReadS RoomRetentionSettings
Prelude.Read, Int -> RoomRetentionSettings -> ShowS
[RoomRetentionSettings] -> ShowS
RoomRetentionSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RoomRetentionSettings] -> ShowS
$cshowList :: [RoomRetentionSettings] -> ShowS
show :: RoomRetentionSettings -> String
$cshow :: RoomRetentionSettings -> String
showsPrec :: Int -> RoomRetentionSettings -> ShowS
$cshowsPrec :: Int -> RoomRetentionSettings -> ShowS
Prelude.Show, forall x. Rep RoomRetentionSettings x -> RoomRetentionSettings
forall x. RoomRetentionSettings -> Rep RoomRetentionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RoomRetentionSettings x -> RoomRetentionSettings
$cfrom :: forall x. RoomRetentionSettings -> Rep RoomRetentionSettings x
Prelude.Generic)

-- |
-- Create a value of 'RoomRetentionSettings' 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', 'roomRetentionSettings_retentionDays' - The number of days for which to retain chat-room messages.
newRoomRetentionSettings ::
  RoomRetentionSettings
newRoomRetentionSettings :: RoomRetentionSettings
newRoomRetentionSettings =
  RoomRetentionSettings'
    { $sel:retentionDays:RoomRetentionSettings' :: Maybe Natural
retentionDays =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The number of days for which to retain chat-room messages.
roomRetentionSettings_retentionDays :: Lens.Lens' RoomRetentionSettings (Prelude.Maybe Prelude.Natural)
roomRetentionSettings_retentionDays :: Lens' RoomRetentionSettings (Maybe Natural)
roomRetentionSettings_retentionDays = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoomRetentionSettings' {Maybe Natural
retentionDays :: Maybe Natural
$sel:retentionDays:RoomRetentionSettings' :: RoomRetentionSettings -> Maybe Natural
retentionDays} -> Maybe Natural
retentionDays) (\s :: RoomRetentionSettings
s@RoomRetentionSettings' {} Maybe Natural
a -> RoomRetentionSettings
s {$sel:retentionDays:RoomRetentionSettings' :: Maybe Natural
retentionDays = Maybe Natural
a} :: RoomRetentionSettings)

instance Data.FromJSON RoomRetentionSettings where
  parseJSON :: Value -> Parser RoomRetentionSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RoomRetentionSettings"
      ( \Object
x ->
          Maybe Natural -> RoomRetentionSettings
RoomRetentionSettings'
            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 RoomRetentionSettings where
  hashWithSalt :: Int -> RoomRetentionSettings -> Int
hashWithSalt Int
_salt RoomRetentionSettings' {Maybe Natural
retentionDays :: Maybe Natural
$sel:retentionDays:RoomRetentionSettings' :: RoomRetentionSettings -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
retentionDays

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

instance Data.ToJSON RoomRetentionSettings where
  toJSON :: RoomRetentionSettings -> Value
toJSON RoomRetentionSettings' {Maybe Natural
retentionDays :: Maybe Natural
$sel:retentionDays:RoomRetentionSettings' :: RoomRetentionSettings -> 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
          ]
      )