{-# 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-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.Chime.Types.RoomRetentionSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(RoomRetentionSettings -> RoomRetentionSettings -> Bool)
-> (RoomRetentionSettings -> RoomRetentionSettings -> Bool)
-> Eq RoomRetentionSettings
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]
(Int -> ReadS RoomRetentionSettings)
-> ReadS [RoomRetentionSettings]
-> ReadPrec RoomRetentionSettings
-> ReadPrec [RoomRetentionSettings]
-> Read 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
(Int -> RoomRetentionSettings -> ShowS)
-> (RoomRetentionSettings -> String)
-> ([RoomRetentionSettings] -> ShowS)
-> Show RoomRetentionSettings
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. RoomRetentionSettings -> Rep RoomRetentionSettings x)
-> (forall x. Rep RoomRetentionSettings x -> RoomRetentionSettings)
-> Generic RoomRetentionSettings
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' :: Maybe Natural -> RoomRetentionSettings
RoomRetentionSettings'
    { $sel:retentionDays:RoomRetentionSettings' :: Maybe Natural
retentionDays =
        Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural))
-> RoomRetentionSettings -> f RoomRetentionSettings
roomRetentionSettings_retentionDays = (RoomRetentionSettings -> Maybe Natural)
-> (RoomRetentionSettings
    -> Maybe Natural -> RoomRetentionSettings)
-> Lens
     RoomRetentionSettings
     RoomRetentionSettings
     (Maybe Natural)
     (Maybe Natural)
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 Core.FromJSON RoomRetentionSettings where
  parseJSON :: Value -> Parser RoomRetentionSettings
parseJSON =
    String
-> (Object -> Parser RoomRetentionSettings)
-> Value
-> Parser RoomRetentionSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RoomRetentionSettings"
      ( \Object
x ->
          Maybe Natural -> RoomRetentionSettings
RoomRetentionSettings'
            (Maybe Natural -> RoomRetentionSettings)
-> Parser (Maybe Natural) -> Parser RoomRetentionSettings
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RetentionDays")
      )

instance Prelude.Hashable RoomRetentionSettings

instance Prelude.NFData RoomRetentionSettings

instance Core.ToJSON RoomRetentionSettings where
  toJSON :: RoomRetentionSettings -> Value
toJSON RoomRetentionSettings' {Maybe Natural
retentionDays :: Maybe Natural
$sel:retentionDays:RoomRetentionSettings' :: RoomRetentionSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RetentionDays" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
retentionDays
          ]
      )