{-# 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.Config.Types.RetentionConfiguration
-- 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.Config.Types.RetentionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object with the name of the retention configuration and the retention
-- period in days. The object stores the configuration for data retention
-- in Config.
--
-- /See:/ 'newRetentionConfiguration' smart constructor.
data RetentionConfiguration = RetentionConfiguration'
  { -- | The name of the retention configuration object.
    RetentionConfiguration -> Text
name :: Prelude.Text,
    -- | Number of days Config stores your historical information.
    --
    -- Currently, only applicable to the configuration item history.
    RetentionConfiguration -> Natural
retentionPeriodInDays :: Prelude.Natural
  }
  deriving (RetentionConfiguration -> RetentionConfiguration -> Bool
(RetentionConfiguration -> RetentionConfiguration -> Bool)
-> (RetentionConfiguration -> RetentionConfiguration -> Bool)
-> Eq RetentionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetentionConfiguration -> RetentionConfiguration -> Bool
$c/= :: RetentionConfiguration -> RetentionConfiguration -> Bool
== :: RetentionConfiguration -> RetentionConfiguration -> Bool
$c== :: RetentionConfiguration -> RetentionConfiguration -> Bool
Prelude.Eq, ReadPrec [RetentionConfiguration]
ReadPrec RetentionConfiguration
Int -> ReadS RetentionConfiguration
ReadS [RetentionConfiguration]
(Int -> ReadS RetentionConfiguration)
-> ReadS [RetentionConfiguration]
-> ReadPrec RetentionConfiguration
-> ReadPrec [RetentionConfiguration]
-> Read RetentionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetentionConfiguration]
$creadListPrec :: ReadPrec [RetentionConfiguration]
readPrec :: ReadPrec RetentionConfiguration
$creadPrec :: ReadPrec RetentionConfiguration
readList :: ReadS [RetentionConfiguration]
$creadList :: ReadS [RetentionConfiguration]
readsPrec :: Int -> ReadS RetentionConfiguration
$creadsPrec :: Int -> ReadS RetentionConfiguration
Prelude.Read, Int -> RetentionConfiguration -> ShowS
[RetentionConfiguration] -> ShowS
RetentionConfiguration -> String
(Int -> RetentionConfiguration -> ShowS)
-> (RetentionConfiguration -> String)
-> ([RetentionConfiguration] -> ShowS)
-> Show RetentionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetentionConfiguration] -> ShowS
$cshowList :: [RetentionConfiguration] -> ShowS
show :: RetentionConfiguration -> String
$cshow :: RetentionConfiguration -> String
showsPrec :: Int -> RetentionConfiguration -> ShowS
$cshowsPrec :: Int -> RetentionConfiguration -> ShowS
Prelude.Show, (forall x. RetentionConfiguration -> Rep RetentionConfiguration x)
-> (forall x.
    Rep RetentionConfiguration x -> RetentionConfiguration)
-> Generic RetentionConfiguration
forall x. Rep RetentionConfiguration x -> RetentionConfiguration
forall x. RetentionConfiguration -> Rep RetentionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetentionConfiguration x -> RetentionConfiguration
$cfrom :: forall x. RetentionConfiguration -> Rep RetentionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'RetentionConfiguration' 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:
--
-- 'name', 'retentionConfiguration_name' - The name of the retention configuration object.
--
-- 'retentionPeriodInDays', 'retentionConfiguration_retentionPeriodInDays' - Number of days Config stores your historical information.
--
-- Currently, only applicable to the configuration item history.
newRetentionConfiguration ::
  -- | 'name'
  Prelude.Text ->
  -- | 'retentionPeriodInDays'
  Prelude.Natural ->
  RetentionConfiguration
newRetentionConfiguration :: Text -> Natural -> RetentionConfiguration
newRetentionConfiguration
  Text
pName_
  Natural
pRetentionPeriodInDays_ =
    RetentionConfiguration' :: Text -> Natural -> RetentionConfiguration
RetentionConfiguration'
      { $sel:name:RetentionConfiguration' :: Text
name = Text
pName_,
        $sel:retentionPeriodInDays:RetentionConfiguration' :: Natural
retentionPeriodInDays = Natural
pRetentionPeriodInDays_
      }

-- | The name of the retention configuration object.
retentionConfiguration_name :: Lens.Lens' RetentionConfiguration Prelude.Text
retentionConfiguration_name :: (Text -> f Text)
-> RetentionConfiguration -> f RetentionConfiguration
retentionConfiguration_name = (RetentionConfiguration -> Text)
-> (RetentionConfiguration -> Text -> RetentionConfiguration)
-> Lens RetentionConfiguration RetentionConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetentionConfiguration' {Text
name :: Text
$sel:name:RetentionConfiguration' :: RetentionConfiguration -> Text
name} -> Text
name) (\s :: RetentionConfiguration
s@RetentionConfiguration' {} Text
a -> RetentionConfiguration
s {$sel:name:RetentionConfiguration' :: Text
name = Text
a} :: RetentionConfiguration)

-- | Number of days Config stores your historical information.
--
-- Currently, only applicable to the configuration item history.
retentionConfiguration_retentionPeriodInDays :: Lens.Lens' RetentionConfiguration Prelude.Natural
retentionConfiguration_retentionPeriodInDays :: (Natural -> f Natural)
-> RetentionConfiguration -> f RetentionConfiguration
retentionConfiguration_retentionPeriodInDays = (RetentionConfiguration -> Natural)
-> (RetentionConfiguration -> Natural -> RetentionConfiguration)
-> Lens
     RetentionConfiguration RetentionConfiguration Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetentionConfiguration' {Natural
retentionPeriodInDays :: Natural
$sel:retentionPeriodInDays:RetentionConfiguration' :: RetentionConfiguration -> Natural
retentionPeriodInDays} -> Natural
retentionPeriodInDays) (\s :: RetentionConfiguration
s@RetentionConfiguration' {} Natural
a -> RetentionConfiguration
s {$sel:retentionPeriodInDays:RetentionConfiguration' :: Natural
retentionPeriodInDays = Natural
a} :: RetentionConfiguration)

instance Core.FromJSON RetentionConfiguration where
  parseJSON :: Value -> Parser RetentionConfiguration
parseJSON =
    String
-> (Object -> Parser RetentionConfiguration)
-> Value
-> Parser RetentionConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RetentionConfiguration"
      ( \Object
x ->
          Text -> Natural -> RetentionConfiguration
RetentionConfiguration'
            (Text -> Natural -> RetentionConfiguration)
-> Parser Text -> Parser (Natural -> RetentionConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
            Parser (Natural -> RetentionConfiguration)
-> Parser Natural -> Parser RetentionConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RetentionPeriodInDays")
      )

instance Prelude.Hashable RetentionConfiguration

instance Prelude.NFData RetentionConfiguration