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

import Amazonka.Chime.Types.ChannelRetentionSettings
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details of the data-retention settings for an @AppInstance@.
--
-- /See:/ 'newAppInstanceRetentionSettings' smart constructor.
data AppInstanceRetentionSettings = AppInstanceRetentionSettings'
  { -- | The length of time in days to retain the messages in a channel.
    AppInstanceRetentionSettings -> Maybe ChannelRetentionSettings
channelRetentionSettings :: Prelude.Maybe ChannelRetentionSettings
  }
  deriving (AppInstanceRetentionSettings
-> AppInstanceRetentionSettings -> Bool
(AppInstanceRetentionSettings
 -> AppInstanceRetentionSettings -> Bool)
-> (AppInstanceRetentionSettings
    -> AppInstanceRetentionSettings -> Bool)
-> Eq AppInstanceRetentionSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AppInstanceRetentionSettings
-> AppInstanceRetentionSettings -> Bool
$c/= :: AppInstanceRetentionSettings
-> AppInstanceRetentionSettings -> Bool
== :: AppInstanceRetentionSettings
-> AppInstanceRetentionSettings -> Bool
$c== :: AppInstanceRetentionSettings
-> AppInstanceRetentionSettings -> Bool
Prelude.Eq, ReadPrec [AppInstanceRetentionSettings]
ReadPrec AppInstanceRetentionSettings
Int -> ReadS AppInstanceRetentionSettings
ReadS [AppInstanceRetentionSettings]
(Int -> ReadS AppInstanceRetentionSettings)
-> ReadS [AppInstanceRetentionSettings]
-> ReadPrec AppInstanceRetentionSettings
-> ReadPrec [AppInstanceRetentionSettings]
-> Read AppInstanceRetentionSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AppInstanceRetentionSettings]
$creadListPrec :: ReadPrec [AppInstanceRetentionSettings]
readPrec :: ReadPrec AppInstanceRetentionSettings
$creadPrec :: ReadPrec AppInstanceRetentionSettings
readList :: ReadS [AppInstanceRetentionSettings]
$creadList :: ReadS [AppInstanceRetentionSettings]
readsPrec :: Int -> ReadS AppInstanceRetentionSettings
$creadsPrec :: Int -> ReadS AppInstanceRetentionSettings
Prelude.Read, Int -> AppInstanceRetentionSettings -> ShowS
[AppInstanceRetentionSettings] -> ShowS
AppInstanceRetentionSettings -> String
(Int -> AppInstanceRetentionSettings -> ShowS)
-> (AppInstanceRetentionSettings -> String)
-> ([AppInstanceRetentionSettings] -> ShowS)
-> Show AppInstanceRetentionSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AppInstanceRetentionSettings] -> ShowS
$cshowList :: [AppInstanceRetentionSettings] -> ShowS
show :: AppInstanceRetentionSettings -> String
$cshow :: AppInstanceRetentionSettings -> String
showsPrec :: Int -> AppInstanceRetentionSettings -> ShowS
$cshowsPrec :: Int -> AppInstanceRetentionSettings -> ShowS
Prelude.Show, (forall x.
 AppInstanceRetentionSettings -> Rep AppInstanceRetentionSettings x)
-> (forall x.
    Rep AppInstanceRetentionSettings x -> AppInstanceRetentionSettings)
-> Generic AppInstanceRetentionSettings
forall x.
Rep AppInstanceRetentionSettings x -> AppInstanceRetentionSettings
forall x.
AppInstanceRetentionSettings -> Rep AppInstanceRetentionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AppInstanceRetentionSettings x -> AppInstanceRetentionSettings
$cfrom :: forall x.
AppInstanceRetentionSettings -> Rep AppInstanceRetentionSettings x
Prelude.Generic)

-- |
-- Create a value of 'AppInstanceRetentionSettings' 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:
--
-- 'channelRetentionSettings', 'appInstanceRetentionSettings_channelRetentionSettings' - The length of time in days to retain the messages in a channel.
newAppInstanceRetentionSettings ::
  AppInstanceRetentionSettings
newAppInstanceRetentionSettings :: AppInstanceRetentionSettings
newAppInstanceRetentionSettings =
  AppInstanceRetentionSettings' :: Maybe ChannelRetentionSettings -> AppInstanceRetentionSettings
AppInstanceRetentionSettings'
    { $sel:channelRetentionSettings:AppInstanceRetentionSettings' :: Maybe ChannelRetentionSettings
channelRetentionSettings =
        Maybe ChannelRetentionSettings
forall a. Maybe a
Prelude.Nothing
    }

-- | The length of time in days to retain the messages in a channel.
appInstanceRetentionSettings_channelRetentionSettings :: Lens.Lens' AppInstanceRetentionSettings (Prelude.Maybe ChannelRetentionSettings)
appInstanceRetentionSettings_channelRetentionSettings :: (Maybe ChannelRetentionSettings
 -> f (Maybe ChannelRetentionSettings))
-> AppInstanceRetentionSettings -> f AppInstanceRetentionSettings
appInstanceRetentionSettings_channelRetentionSettings = (AppInstanceRetentionSettings -> Maybe ChannelRetentionSettings)
-> (AppInstanceRetentionSettings
    -> Maybe ChannelRetentionSettings -> AppInstanceRetentionSettings)
-> Lens
     AppInstanceRetentionSettings
     AppInstanceRetentionSettings
     (Maybe ChannelRetentionSettings)
     (Maybe ChannelRetentionSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppInstanceRetentionSettings' {Maybe ChannelRetentionSettings
channelRetentionSettings :: Maybe ChannelRetentionSettings
$sel:channelRetentionSettings:AppInstanceRetentionSettings' :: AppInstanceRetentionSettings -> Maybe ChannelRetentionSettings
channelRetentionSettings} -> Maybe ChannelRetentionSettings
channelRetentionSettings) (\s :: AppInstanceRetentionSettings
s@AppInstanceRetentionSettings' {} Maybe ChannelRetentionSettings
a -> AppInstanceRetentionSettings
s {$sel:channelRetentionSettings:AppInstanceRetentionSettings' :: Maybe ChannelRetentionSettings
channelRetentionSettings = Maybe ChannelRetentionSettings
a} :: AppInstanceRetentionSettings)

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

instance
  Prelude.Hashable
    AppInstanceRetentionSettings

instance Prelude.NFData AppInstanceRetentionSettings

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