{-# 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.CertificateManager.Types.ExpiryEventsConfiguration
-- 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.CertificateManager.Types.ExpiryEventsConfiguration where

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

-- | Object containing expiration events options associated with an Amazon
-- Web Services account.
--
-- /See:/ 'newExpiryEventsConfiguration' smart constructor.
data ExpiryEventsConfiguration = ExpiryEventsConfiguration'
  { -- | Specifies the number of days prior to certificate expiration when ACM
    -- starts generating @EventBridge@ events. ACM sends one event per day per
    -- certificate until the certificate expires. By default, accounts receive
    -- events starting 45 days before certificate expiration.
    ExpiryEventsConfiguration -> Maybe Natural
daysBeforeExpiry :: Prelude.Maybe Prelude.Natural
  }
  deriving (ExpiryEventsConfiguration -> ExpiryEventsConfiguration -> Bool
(ExpiryEventsConfiguration -> ExpiryEventsConfiguration -> Bool)
-> (ExpiryEventsConfiguration -> ExpiryEventsConfiguration -> Bool)
-> Eq ExpiryEventsConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExpiryEventsConfiguration -> ExpiryEventsConfiguration -> Bool
$c/= :: ExpiryEventsConfiguration -> ExpiryEventsConfiguration -> Bool
== :: ExpiryEventsConfiguration -> ExpiryEventsConfiguration -> Bool
$c== :: ExpiryEventsConfiguration -> ExpiryEventsConfiguration -> Bool
Prelude.Eq, ReadPrec [ExpiryEventsConfiguration]
ReadPrec ExpiryEventsConfiguration
Int -> ReadS ExpiryEventsConfiguration
ReadS [ExpiryEventsConfiguration]
(Int -> ReadS ExpiryEventsConfiguration)
-> ReadS [ExpiryEventsConfiguration]
-> ReadPrec ExpiryEventsConfiguration
-> ReadPrec [ExpiryEventsConfiguration]
-> Read ExpiryEventsConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExpiryEventsConfiguration]
$creadListPrec :: ReadPrec [ExpiryEventsConfiguration]
readPrec :: ReadPrec ExpiryEventsConfiguration
$creadPrec :: ReadPrec ExpiryEventsConfiguration
readList :: ReadS [ExpiryEventsConfiguration]
$creadList :: ReadS [ExpiryEventsConfiguration]
readsPrec :: Int -> ReadS ExpiryEventsConfiguration
$creadsPrec :: Int -> ReadS ExpiryEventsConfiguration
Prelude.Read, Int -> ExpiryEventsConfiguration -> ShowS
[ExpiryEventsConfiguration] -> ShowS
ExpiryEventsConfiguration -> String
(Int -> ExpiryEventsConfiguration -> ShowS)
-> (ExpiryEventsConfiguration -> String)
-> ([ExpiryEventsConfiguration] -> ShowS)
-> Show ExpiryEventsConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExpiryEventsConfiguration] -> ShowS
$cshowList :: [ExpiryEventsConfiguration] -> ShowS
show :: ExpiryEventsConfiguration -> String
$cshow :: ExpiryEventsConfiguration -> String
showsPrec :: Int -> ExpiryEventsConfiguration -> ShowS
$cshowsPrec :: Int -> ExpiryEventsConfiguration -> ShowS
Prelude.Show, (forall x.
 ExpiryEventsConfiguration -> Rep ExpiryEventsConfiguration x)
-> (forall x.
    Rep ExpiryEventsConfiguration x -> ExpiryEventsConfiguration)
-> Generic ExpiryEventsConfiguration
forall x.
Rep ExpiryEventsConfiguration x -> ExpiryEventsConfiguration
forall x.
ExpiryEventsConfiguration -> Rep ExpiryEventsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExpiryEventsConfiguration x -> ExpiryEventsConfiguration
$cfrom :: forall x.
ExpiryEventsConfiguration -> Rep ExpiryEventsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ExpiryEventsConfiguration' 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:
--
-- 'daysBeforeExpiry', 'expiryEventsConfiguration_daysBeforeExpiry' - Specifies the number of days prior to certificate expiration when ACM
-- starts generating @EventBridge@ events. ACM sends one event per day per
-- certificate until the certificate expires. By default, accounts receive
-- events starting 45 days before certificate expiration.
newExpiryEventsConfiguration ::
  ExpiryEventsConfiguration
newExpiryEventsConfiguration :: ExpiryEventsConfiguration
newExpiryEventsConfiguration =
  ExpiryEventsConfiguration' :: Maybe Natural -> ExpiryEventsConfiguration
ExpiryEventsConfiguration'
    { $sel:daysBeforeExpiry:ExpiryEventsConfiguration' :: Maybe Natural
daysBeforeExpiry =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the number of days prior to certificate expiration when ACM
-- starts generating @EventBridge@ events. ACM sends one event per day per
-- certificate until the certificate expires. By default, accounts receive
-- events starting 45 days before certificate expiration.
expiryEventsConfiguration_daysBeforeExpiry :: Lens.Lens' ExpiryEventsConfiguration (Prelude.Maybe Prelude.Natural)
expiryEventsConfiguration_daysBeforeExpiry :: (Maybe Natural -> f (Maybe Natural))
-> ExpiryEventsConfiguration -> f ExpiryEventsConfiguration
expiryEventsConfiguration_daysBeforeExpiry = (ExpiryEventsConfiguration -> Maybe Natural)
-> (ExpiryEventsConfiguration
    -> Maybe Natural -> ExpiryEventsConfiguration)
-> Lens
     ExpiryEventsConfiguration
     ExpiryEventsConfiguration
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExpiryEventsConfiguration' {Maybe Natural
daysBeforeExpiry :: Maybe Natural
$sel:daysBeforeExpiry:ExpiryEventsConfiguration' :: ExpiryEventsConfiguration -> Maybe Natural
daysBeforeExpiry} -> Maybe Natural
daysBeforeExpiry) (\s :: ExpiryEventsConfiguration
s@ExpiryEventsConfiguration' {} Maybe Natural
a -> ExpiryEventsConfiguration
s {$sel:daysBeforeExpiry:ExpiryEventsConfiguration' :: Maybe Natural
daysBeforeExpiry = Maybe Natural
a} :: ExpiryEventsConfiguration)

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

instance Prelude.Hashable ExpiryEventsConfiguration

instance Prelude.NFData ExpiryEventsConfiguration

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