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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.DomainValidationRecord
import Amazonka.Lightsail.Types.RenewalStatus
import qualified Amazonka.Prelude as Prelude

-- | Describes the status of a SSL\/TLS certificate renewal managed by Amazon
-- Lightsail.
--
-- /See:/ 'newRenewalSummary' smart constructor.
data RenewalSummary = RenewalSummary'
  { -- | The renewal status of the certificate.
    --
    -- The following renewal status are possible:
    --
    -- -   __@PendingAutoRenewal@__ - Lightsail is attempting to automatically
    --     validate the domain names of the certificate. No further action is
    --     required.
    --
    -- -   __@PendingValidation@__ - Lightsail couldn\'t automatically validate
    --     one or more domain names of the certificate. You must take action to
    --     validate these domain names or the certificate won\'t be renewed.
    --     Check to make sure your certificate\'s domain validation records
    --     exist in your domain\'s DNS, and that your certificate remains in
    --     use.
    --
    -- -   __@Success@__ - All domain names in the certificate are validated,
    --     and Lightsail renewed the certificate. No further action is
    --     required.
    --
    -- -   __@Failed@__ - One or more domain names were not validated before
    --     the certificate expired, and Lightsail did not renew the
    --     certificate. You can request a new certificate using the
    --     @CreateCertificate@ action.
    RenewalSummary -> Maybe RenewalStatus
renewalStatus :: Prelude.Maybe RenewalStatus,
    -- | An array of objects that describe the domain validation records of the
    -- certificate.
    RenewalSummary -> Maybe [DomainValidationRecord]
domainValidationRecords :: Prelude.Maybe [DomainValidationRecord],
    -- | The timestamp when the certificate was last updated.
    RenewalSummary -> Maybe POSIX
updatedAt :: Prelude.Maybe Core.POSIX,
    -- | The reason for the renewal status of the certificate.
    RenewalSummary -> Maybe Text
renewalStatusReason :: Prelude.Maybe Prelude.Text
  }
  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:
--
-- 'renewalStatus', 'renewalSummary_renewalStatus' - The renewal status of the certificate.
--
-- The following renewal status are possible:
--
-- -   __@PendingAutoRenewal@__ - Lightsail is attempting to automatically
--     validate the domain names of the certificate. No further action is
--     required.
--
-- -   __@PendingValidation@__ - Lightsail couldn\'t automatically validate
--     one or more domain names of the certificate. You must take action to
--     validate these domain names or the certificate won\'t be renewed.
--     Check to make sure your certificate\'s domain validation records
--     exist in your domain\'s DNS, and that your certificate remains in
--     use.
--
-- -   __@Success@__ - All domain names in the certificate are validated,
--     and Lightsail renewed the certificate. No further action is
--     required.
--
-- -   __@Failed@__ - One or more domain names were not validated before
--     the certificate expired, and Lightsail did not renew the
--     certificate. You can request a new certificate using the
--     @CreateCertificate@ action.
--
-- 'domainValidationRecords', 'renewalSummary_domainValidationRecords' - An array of objects that describe the domain validation records of the
-- certificate.
--
-- 'updatedAt', 'renewalSummary_updatedAt' - The timestamp when the certificate was last updated.
--
-- 'renewalStatusReason', 'renewalSummary_renewalStatusReason' - The reason for the renewal status of the certificate.
newRenewalSummary ::
  RenewalSummary
newRenewalSummary :: RenewalSummary
newRenewalSummary =
  RenewalSummary' :: Maybe RenewalStatus
-> Maybe [DomainValidationRecord]
-> Maybe POSIX
-> Maybe Text
-> RenewalSummary
RenewalSummary'
    { $sel:renewalStatus:RenewalSummary' :: Maybe RenewalStatus
renewalStatus = Maybe RenewalStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:domainValidationRecords:RenewalSummary' :: Maybe [DomainValidationRecord]
domainValidationRecords = Maybe [DomainValidationRecord]
forall a. Maybe a
Prelude.Nothing,
      $sel:updatedAt:RenewalSummary' :: Maybe POSIX
updatedAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:renewalStatusReason:RenewalSummary' :: Maybe Text
renewalStatusReason = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The renewal status of the certificate.
--
-- The following renewal status are possible:
--
-- -   __@PendingAutoRenewal@__ - Lightsail is attempting to automatically
--     validate the domain names of the certificate. No further action is
--     required.
--
-- -   __@PendingValidation@__ - Lightsail couldn\'t automatically validate
--     one or more domain names of the certificate. You must take action to
--     validate these domain names or the certificate won\'t be renewed.
--     Check to make sure your certificate\'s domain validation records
--     exist in your domain\'s DNS, and that your certificate remains in
--     use.
--
-- -   __@Success@__ - All domain names in the certificate are validated,
--     and Lightsail renewed the certificate. No further action is
--     required.
--
-- -   __@Failed@__ - One or more domain names were not validated before
--     the certificate expired, and Lightsail did not renew the
--     certificate. You can request a new certificate using the
--     @CreateCertificate@ action.
renewalSummary_renewalStatus :: Lens.Lens' RenewalSummary (Prelude.Maybe RenewalStatus)
renewalSummary_renewalStatus :: (Maybe RenewalStatus -> f (Maybe RenewalStatus))
-> RenewalSummary -> f RenewalSummary
renewalSummary_renewalStatus = (RenewalSummary -> Maybe RenewalStatus)
-> (RenewalSummary -> Maybe RenewalStatus -> RenewalSummary)
-> Lens
     RenewalSummary
     RenewalSummary
     (Maybe RenewalStatus)
     (Maybe RenewalStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewalSummary' {Maybe RenewalStatus
renewalStatus :: Maybe RenewalStatus
$sel:renewalStatus:RenewalSummary' :: RenewalSummary -> Maybe RenewalStatus
renewalStatus} -> Maybe RenewalStatus
renewalStatus) (\s :: RenewalSummary
s@RenewalSummary' {} Maybe RenewalStatus
a -> RenewalSummary
s {$sel:renewalStatus:RenewalSummary' :: Maybe RenewalStatus
renewalStatus = Maybe RenewalStatus
a} :: RenewalSummary)

-- | An array of objects that describe the domain validation records of the
-- certificate.
renewalSummary_domainValidationRecords :: Lens.Lens' RenewalSummary (Prelude.Maybe [DomainValidationRecord])
renewalSummary_domainValidationRecords :: (Maybe [DomainValidationRecord]
 -> f (Maybe [DomainValidationRecord]))
-> RenewalSummary -> f RenewalSummary
renewalSummary_domainValidationRecords = (RenewalSummary -> Maybe [DomainValidationRecord])
-> (RenewalSummary
    -> Maybe [DomainValidationRecord] -> RenewalSummary)
-> Lens
     RenewalSummary
     RenewalSummary
     (Maybe [DomainValidationRecord])
     (Maybe [DomainValidationRecord])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewalSummary' {Maybe [DomainValidationRecord]
domainValidationRecords :: Maybe [DomainValidationRecord]
$sel:domainValidationRecords:RenewalSummary' :: RenewalSummary -> Maybe [DomainValidationRecord]
domainValidationRecords} -> Maybe [DomainValidationRecord]
domainValidationRecords) (\s :: RenewalSummary
s@RenewalSummary' {} Maybe [DomainValidationRecord]
a -> RenewalSummary
s {$sel:domainValidationRecords:RenewalSummary' :: Maybe [DomainValidationRecord]
domainValidationRecords = Maybe [DomainValidationRecord]
a} :: RenewalSummary) ((Maybe [DomainValidationRecord]
  -> f (Maybe [DomainValidationRecord]))
 -> RenewalSummary -> f RenewalSummary)
-> ((Maybe [DomainValidationRecord]
     -> f (Maybe [DomainValidationRecord]))
    -> Maybe [DomainValidationRecord]
    -> f (Maybe [DomainValidationRecord]))
-> (Maybe [DomainValidationRecord]
    -> f (Maybe [DomainValidationRecord]))
-> RenewalSummary
-> f RenewalSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DomainValidationRecord]
  [DomainValidationRecord]
  [DomainValidationRecord]
  [DomainValidationRecord]
-> Iso
     (Maybe [DomainValidationRecord])
     (Maybe [DomainValidationRecord])
     (Maybe [DomainValidationRecord])
     (Maybe [DomainValidationRecord])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [DomainValidationRecord]
  [DomainValidationRecord]
  [DomainValidationRecord]
  [DomainValidationRecord]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The timestamp when the certificate was last updated.
renewalSummary_updatedAt :: Lens.Lens' RenewalSummary (Prelude.Maybe Prelude.UTCTime)
renewalSummary_updatedAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> RenewalSummary -> f RenewalSummary
renewalSummary_updatedAt = (RenewalSummary -> Maybe POSIX)
-> (RenewalSummary -> Maybe POSIX -> RenewalSummary)
-> Lens RenewalSummary RenewalSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewalSummary' {Maybe POSIX
updatedAt :: Maybe POSIX
$sel:updatedAt:RenewalSummary' :: RenewalSummary -> Maybe POSIX
updatedAt} -> Maybe POSIX
updatedAt) (\s :: RenewalSummary
s@RenewalSummary' {} Maybe POSIX
a -> RenewalSummary
s {$sel:updatedAt:RenewalSummary' :: Maybe POSIX
updatedAt = Maybe POSIX
a} :: RenewalSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> RenewalSummary -> f RenewalSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> RenewalSummary
-> f RenewalSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The reason for the renewal status of the certificate.
renewalSummary_renewalStatusReason :: Lens.Lens' RenewalSummary (Prelude.Maybe Prelude.Text)
renewalSummary_renewalStatusReason :: (Maybe Text -> f (Maybe Text))
-> RenewalSummary -> f RenewalSummary
renewalSummary_renewalStatusReason = (RenewalSummary -> Maybe Text)
-> (RenewalSummary -> Maybe Text -> RenewalSummary)
-> Lens RenewalSummary RenewalSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewalSummary' {Maybe Text
renewalStatusReason :: Maybe Text
$sel:renewalStatusReason:RenewalSummary' :: RenewalSummary -> Maybe Text
renewalStatusReason} -> Maybe Text
renewalStatusReason) (\s :: RenewalSummary
s@RenewalSummary' {} Maybe Text
a -> RenewalSummary
s {$sel:renewalStatusReason:RenewalSummary' :: Maybe Text
renewalStatusReason = Maybe Text
a} :: RenewalSummary)

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 RenewalStatus
-> Maybe [DomainValidationRecord]
-> Maybe POSIX
-> Maybe Text
-> RenewalSummary
RenewalSummary'
            (Maybe RenewalStatus
 -> Maybe [DomainValidationRecord]
 -> Maybe POSIX
 -> Maybe Text
 -> RenewalSummary)
-> Parser (Maybe RenewalStatus)
-> Parser
     (Maybe [DomainValidationRecord]
      -> Maybe POSIX -> Maybe Text -> RenewalSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RenewalStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"renewalStatus")
            Parser
  (Maybe [DomainValidationRecord]
   -> Maybe POSIX -> Maybe Text -> RenewalSummary)
-> Parser (Maybe [DomainValidationRecord])
-> Parser (Maybe POSIX -> Maybe Text -> RenewalSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [DomainValidationRecord]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"domainValidationRecords"
                            Parser (Maybe (Maybe [DomainValidationRecord]))
-> Maybe [DomainValidationRecord]
-> Parser (Maybe [DomainValidationRecord])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DomainValidationRecord]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe POSIX -> Maybe Text -> RenewalSummary)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> RenewalSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"updatedAt")
            Parser (Maybe Text -> RenewalSummary)
-> Parser (Maybe Text) -> Parser RenewalSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"renewalStatusReason")
      )

instance Prelude.Hashable RenewalSummary

instance Prelude.NFData RenewalSummary