{-# 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.RDS.Types.Certificate
-- 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.RDS.Types.Certificate where

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

-- | A CA certificate for an Amazon Web Services account.
--
-- /See:/ 'newCertificate' smart constructor.
data Certificate = Certificate'
  { -- | The type of the certificate.
    Certificate -> Maybe Text
certificateType :: Prelude.Maybe Prelude.Text,
    -- | Whether there is an override for the default certificate identifier.
    Certificate -> Maybe Bool
customerOverride :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) for the certificate.
    Certificate -> Maybe Text
certificateArn :: Prelude.Maybe Prelude.Text,
    -- | If there is an override for the default certificate identifier, when the
    -- override expires.
    Certificate -> Maybe ISO8601
customerOverrideValidTill :: Prelude.Maybe Core.ISO8601,
    -- | The final date that the certificate continues to be valid.
    Certificate -> Maybe ISO8601
validTill :: Prelude.Maybe Core.ISO8601,
    -- | The unique key that identifies a certificate.
    Certificate -> Maybe Text
certificateIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The thumbprint of the certificate.
    Certificate -> Maybe Text
thumbprint :: Prelude.Maybe Prelude.Text,
    -- | The starting date from which the certificate is valid.
    Certificate -> Maybe ISO8601
validFrom :: Prelude.Maybe Core.ISO8601
  }
  deriving (Certificate -> Certificate -> Bool
(Certificate -> Certificate -> Bool)
-> (Certificate -> Certificate -> Bool) -> Eq Certificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Certificate -> Certificate -> Bool
$c/= :: Certificate -> Certificate -> Bool
== :: Certificate -> Certificate -> Bool
$c== :: Certificate -> Certificate -> Bool
Prelude.Eq, ReadPrec [Certificate]
ReadPrec Certificate
Int -> ReadS Certificate
ReadS [Certificate]
(Int -> ReadS Certificate)
-> ReadS [Certificate]
-> ReadPrec Certificate
-> ReadPrec [Certificate]
-> Read Certificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Certificate]
$creadListPrec :: ReadPrec [Certificate]
readPrec :: ReadPrec Certificate
$creadPrec :: ReadPrec Certificate
readList :: ReadS [Certificate]
$creadList :: ReadS [Certificate]
readsPrec :: Int -> ReadS Certificate
$creadsPrec :: Int -> ReadS Certificate
Prelude.Read, Int -> Certificate -> ShowS
[Certificate] -> ShowS
Certificate -> String
(Int -> Certificate -> ShowS)
-> (Certificate -> String)
-> ([Certificate] -> ShowS)
-> Show Certificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Certificate] -> ShowS
$cshowList :: [Certificate] -> ShowS
show :: Certificate -> String
$cshow :: Certificate -> String
showsPrec :: Int -> Certificate -> ShowS
$cshowsPrec :: Int -> Certificate -> ShowS
Prelude.Show, (forall x. Certificate -> Rep Certificate x)
-> (forall x. Rep Certificate x -> Certificate)
-> Generic Certificate
forall x. Rep Certificate x -> Certificate
forall x. Certificate -> Rep Certificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Certificate x -> Certificate
$cfrom :: forall x. Certificate -> Rep Certificate x
Prelude.Generic)

-- |
-- Create a value of 'Certificate' 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:
--
-- 'certificateType', 'certificate_certificateType' - The type of the certificate.
--
-- 'customerOverride', 'certificate_customerOverride' - Whether there is an override for the default certificate identifier.
--
-- 'certificateArn', 'certificate_certificateArn' - The Amazon Resource Name (ARN) for the certificate.
--
-- 'customerOverrideValidTill', 'certificate_customerOverrideValidTill' - If there is an override for the default certificate identifier, when the
-- override expires.
--
-- 'validTill', 'certificate_validTill' - The final date that the certificate continues to be valid.
--
-- 'certificateIdentifier', 'certificate_certificateIdentifier' - The unique key that identifies a certificate.
--
-- 'thumbprint', 'certificate_thumbprint' - The thumbprint of the certificate.
--
-- 'validFrom', 'certificate_validFrom' - The starting date from which the certificate is valid.
newCertificate ::
  Certificate
newCertificate :: Certificate
newCertificate =
  Certificate' :: Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe ISO8601
-> Maybe ISO8601
-> Maybe Text
-> Maybe Text
-> Maybe ISO8601
-> Certificate
Certificate'
    { $sel:certificateType:Certificate' :: Maybe Text
certificateType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:customerOverride:Certificate' :: Maybe Bool
customerOverride = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateArn:Certificate' :: Maybe Text
certificateArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:customerOverrideValidTill:Certificate' :: Maybe ISO8601
customerOverrideValidTill = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
      $sel:validTill:Certificate' :: Maybe ISO8601
validTill = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateIdentifier:Certificate' :: Maybe Text
certificateIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:thumbprint:Certificate' :: Maybe Text
thumbprint = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:validFrom:Certificate' :: Maybe ISO8601
validFrom = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of the certificate.
certificate_certificateType :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_certificateType :: (Maybe Text -> f (Maybe Text)) -> Certificate -> f Certificate
certificate_certificateType = (Certificate -> Maybe Text)
-> (Certificate -> Maybe Text -> Certificate)
-> Lens Certificate Certificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Text
certificateType :: Maybe Text
$sel:certificateType:Certificate' :: Certificate -> Maybe Text
certificateType} -> Maybe Text
certificateType) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:certificateType:Certificate' :: Maybe Text
certificateType = Maybe Text
a} :: Certificate)

-- | Whether there is an override for the default certificate identifier.
certificate_customerOverride :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Bool)
certificate_customerOverride :: (Maybe Bool -> f (Maybe Bool)) -> Certificate -> f Certificate
certificate_customerOverride = (Certificate -> Maybe Bool)
-> (Certificate -> Maybe Bool -> Certificate)
-> Lens Certificate Certificate (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Bool
customerOverride :: Maybe Bool
$sel:customerOverride:Certificate' :: Certificate -> Maybe Bool
customerOverride} -> Maybe Bool
customerOverride) (\s :: Certificate
s@Certificate' {} Maybe Bool
a -> Certificate
s {$sel:customerOverride:Certificate' :: Maybe Bool
customerOverride = Maybe Bool
a} :: Certificate)

-- | The Amazon Resource Name (ARN) for the certificate.
certificate_certificateArn :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_certificateArn :: (Maybe Text -> f (Maybe Text)) -> Certificate -> f Certificate
certificate_certificateArn = (Certificate -> Maybe Text)
-> (Certificate -> Maybe Text -> Certificate)
-> Lens Certificate Certificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Text
certificateArn :: Maybe Text
$sel:certificateArn:Certificate' :: Certificate -> Maybe Text
certificateArn} -> Maybe Text
certificateArn) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:certificateArn:Certificate' :: Maybe Text
certificateArn = Maybe Text
a} :: Certificate)

-- | If there is an override for the default certificate identifier, when the
-- override expires.
certificate_customerOverrideValidTill :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_customerOverrideValidTill :: (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate -> f Certificate
certificate_customerOverrideValidTill = (Certificate -> Maybe ISO8601)
-> (Certificate -> Maybe ISO8601 -> Certificate)
-> Lens Certificate Certificate (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe ISO8601
customerOverrideValidTill :: Maybe ISO8601
$sel:customerOverrideValidTill:Certificate' :: Certificate -> Maybe ISO8601
customerOverrideValidTill} -> Maybe ISO8601
customerOverrideValidTill) (\s :: Certificate
s@Certificate' {} Maybe ISO8601
a -> Certificate
s {$sel:customerOverrideValidTill:Certificate' :: Maybe ISO8601
customerOverrideValidTill = Maybe ISO8601
a} :: Certificate) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> Certificate -> f Certificate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate
-> f Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The final date that the certificate continues to be valid.
certificate_validTill :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_validTill :: (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate -> f Certificate
certificate_validTill = (Certificate -> Maybe ISO8601)
-> (Certificate -> Maybe ISO8601 -> Certificate)
-> Lens Certificate Certificate (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe ISO8601
validTill :: Maybe ISO8601
$sel:validTill:Certificate' :: Certificate -> Maybe ISO8601
validTill} -> Maybe ISO8601
validTill) (\s :: Certificate
s@Certificate' {} Maybe ISO8601
a -> Certificate
s {$sel:validTill:Certificate' :: Maybe ISO8601
validTill = Maybe ISO8601
a} :: Certificate) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> Certificate -> f Certificate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate
-> f Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The unique key that identifies a certificate.
certificate_certificateIdentifier :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_certificateIdentifier :: (Maybe Text -> f (Maybe Text)) -> Certificate -> f Certificate
certificate_certificateIdentifier = (Certificate -> Maybe Text)
-> (Certificate -> Maybe Text -> Certificate)
-> Lens Certificate Certificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Text
certificateIdentifier :: Maybe Text
$sel:certificateIdentifier:Certificate' :: Certificate -> Maybe Text
certificateIdentifier} -> Maybe Text
certificateIdentifier) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:certificateIdentifier:Certificate' :: Maybe Text
certificateIdentifier = Maybe Text
a} :: Certificate)

-- | The thumbprint of the certificate.
certificate_thumbprint :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_thumbprint :: (Maybe Text -> f (Maybe Text)) -> Certificate -> f Certificate
certificate_thumbprint = (Certificate -> Maybe Text)
-> (Certificate -> Maybe Text -> Certificate)
-> Lens Certificate Certificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Text
thumbprint :: Maybe Text
$sel:thumbprint:Certificate' :: Certificate -> Maybe Text
thumbprint} -> Maybe Text
thumbprint) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:thumbprint:Certificate' :: Maybe Text
thumbprint = Maybe Text
a} :: Certificate)

-- | The starting date from which the certificate is valid.
certificate_validFrom :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_validFrom :: (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate -> f Certificate
certificate_validFrom = (Certificate -> Maybe ISO8601)
-> (Certificate -> Maybe ISO8601 -> Certificate)
-> Lens Certificate Certificate (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe ISO8601
validFrom :: Maybe ISO8601
$sel:validFrom:Certificate' :: Certificate -> Maybe ISO8601
validFrom} -> Maybe ISO8601
validFrom) (\s :: Certificate
s@Certificate' {} Maybe ISO8601
a -> Certificate
s {$sel:validFrom:Certificate' :: Maybe ISO8601
validFrom = Maybe ISO8601
a} :: Certificate) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> Certificate -> f Certificate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate
-> f Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromXML Certificate where
  parseXML :: [Node] -> Either String Certificate
parseXML [Node]
x =
    Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe ISO8601
-> Maybe ISO8601
-> Maybe Text
-> Maybe Text
-> Maybe ISO8601
-> Certificate
Certificate'
      (Maybe Text
 -> Maybe Bool
 -> Maybe Text
 -> Maybe ISO8601
 -> Maybe ISO8601
 -> Maybe Text
 -> Maybe Text
 -> Maybe ISO8601
 -> Certificate)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Bool
      -> Maybe Text
      -> Maybe ISO8601
      -> Maybe ISO8601
      -> Maybe Text
      -> Maybe Text
      -> Maybe ISO8601
      -> Certificate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CertificateType")
      Either
  String
  (Maybe Bool
   -> Maybe Text
   -> Maybe ISO8601
   -> Maybe ISO8601
   -> Maybe Text
   -> Maybe Text
   -> Maybe ISO8601
   -> Certificate)
-> Either String (Maybe Bool)
-> Either
     String
     (Maybe Text
      -> Maybe ISO8601
      -> Maybe ISO8601
      -> Maybe Text
      -> Maybe Text
      -> Maybe ISO8601
      -> Certificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CustomerOverride")
      Either
  String
  (Maybe Text
   -> Maybe ISO8601
   -> Maybe ISO8601
   -> Maybe Text
   -> Maybe Text
   -> Maybe ISO8601
   -> Certificate)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe ISO8601
      -> Maybe ISO8601
      -> Maybe Text
      -> Maybe Text
      -> Maybe ISO8601
      -> Certificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CertificateArn")
      Either
  String
  (Maybe ISO8601
   -> Maybe ISO8601
   -> Maybe Text
   -> Maybe Text
   -> Maybe ISO8601
   -> Certificate)
-> Either String (Maybe ISO8601)
-> Either
     String
     (Maybe ISO8601
      -> Maybe Text -> Maybe Text -> Maybe ISO8601 -> Certificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CustomerOverrideValidTill")
      Either
  String
  (Maybe ISO8601
   -> Maybe Text -> Maybe Text -> Maybe ISO8601 -> Certificate)
-> Either String (Maybe ISO8601)
-> Either
     String (Maybe Text -> Maybe Text -> Maybe ISO8601 -> Certificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ValidTill")
      Either
  String (Maybe Text -> Maybe Text -> Maybe ISO8601 -> Certificate)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe ISO8601 -> Certificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CertificateIdentifier")
      Either String (Maybe Text -> Maybe ISO8601 -> Certificate)
-> Either String (Maybe Text)
-> Either String (Maybe ISO8601 -> Certificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Thumbprint")
      Either String (Maybe ISO8601 -> Certificate)
-> Either String (Maybe ISO8601) -> Either String Certificate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ValidFrom")

instance Prelude.Hashable Certificate

instance Prelude.NFData Certificate