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

import Amazonka.CertificateManager.Types.DomainValidation
import Amazonka.CertificateManager.Types.FailureReason
import Amazonka.CertificateManager.Types.RenewalStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the status of ACM\'s
-- <https://docs.aws.amazon.com/acm/latest/userguide/acm-renewal.html managed renewal>
-- for the certificate. This structure exists only when the certificate
-- type is @AMAZON_ISSUED@.
--
-- /See:/ 'newRenewalSummary' smart constructor.
data RenewalSummary = RenewalSummary'
  { -- | The reason that a renewal request was unsuccessful.
    RenewalSummary -> Maybe FailureReason
renewalStatusReason :: Prelude.Maybe FailureReason,
    -- | The status of ACM\'s
    -- <https://docs.aws.amazon.com/acm/latest/userguide/acm-renewal.html managed renewal>
    -- of the certificate.
    RenewalSummary -> RenewalStatus
renewalStatus :: RenewalStatus,
    -- | Contains information about the validation of each domain name in the
    -- certificate, as it pertains to ACM\'s
    -- <https://docs.aws.amazon.com/acm/latest/userguide/acm-renewal.html managed renewal>.
    -- This is different from the initial validation that occurs as a result of
    -- the RequestCertificate request. This field exists only when the
    -- certificate type is @AMAZON_ISSUED@.
    RenewalSummary -> NonEmpty DomainValidation
domainValidationOptions :: Prelude.NonEmpty DomainValidation,
    -- | The time at which the renewal summary was last updated.
    RenewalSummary -> POSIX
updatedAt :: Core.POSIX
  }
  deriving (RenewalSummary -> RenewalSummary -> Bool
(RenewalSummary -> RenewalSummary -> Bool)
-> (RenewalSummary -> RenewalSummary -> Bool) -> Eq RenewalSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RenewalSummary -> RenewalSummary -> Bool
$c/= :: RenewalSummary -> RenewalSummary -> Bool
== :: RenewalSummary -> RenewalSummary -> Bool
$c== :: RenewalSummary -> RenewalSummary -> Bool
Prelude.Eq, ReadPrec [RenewalSummary]
ReadPrec RenewalSummary
Int -> ReadS RenewalSummary
ReadS [RenewalSummary]
(Int -> ReadS RenewalSummary)
-> ReadS [RenewalSummary]
-> ReadPrec RenewalSummary
-> ReadPrec [RenewalSummary]
-> Read RenewalSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RenewalSummary]
$creadListPrec :: ReadPrec [RenewalSummary]
readPrec :: ReadPrec RenewalSummary
$creadPrec :: ReadPrec RenewalSummary
readList :: ReadS [RenewalSummary]
$creadList :: ReadS [RenewalSummary]
readsPrec :: Int -> ReadS RenewalSummary
$creadsPrec :: Int -> ReadS RenewalSummary
Prelude.Read, Int -> RenewalSummary -> ShowS
[RenewalSummary] -> ShowS
RenewalSummary -> String
(Int -> RenewalSummary -> ShowS)
-> (RenewalSummary -> String)
-> ([RenewalSummary] -> ShowS)
-> Show RenewalSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RenewalSummary] -> ShowS
$cshowList :: [RenewalSummary] -> ShowS
show :: RenewalSummary -> String
$cshow :: RenewalSummary -> String
showsPrec :: Int -> RenewalSummary -> ShowS
$cshowsPrec :: Int -> RenewalSummary -> ShowS
Prelude.Show, (forall x. RenewalSummary -> Rep RenewalSummary x)
-> (forall x. Rep RenewalSummary x -> RenewalSummary)
-> Generic RenewalSummary
forall x. Rep RenewalSummary x -> RenewalSummary
forall x. RenewalSummary -> Rep RenewalSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RenewalSummary x -> RenewalSummary
$cfrom :: forall x. RenewalSummary -> Rep RenewalSummary x
Prelude.Generic)

-- |
-- Create a value of 'RenewalSummary' 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:
--
-- 'renewalStatusReason', 'renewalSummary_renewalStatusReason' - The reason that a renewal request was unsuccessful.
--
-- 'renewalStatus', 'renewalSummary_renewalStatus' - The status of ACM\'s
-- <https://docs.aws.amazon.com/acm/latest/userguide/acm-renewal.html managed renewal>
-- of the certificate.
--
-- 'domainValidationOptions', 'renewalSummary_domainValidationOptions' - Contains information about the validation of each domain name in the
-- certificate, as it pertains to ACM\'s
-- <https://docs.aws.amazon.com/acm/latest/userguide/acm-renewal.html managed renewal>.
-- This is different from the initial validation that occurs as a result of
-- the RequestCertificate request. This field exists only when the
-- certificate type is @AMAZON_ISSUED@.
--
-- 'updatedAt', 'renewalSummary_updatedAt' - The time at which the renewal summary was last updated.
newRenewalSummary ::
  -- | 'renewalStatus'
  RenewalStatus ->
  -- | 'domainValidationOptions'
  Prelude.NonEmpty DomainValidation ->
  -- | 'updatedAt'
  Prelude.UTCTime ->
  RenewalSummary
newRenewalSummary :: RenewalStatus
-> NonEmpty DomainValidation -> UTCTime -> RenewalSummary
newRenewalSummary
  RenewalStatus
pRenewalStatus_
  NonEmpty DomainValidation
pDomainValidationOptions_
  UTCTime
pUpdatedAt_ =
    RenewalSummary' :: Maybe FailureReason
-> RenewalStatus
-> NonEmpty DomainValidation
-> POSIX
-> RenewalSummary
RenewalSummary'
      { $sel:renewalStatusReason:RenewalSummary' :: Maybe FailureReason
renewalStatusReason =
          Maybe FailureReason
forall a. Maybe a
Prelude.Nothing,
        $sel:renewalStatus:RenewalSummary' :: RenewalStatus
renewalStatus = RenewalStatus
pRenewalStatus_,
        $sel:domainValidationOptions:RenewalSummary' :: NonEmpty DomainValidation
domainValidationOptions =
          Tagged
  (NonEmpty DomainValidation) (Identity (NonEmpty DomainValidation))
-> Tagged
     (NonEmpty DomainValidation) (Identity (NonEmpty DomainValidation))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty DomainValidation) (Identity (NonEmpty DomainValidation))
 -> Tagged
      (NonEmpty DomainValidation) (Identity (NonEmpty DomainValidation)))
-> NonEmpty DomainValidation -> NonEmpty DomainValidation
forall t b. AReview t b -> b -> t
Lens.# NonEmpty DomainValidation
pDomainValidationOptions_,
        $sel:updatedAt:RenewalSummary' :: POSIX
updatedAt = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pUpdatedAt_
      }

-- | The reason that a renewal request was unsuccessful.
renewalSummary_renewalStatusReason :: Lens.Lens' RenewalSummary (Prelude.Maybe FailureReason)
renewalSummary_renewalStatusReason :: (Maybe FailureReason -> f (Maybe FailureReason))
-> RenewalSummary -> f RenewalSummary
renewalSummary_renewalStatusReason = (RenewalSummary -> Maybe FailureReason)
-> (RenewalSummary -> Maybe FailureReason -> RenewalSummary)
-> Lens
     RenewalSummary
     RenewalSummary
     (Maybe FailureReason)
     (Maybe FailureReason)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewalSummary' {Maybe FailureReason
renewalStatusReason :: Maybe FailureReason
$sel:renewalStatusReason:RenewalSummary' :: RenewalSummary -> Maybe FailureReason
renewalStatusReason} -> Maybe FailureReason
renewalStatusReason) (\s :: RenewalSummary
s@RenewalSummary' {} Maybe FailureReason
a -> RenewalSummary
s {$sel:renewalStatusReason:RenewalSummary' :: Maybe FailureReason
renewalStatusReason = Maybe FailureReason
a} :: RenewalSummary)

-- | The status of ACM\'s
-- <https://docs.aws.amazon.com/acm/latest/userguide/acm-renewal.html managed renewal>
-- of the certificate.
renewalSummary_renewalStatus :: Lens.Lens' RenewalSummary RenewalStatus
renewalSummary_renewalStatus :: (RenewalStatus -> f RenewalStatus)
-> RenewalSummary -> f RenewalSummary
renewalSummary_renewalStatus = (RenewalSummary -> RenewalStatus)
-> (RenewalSummary -> RenewalStatus -> RenewalSummary)
-> Lens RenewalSummary RenewalSummary RenewalStatus RenewalStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewalSummary' {RenewalStatus
renewalStatus :: RenewalStatus
$sel:renewalStatus:RenewalSummary' :: RenewalSummary -> RenewalStatus
renewalStatus} -> RenewalStatus
renewalStatus) (\s :: RenewalSummary
s@RenewalSummary' {} RenewalStatus
a -> RenewalSummary
s {$sel:renewalStatus:RenewalSummary' :: RenewalStatus
renewalStatus = RenewalStatus
a} :: RenewalSummary)

-- | Contains information about the validation of each domain name in the
-- certificate, as it pertains to ACM\'s
-- <https://docs.aws.amazon.com/acm/latest/userguide/acm-renewal.html managed renewal>.
-- This is different from the initial validation that occurs as a result of
-- the RequestCertificate request. This field exists only when the
-- certificate type is @AMAZON_ISSUED@.
renewalSummary_domainValidationOptions :: Lens.Lens' RenewalSummary (Prelude.NonEmpty DomainValidation)
renewalSummary_domainValidationOptions :: (NonEmpty DomainValidation -> f (NonEmpty DomainValidation))
-> RenewalSummary -> f RenewalSummary
renewalSummary_domainValidationOptions = (RenewalSummary -> NonEmpty DomainValidation)
-> (RenewalSummary -> NonEmpty DomainValidation -> RenewalSummary)
-> Lens
     RenewalSummary
     RenewalSummary
     (NonEmpty DomainValidation)
     (NonEmpty DomainValidation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewalSummary' {NonEmpty DomainValidation
domainValidationOptions :: NonEmpty DomainValidation
$sel:domainValidationOptions:RenewalSummary' :: RenewalSummary -> NonEmpty DomainValidation
domainValidationOptions} -> NonEmpty DomainValidation
domainValidationOptions) (\s :: RenewalSummary
s@RenewalSummary' {} NonEmpty DomainValidation
a -> RenewalSummary
s {$sel:domainValidationOptions:RenewalSummary' :: NonEmpty DomainValidation
domainValidationOptions = NonEmpty DomainValidation
a} :: RenewalSummary) ((NonEmpty DomainValidation -> f (NonEmpty DomainValidation))
 -> RenewalSummary -> f RenewalSummary)
-> ((NonEmpty DomainValidation -> f (NonEmpty DomainValidation))
    -> NonEmpty DomainValidation -> f (NonEmpty DomainValidation))
-> (NonEmpty DomainValidation -> f (NonEmpty DomainValidation))
-> RenewalSummary
-> f RenewalSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty DomainValidation -> f (NonEmpty DomainValidation))
-> NonEmpty DomainValidation -> f (NonEmpty DomainValidation)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The time at which the renewal summary was last updated.
renewalSummary_updatedAt :: Lens.Lens' RenewalSummary Prelude.UTCTime
renewalSummary_updatedAt :: (UTCTime -> f UTCTime) -> RenewalSummary -> f RenewalSummary
renewalSummary_updatedAt = (RenewalSummary -> POSIX)
-> (RenewalSummary -> POSIX -> RenewalSummary)
-> Lens RenewalSummary RenewalSummary POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewalSummary' {POSIX
updatedAt :: POSIX
$sel:updatedAt:RenewalSummary' :: RenewalSummary -> POSIX
updatedAt} -> POSIX
updatedAt) (\s :: RenewalSummary
s@RenewalSummary' {} POSIX
a -> RenewalSummary
s {$sel:updatedAt:RenewalSummary' :: POSIX
updatedAt = POSIX
a} :: RenewalSummary) ((POSIX -> f POSIX) -> RenewalSummary -> f RenewalSummary)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> RenewalSummary
-> f RenewalSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON RenewalSummary where
  parseJSON :: Value -> Parser RenewalSummary
parseJSON =
    String
-> (Object -> Parser RenewalSummary)
-> Value
-> Parser RenewalSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RenewalSummary"
      ( \Object
x ->
          Maybe FailureReason
-> RenewalStatus
-> NonEmpty DomainValidation
-> POSIX
-> RenewalSummary
RenewalSummary'
            (Maybe FailureReason
 -> RenewalStatus
 -> NonEmpty DomainValidation
 -> POSIX
 -> RenewalSummary)
-> Parser (Maybe FailureReason)
-> Parser
     (RenewalStatus
      -> NonEmpty DomainValidation -> POSIX -> RenewalSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FailureReason)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RenewalStatusReason")
            Parser
  (RenewalStatus
   -> NonEmpty DomainValidation -> POSIX -> RenewalSummary)
-> Parser RenewalStatus
-> Parser (NonEmpty DomainValidation -> POSIX -> RenewalSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser RenewalStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RenewalStatus")
            Parser (NonEmpty DomainValidation -> POSIX -> RenewalSummary)
-> Parser (NonEmpty DomainValidation)
-> Parser (POSIX -> RenewalSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty DomainValidation)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DomainValidationOptions")
            Parser (POSIX -> RenewalSummary)
-> Parser POSIX -> Parser RenewalSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"UpdatedAt")
      )

instance Prelude.Hashable RenewalSummary

instance Prelude.NFData RenewalSummary