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

import Amazonka.Config.Types.MaximumExecutionFrequency
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

-- | Provides options for how often Config delivers configuration snapshots
-- to the Amazon S3 bucket in your delivery channel.
--
-- The frequency for a rule that triggers evaluations for your resources
-- when Config delivers the configuration snapshot is set by one of two
-- values, depending on which is less frequent:
--
-- -   The value for the @deliveryFrequency@ parameter within the delivery
--     channel configuration, which sets how often Config delivers
--     configuration snapshots. This value also sets how often Config
--     invokes evaluations for Config rules.
--
-- -   The value for the @MaximumExecutionFrequency@ parameter, which sets
--     the maximum frequency with which Config invokes evaluations for the
--     rule. For more information, see ConfigRule.
--
-- If the @deliveryFrequency@ value is less frequent than the
-- @MaximumExecutionFrequency@ value for a rule, Config invokes the rule
-- only as often as the @deliveryFrequency@ value.
--
-- 1.  For example, you want your rule to run evaluations when Config
--     delivers the configuration snapshot.
--
-- 2.  You specify the @MaximumExecutionFrequency@ value for @Six_Hours@.
--
-- 3.  You then specify the delivery channel @deliveryFrequency@ value for
--     @TwentyFour_Hours@.
--
-- 4.  Because the value for @deliveryFrequency@ is less frequent than
--     @MaximumExecutionFrequency@, Config invokes evaluations for the rule
--     every 24 hours.
--
-- You should set the @MaximumExecutionFrequency@ value to be at least as
-- frequent as the @deliveryFrequency@ value. You can view the
-- @deliveryFrequency@ value by using the @DescribeDeliveryChannnels@
-- action.
--
-- To update the @deliveryFrequency@ with which Config delivers your
-- configuration snapshots, use the @PutDeliveryChannel@ action.
--
-- /See:/ 'newConfigSnapshotDeliveryProperties' smart constructor.
data ConfigSnapshotDeliveryProperties = ConfigSnapshotDeliveryProperties'
  { -- | The frequency with which Config delivers configuration snapshots.
    ConfigSnapshotDeliveryProperties -> Maybe MaximumExecutionFrequency
deliveryFrequency :: Prelude.Maybe MaximumExecutionFrequency
  }
  deriving (ConfigSnapshotDeliveryProperties
-> ConfigSnapshotDeliveryProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigSnapshotDeliveryProperties
-> ConfigSnapshotDeliveryProperties -> Bool
$c/= :: ConfigSnapshotDeliveryProperties
-> ConfigSnapshotDeliveryProperties -> Bool
== :: ConfigSnapshotDeliveryProperties
-> ConfigSnapshotDeliveryProperties -> Bool
$c== :: ConfigSnapshotDeliveryProperties
-> ConfigSnapshotDeliveryProperties -> Bool
Prelude.Eq, ReadPrec [ConfigSnapshotDeliveryProperties]
ReadPrec ConfigSnapshotDeliveryProperties
Int -> ReadS ConfigSnapshotDeliveryProperties
ReadS [ConfigSnapshotDeliveryProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigSnapshotDeliveryProperties]
$creadListPrec :: ReadPrec [ConfigSnapshotDeliveryProperties]
readPrec :: ReadPrec ConfigSnapshotDeliveryProperties
$creadPrec :: ReadPrec ConfigSnapshotDeliveryProperties
readList :: ReadS [ConfigSnapshotDeliveryProperties]
$creadList :: ReadS [ConfigSnapshotDeliveryProperties]
readsPrec :: Int -> ReadS ConfigSnapshotDeliveryProperties
$creadsPrec :: Int -> ReadS ConfigSnapshotDeliveryProperties
Prelude.Read, Int -> ConfigSnapshotDeliveryProperties -> ShowS
[ConfigSnapshotDeliveryProperties] -> ShowS
ConfigSnapshotDeliveryProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigSnapshotDeliveryProperties] -> ShowS
$cshowList :: [ConfigSnapshotDeliveryProperties] -> ShowS
show :: ConfigSnapshotDeliveryProperties -> String
$cshow :: ConfigSnapshotDeliveryProperties -> String
showsPrec :: Int -> ConfigSnapshotDeliveryProperties -> ShowS
$cshowsPrec :: Int -> ConfigSnapshotDeliveryProperties -> ShowS
Prelude.Show, forall x.
Rep ConfigSnapshotDeliveryProperties x
-> ConfigSnapshotDeliveryProperties
forall x.
ConfigSnapshotDeliveryProperties
-> Rep ConfigSnapshotDeliveryProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfigSnapshotDeliveryProperties x
-> ConfigSnapshotDeliveryProperties
$cfrom :: forall x.
ConfigSnapshotDeliveryProperties
-> Rep ConfigSnapshotDeliveryProperties x
Prelude.Generic)

-- |
-- Create a value of 'ConfigSnapshotDeliveryProperties' 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:
--
-- 'deliveryFrequency', 'configSnapshotDeliveryProperties_deliveryFrequency' - The frequency with which Config delivers configuration snapshots.
newConfigSnapshotDeliveryProperties ::
  ConfigSnapshotDeliveryProperties
newConfigSnapshotDeliveryProperties :: ConfigSnapshotDeliveryProperties
newConfigSnapshotDeliveryProperties =
  ConfigSnapshotDeliveryProperties'
    { $sel:deliveryFrequency:ConfigSnapshotDeliveryProperties' :: Maybe MaximumExecutionFrequency
deliveryFrequency =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The frequency with which Config delivers configuration snapshots.
configSnapshotDeliveryProperties_deliveryFrequency :: Lens.Lens' ConfigSnapshotDeliveryProperties (Prelude.Maybe MaximumExecutionFrequency)
configSnapshotDeliveryProperties_deliveryFrequency :: Lens'
  ConfigSnapshotDeliveryProperties (Maybe MaximumExecutionFrequency)
configSnapshotDeliveryProperties_deliveryFrequency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigSnapshotDeliveryProperties' {Maybe MaximumExecutionFrequency
deliveryFrequency :: Maybe MaximumExecutionFrequency
$sel:deliveryFrequency:ConfigSnapshotDeliveryProperties' :: ConfigSnapshotDeliveryProperties -> Maybe MaximumExecutionFrequency
deliveryFrequency} -> Maybe MaximumExecutionFrequency
deliveryFrequency) (\s :: ConfigSnapshotDeliveryProperties
s@ConfigSnapshotDeliveryProperties' {} Maybe MaximumExecutionFrequency
a -> ConfigSnapshotDeliveryProperties
s {$sel:deliveryFrequency:ConfigSnapshotDeliveryProperties' :: Maybe MaximumExecutionFrequency
deliveryFrequency = Maybe MaximumExecutionFrequency
a} :: ConfigSnapshotDeliveryProperties)

instance
  Data.FromJSON
    ConfigSnapshotDeliveryProperties
  where
  parseJSON :: Value -> Parser ConfigSnapshotDeliveryProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConfigSnapshotDeliveryProperties"
      ( \Object
x ->
          Maybe MaximumExecutionFrequency -> ConfigSnapshotDeliveryProperties
ConfigSnapshotDeliveryProperties'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"deliveryFrequency")
      )

instance
  Prelude.Hashable
    ConfigSnapshotDeliveryProperties
  where
  hashWithSalt :: Int -> ConfigSnapshotDeliveryProperties -> Int
hashWithSalt
    Int
_salt
    ConfigSnapshotDeliveryProperties' {Maybe MaximumExecutionFrequency
deliveryFrequency :: Maybe MaximumExecutionFrequency
$sel:deliveryFrequency:ConfigSnapshotDeliveryProperties' :: ConfigSnapshotDeliveryProperties -> Maybe MaximumExecutionFrequency
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MaximumExecutionFrequency
deliveryFrequency

instance
  Prelude.NFData
    ConfigSnapshotDeliveryProperties
  where
  rnf :: ConfigSnapshotDeliveryProperties -> ()
rnf ConfigSnapshotDeliveryProperties' {Maybe MaximumExecutionFrequency
deliveryFrequency :: Maybe MaximumExecutionFrequency
$sel:deliveryFrequency:ConfigSnapshotDeliveryProperties' :: ConfigSnapshotDeliveryProperties -> Maybe MaximumExecutionFrequency
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe MaximumExecutionFrequency
deliveryFrequency

instance Data.ToJSON ConfigSnapshotDeliveryProperties where
  toJSON :: ConfigSnapshotDeliveryProperties -> Value
toJSON ConfigSnapshotDeliveryProperties' {Maybe MaximumExecutionFrequency
deliveryFrequency :: Maybe MaximumExecutionFrequency
$sel:deliveryFrequency:ConfigSnapshotDeliveryProperties' :: ConfigSnapshotDeliveryProperties -> Maybe MaximumExecutionFrequency
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"deliveryFrequency" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MaximumExecutionFrequency
deliveryFrequency
          ]
      )