{-# 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-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.ConversationRetentionSettings 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 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
(ConversationRetentionSettings
 -> ConversationRetentionSettings -> Bool)
-> (ConversationRetentionSettings
    -> ConversationRetentionSettings -> Bool)
-> Eq ConversationRetentionSettings
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]
(Int -> ReadS ConversationRetentionSettings)
-> ReadS [ConversationRetentionSettings]
-> ReadPrec ConversationRetentionSettings
-> ReadPrec [ConversationRetentionSettings]
-> Read 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
(Int -> ConversationRetentionSettings -> ShowS)
-> (ConversationRetentionSettings -> String)
-> ([ConversationRetentionSettings] -> ShowS)
-> Show ConversationRetentionSettings
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.
 ConversationRetentionSettings
 -> Rep ConversationRetentionSettings x)
-> (forall x.
    Rep ConversationRetentionSettings x
    -> ConversationRetentionSettings)
-> Generic ConversationRetentionSettings
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' :: Maybe Natural -> ConversationRetentionSettings
ConversationRetentionSettings'
    { $sel:retentionDays:ConversationRetentionSettings' :: Maybe Natural
retentionDays =
        Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural))
-> ConversationRetentionSettings -> f ConversationRetentionSettings
conversationRetentionSettings_retentionDays = (ConversationRetentionSettings -> Maybe Natural)
-> (ConversationRetentionSettings
    -> Maybe Natural -> ConversationRetentionSettings)
-> Lens
     ConversationRetentionSettings
     ConversationRetentionSettings
     (Maybe Natural)
     (Maybe Natural)
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 Core.FromJSON ConversationRetentionSettings where
  parseJSON :: Value -> Parser ConversationRetentionSettings
parseJSON =
    String
-> (Object -> Parser ConversationRetentionSettings)
-> Value
-> Parser ConversationRetentionSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConversationRetentionSettings"
      ( \Object
x ->
          Maybe Natural -> ConversationRetentionSettings
ConversationRetentionSettings'
            (Maybe Natural -> ConversationRetentionSettings)
-> Parser (Maybe Natural) -> Parser ConversationRetentionSettings
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
    ConversationRetentionSettings

instance Prelude.NFData ConversationRetentionSettings

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