{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Config.Types.RetentionConfiguration 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

-- | 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
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]
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
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. 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'
      { $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 :: Lens' RetentionConfiguration Text
retentionConfiguration_name = 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 :: Lens' RetentionConfiguration Natural
retentionConfiguration_retentionPeriodInDays = 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 Data.FromJSON RetentionConfiguration where
  parseJSON :: Value -> Parser RetentionConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RetentionConfiguration"
      ( \Object
x ->
          Text -> Natural -> RetentionConfiguration
RetentionConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"RetentionPeriodInDays")
      )

instance Prelude.Hashable RetentionConfiguration where
  hashWithSalt :: Int -> RetentionConfiguration -> Int
hashWithSalt Int
_salt RetentionConfiguration' {Natural
Text
retentionPeriodInDays :: Natural
name :: Text
$sel:retentionPeriodInDays:RetentionConfiguration' :: RetentionConfiguration -> Natural
$sel:name:RetentionConfiguration' :: RetentionConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
retentionPeriodInDays

instance Prelude.NFData RetentionConfiguration where
  rnf :: RetentionConfiguration -> ()
rnf RetentionConfiguration' {Natural
Text
retentionPeriodInDays :: Natural
name :: Text
$sel:retentionPeriodInDays:RetentionConfiguration' :: RetentionConfiguration -> Natural
$sel:name:RetentionConfiguration' :: RetentionConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
retentionPeriodInDays