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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | An array of objects that describe the domain validation records of the
    -- certificate.
    RenewalSummary -> Maybe [DomainValidationRecord]
domainValidationRecords :: Prelude.Maybe [DomainValidationRecord],
    -- | 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,
    -- | The reason for the renewal status of the certificate.
    RenewalSummary -> Maybe Text
renewalStatusReason :: Prelude.Maybe Prelude.Text,
    -- | The timestamp when the certificate was last updated.
    RenewalSummary -> Maybe POSIX
updatedAt :: Prelude.Maybe Data.POSIX
  }
  deriving (RenewalSummary -> RenewalSummary -> Bool
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]
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
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. 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:
--
-- 'domainValidationRecords', 'renewalSummary_domainValidationRecords' - An array of objects that describe the domain validation records of the
-- certificate.
--
-- '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.
--
-- 'renewalStatusReason', 'renewalSummary_renewalStatusReason' - The reason for the renewal status of the certificate.
--
-- 'updatedAt', 'renewalSummary_updatedAt' - The timestamp when the certificate was last updated.
newRenewalSummary ::
  RenewalSummary
newRenewalSummary :: RenewalSummary
newRenewalSummary =
  RenewalSummary'
    { $sel:domainValidationRecords:RenewalSummary' :: Maybe [DomainValidationRecord]
domainValidationRecords =
        forall a. Maybe a
Prelude.Nothing,
      $sel:renewalStatus:RenewalSummary' :: Maybe RenewalStatus
renewalStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:renewalStatusReason:RenewalSummary' :: Maybe Text
renewalStatusReason = forall a. Maybe a
Prelude.Nothing,
      $sel:updatedAt:RenewalSummary' :: Maybe POSIX
updatedAt = forall a. Maybe a
Prelude.Nothing
    }

-- | An array of objects that describe the domain validation records of the
-- certificate.
renewalSummary_domainValidationRecords :: Lens.Lens' RenewalSummary (Prelude.Maybe [DomainValidationRecord])
renewalSummary_domainValidationRecords :: Lens' RenewalSummary (Maybe [DomainValidationRecord])
renewalSummary_domainValidationRecords = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' RenewalSummary (Maybe RenewalStatus)
renewalSummary_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)

-- | The reason for the renewal status of the certificate.
renewalSummary_renewalStatusReason :: Lens.Lens' RenewalSummary (Prelude.Maybe Prelude.Text)
renewalSummary_renewalStatusReason :: Lens' RenewalSummary (Maybe Text)
renewalSummary_renewalStatusReason = 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)

-- | The timestamp when the certificate was last updated.
renewalSummary_updatedAt :: Lens.Lens' RenewalSummary (Prelude.Maybe Prelude.UTCTime)
renewalSummary_updatedAt :: Lens' RenewalSummary (Maybe UTCTime)
renewalSummary_updatedAt = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON RenewalSummary where
  parseJSON :: Value -> Parser RenewalSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RenewalSummary"
      ( \Object
x ->
          Maybe [DomainValidationRecord]
-> Maybe RenewalStatus
-> Maybe Text
-> Maybe POSIX
-> RenewalSummary
RenewalSummary'
            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
"domainValidationRecords"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"renewalStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"renewalStatusReason")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"updatedAt")
      )

instance Prelude.Hashable RenewalSummary where
  hashWithSalt :: Int -> RenewalSummary -> Int
hashWithSalt Int
_salt RenewalSummary' {Maybe [DomainValidationRecord]
Maybe Text
Maybe POSIX
Maybe RenewalStatus
updatedAt :: Maybe POSIX
renewalStatusReason :: Maybe Text
renewalStatus :: Maybe RenewalStatus
domainValidationRecords :: Maybe [DomainValidationRecord]
$sel:updatedAt:RenewalSummary' :: RenewalSummary -> Maybe POSIX
$sel:renewalStatusReason:RenewalSummary' :: RenewalSummary -> Maybe Text
$sel:renewalStatus:RenewalSummary' :: RenewalSummary -> Maybe RenewalStatus
$sel:domainValidationRecords:RenewalSummary' :: RenewalSummary -> Maybe [DomainValidationRecord]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DomainValidationRecord]
domainValidationRecords
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RenewalStatus
renewalStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
renewalStatusReason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
updatedAt

instance Prelude.NFData RenewalSummary where
  rnf :: RenewalSummary -> ()
rnf RenewalSummary' {Maybe [DomainValidationRecord]
Maybe Text
Maybe POSIX
Maybe RenewalStatus
updatedAt :: Maybe POSIX
renewalStatusReason :: Maybe Text
renewalStatus :: Maybe RenewalStatus
domainValidationRecords :: Maybe [DomainValidationRecord]
$sel:updatedAt:RenewalSummary' :: RenewalSummary -> Maybe POSIX
$sel:renewalStatusReason:RenewalSummary' :: RenewalSummary -> Maybe Text
$sel:renewalStatus:RenewalSummary' :: RenewalSummary -> Maybe RenewalStatus
$sel:domainValidationRecords:RenewalSummary' :: RenewalSummary -> Maybe [DomainValidationRecord]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DomainValidationRecord]
domainValidationRecords
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RenewalStatus
renewalStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
renewalStatusReason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
updatedAt