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

-- |
-- Create a value of 'ConversationRetentionSettings' 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', 'conversationRetentionSettings_retentionDays' - The number of days for which to retain conversation messages.
newConversationRetentionSettings ::
  ConversationRetentionSettings
newConversationRetentionSettings :: ConversationRetentionSettings
newConversationRetentionSettings =
  ConversationRetentionSettings'
    { $sel:retentionDays:ConversationRetentionSettings' :: Maybe Natural
retentionDays =
        forall a. Maybe a
Prelude.Nothing
    }

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

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

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

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