{-# 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.RetentionSettings
-- 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.RetentionSettings where

import Amazonka.Chime.Types.ConversationRetentionSettings
import Amazonka.Chime.Types.RoomRetentionSettings
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The retention settings for an Amazon Chime Enterprise account that
-- determine how long to retain items such as chat-room messages and
-- chat-conversation messages.
--
-- /See:/ 'newRetentionSettings' smart constructor.
data RetentionSettings = RetentionSettings'
  { -- | The chat room retention settings.
    RetentionSettings -> Maybe RoomRetentionSettings
roomRetentionSettings :: Prelude.Maybe RoomRetentionSettings,
    -- | The chat conversation retention settings.
    RetentionSettings -> Maybe ConversationRetentionSettings
conversationRetentionSettings :: Prelude.Maybe ConversationRetentionSettings
  }
  deriving (RetentionSettings -> RetentionSettings -> Bool
(RetentionSettings -> RetentionSettings -> Bool)
-> (RetentionSettings -> RetentionSettings -> Bool)
-> Eq RetentionSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetentionSettings -> RetentionSettings -> Bool
$c/= :: RetentionSettings -> RetentionSettings -> Bool
== :: RetentionSettings -> RetentionSettings -> Bool
$c== :: RetentionSettings -> RetentionSettings -> Bool
Prelude.Eq, ReadPrec [RetentionSettings]
ReadPrec RetentionSettings
Int -> ReadS RetentionSettings
ReadS [RetentionSettings]
(Int -> ReadS RetentionSettings)
-> ReadS [RetentionSettings]
-> ReadPrec RetentionSettings
-> ReadPrec [RetentionSettings]
-> Read RetentionSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetentionSettings]
$creadListPrec :: ReadPrec [RetentionSettings]
readPrec :: ReadPrec RetentionSettings
$creadPrec :: ReadPrec RetentionSettings
readList :: ReadS [RetentionSettings]
$creadList :: ReadS [RetentionSettings]
readsPrec :: Int -> ReadS RetentionSettings
$creadsPrec :: Int -> ReadS RetentionSettings
Prelude.Read, Int -> RetentionSettings -> ShowS
[RetentionSettings] -> ShowS
RetentionSettings -> String
(Int -> RetentionSettings -> ShowS)
-> (RetentionSettings -> String)
-> ([RetentionSettings] -> ShowS)
-> Show RetentionSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetentionSettings] -> ShowS
$cshowList :: [RetentionSettings] -> ShowS
show :: RetentionSettings -> String
$cshow :: RetentionSettings -> String
showsPrec :: Int -> RetentionSettings -> ShowS
$cshowsPrec :: Int -> RetentionSettings -> ShowS
Prelude.Show, (forall x. RetentionSettings -> Rep RetentionSettings x)
-> (forall x. Rep RetentionSettings x -> RetentionSettings)
-> Generic RetentionSettings
forall x. Rep RetentionSettings x -> RetentionSettings
forall x. RetentionSettings -> Rep RetentionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetentionSettings x -> RetentionSettings
$cfrom :: forall x. RetentionSettings -> Rep RetentionSettings x
Prelude.Generic)

-- |
-- Create a value of 'RetentionSettings' 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:
--
-- 'roomRetentionSettings', 'retentionSettings_roomRetentionSettings' - The chat room retention settings.
--
-- 'conversationRetentionSettings', 'retentionSettings_conversationRetentionSettings' - The chat conversation retention settings.
newRetentionSettings ::
  RetentionSettings
newRetentionSettings :: RetentionSettings
newRetentionSettings =
  RetentionSettings' :: Maybe RoomRetentionSettings
-> Maybe ConversationRetentionSettings -> RetentionSettings
RetentionSettings'
    { $sel:roomRetentionSettings:RetentionSettings' :: Maybe RoomRetentionSettings
roomRetentionSettings =
        Maybe RoomRetentionSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:conversationRetentionSettings:RetentionSettings' :: Maybe ConversationRetentionSettings
conversationRetentionSettings = Maybe ConversationRetentionSettings
forall a. Maybe a
Prelude.Nothing
    }

-- | The chat room retention settings.
retentionSettings_roomRetentionSettings :: Lens.Lens' RetentionSettings (Prelude.Maybe RoomRetentionSettings)
retentionSettings_roomRetentionSettings :: (Maybe RoomRetentionSettings -> f (Maybe RoomRetentionSettings))
-> RetentionSettings -> f RetentionSettings
retentionSettings_roomRetentionSettings = (RetentionSettings -> Maybe RoomRetentionSettings)
-> (RetentionSettings
    -> Maybe RoomRetentionSettings -> RetentionSettings)
-> Lens
     RetentionSettings
     RetentionSettings
     (Maybe RoomRetentionSettings)
     (Maybe RoomRetentionSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetentionSettings' {Maybe RoomRetentionSettings
roomRetentionSettings :: Maybe RoomRetentionSettings
$sel:roomRetentionSettings:RetentionSettings' :: RetentionSettings -> Maybe RoomRetentionSettings
roomRetentionSettings} -> Maybe RoomRetentionSettings
roomRetentionSettings) (\s :: RetentionSettings
s@RetentionSettings' {} Maybe RoomRetentionSettings
a -> RetentionSettings
s {$sel:roomRetentionSettings:RetentionSettings' :: Maybe RoomRetentionSettings
roomRetentionSettings = Maybe RoomRetentionSettings
a} :: RetentionSettings)

-- | The chat conversation retention settings.
retentionSettings_conversationRetentionSettings :: Lens.Lens' RetentionSettings (Prelude.Maybe ConversationRetentionSettings)
retentionSettings_conversationRetentionSettings :: (Maybe ConversationRetentionSettings
 -> f (Maybe ConversationRetentionSettings))
-> RetentionSettings -> f RetentionSettings
retentionSettings_conversationRetentionSettings = (RetentionSettings -> Maybe ConversationRetentionSettings)
-> (RetentionSettings
    -> Maybe ConversationRetentionSettings -> RetentionSettings)
-> Lens
     RetentionSettings
     RetentionSettings
     (Maybe ConversationRetentionSettings)
     (Maybe ConversationRetentionSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetentionSettings' {Maybe ConversationRetentionSettings
conversationRetentionSettings :: Maybe ConversationRetentionSettings
$sel:conversationRetentionSettings:RetentionSettings' :: RetentionSettings -> Maybe ConversationRetentionSettings
conversationRetentionSettings} -> Maybe ConversationRetentionSettings
conversationRetentionSettings) (\s :: RetentionSettings
s@RetentionSettings' {} Maybe ConversationRetentionSettings
a -> RetentionSettings
s {$sel:conversationRetentionSettings:RetentionSettings' :: Maybe ConversationRetentionSettings
conversationRetentionSettings = Maybe ConversationRetentionSettings
a} :: RetentionSettings)

instance Core.FromJSON RetentionSettings where
  parseJSON :: Value -> Parser RetentionSettings
parseJSON =
    String
-> (Object -> Parser RetentionSettings)
-> Value
-> Parser RetentionSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RetentionSettings"
      ( \Object
x ->
          Maybe RoomRetentionSettings
-> Maybe ConversationRetentionSettings -> RetentionSettings
RetentionSettings'
            (Maybe RoomRetentionSettings
 -> Maybe ConversationRetentionSettings -> RetentionSettings)
-> Parser (Maybe RoomRetentionSettings)
-> Parser
     (Maybe ConversationRetentionSettings -> RetentionSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RoomRetentionSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RoomRetentionSettings")
            Parser (Maybe ConversationRetentionSettings -> RetentionSettings)
-> Parser (Maybe ConversationRetentionSettings)
-> Parser RetentionSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConversationRetentionSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConversationRetentionSettings")
      )

instance Prelude.Hashable RetentionSettings

instance Prelude.NFData RetentionSettings

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