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

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

-- | A certificate authority (CA) certificate for an Amazon Web Services
-- account.
--
-- /See:/ 'newCertificate' smart constructor.
data Certificate = Certificate'
  { -- | The Amazon Resource Name (ARN) for the certificate.
    --
    -- Example: @arn:aws:rds:us-east-1::cert:rds-ca-2019@
    Certificate -> Maybe Text
certificateArn :: Prelude.Maybe Prelude.Text,
    -- | The unique key that identifies a certificate.
    --
    -- Example: @rds-ca-2019@
    Certificate -> Maybe Text
certificateIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The type of the certificate.
    --
    -- Example: @CA@
    Certificate -> Maybe Text
certificateType :: Prelude.Maybe Prelude.Text,
    -- | The thumbprint of the certificate.
    Certificate -> Maybe Text
thumbprint :: Prelude.Maybe Prelude.Text,
    -- | The starting date-time from which the certificate is valid.
    --
    -- Example: @2019-07-31T17:57:09Z@
    Certificate -> Maybe ISO8601
validFrom :: Prelude.Maybe Data.ISO8601,
    -- | The date-time after which the certificate is no longer valid.
    --
    -- Example: @2024-07-31T17:57:09Z@
    Certificate -> Maybe ISO8601
validTill :: Prelude.Maybe Data.ISO8601
  }
  deriving (Certificate -> Certificate -> Bool
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]
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
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. 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:
--
-- 'certificateArn', 'certificate_certificateArn' - The Amazon Resource Name (ARN) for the certificate.
--
-- Example: @arn:aws:rds:us-east-1::cert:rds-ca-2019@
--
-- 'certificateIdentifier', 'certificate_certificateIdentifier' - The unique key that identifies a certificate.
--
-- Example: @rds-ca-2019@
--
-- 'certificateType', 'certificate_certificateType' - The type of the certificate.
--
-- Example: @CA@
--
-- 'thumbprint', 'certificate_thumbprint' - The thumbprint of the certificate.
--
-- 'validFrom', 'certificate_validFrom' - The starting date-time from which the certificate is valid.
--
-- Example: @2019-07-31T17:57:09Z@
--
-- 'validTill', 'certificate_validTill' - The date-time after which the certificate is no longer valid.
--
-- Example: @2024-07-31T17:57:09Z@
newCertificate ::
  Certificate
newCertificate :: Certificate
newCertificate =
  Certificate'
    { $sel:certificateArn:Certificate' :: Maybe Text
certificateArn = forall a. Maybe a
Prelude.Nothing,
      $sel:certificateIdentifier:Certificate' :: Maybe Text
certificateIdentifier = forall a. Maybe a
Prelude.Nothing,
      $sel:certificateType:Certificate' :: Maybe Text
certificateType = forall a. Maybe a
Prelude.Nothing,
      $sel:thumbprint:Certificate' :: Maybe Text
thumbprint = forall a. Maybe a
Prelude.Nothing,
      $sel:validFrom:Certificate' :: Maybe ISO8601
validFrom = forall a. Maybe a
Prelude.Nothing,
      $sel:validTill:Certificate' :: Maybe ISO8601
validTill = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) for the certificate.
--
-- Example: @arn:aws:rds:us-east-1::cert:rds-ca-2019@
certificate_certificateArn :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_certificateArn :: Lens' Certificate (Maybe Text)
certificate_certificateArn = 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)

-- | The unique key that identifies a certificate.
--
-- Example: @rds-ca-2019@
certificate_certificateIdentifier :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_certificateIdentifier :: Lens' Certificate (Maybe Text)
certificate_certificateIdentifier = 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 type of the certificate.
--
-- Example: @CA@
certificate_certificateType :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_certificateType :: Lens' Certificate (Maybe Text)
certificate_certificateType = 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)

-- | The thumbprint of the certificate.
certificate_thumbprint :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_thumbprint :: Lens' Certificate (Maybe Text)
certificate_thumbprint = 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-time from which the certificate is valid.
--
-- Example: @2019-07-31T17:57:09Z@
certificate_validFrom :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_validFrom :: Lens' Certificate (Maybe UTCTime)
certificate_validFrom = 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) 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

-- | The date-time after which the certificate is no longer valid.
--
-- Example: @2024-07-31T17:57:09Z@
certificate_validTill :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_validTill :: Lens' Certificate (Maybe UTCTime)
certificate_validTill = 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) 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.FromXML Certificate where
  parseXML :: [Node] -> Either String Certificate
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ISO8601
-> Maybe ISO8601
-> Certificate
Certificate'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CertificateArn")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CertificateIdentifier")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CertificateType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Thumbprint")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ValidFrom")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ValidTill")

instance Prelude.Hashable Certificate where
  hashWithSalt :: Int -> Certificate -> Int
hashWithSalt Int
_salt Certificate' {Maybe Text
Maybe ISO8601
validTill :: Maybe ISO8601
validFrom :: Maybe ISO8601
thumbprint :: Maybe Text
certificateType :: Maybe Text
certificateIdentifier :: Maybe Text
certificateArn :: Maybe Text
$sel:validTill:Certificate' :: Certificate -> Maybe ISO8601
$sel:validFrom:Certificate' :: Certificate -> Maybe ISO8601
$sel:thumbprint:Certificate' :: Certificate -> Maybe Text
$sel:certificateType:Certificate' :: Certificate -> Maybe Text
$sel:certificateIdentifier:Certificate' :: Certificate -> Maybe Text
$sel:certificateArn:Certificate' :: Certificate -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
certificateArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
certificateIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
certificateType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thumbprint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
validFrom
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
validTill

instance Prelude.NFData Certificate where
  rnf :: Certificate -> ()
rnf Certificate' {Maybe Text
Maybe ISO8601
validTill :: Maybe ISO8601
validFrom :: Maybe ISO8601
thumbprint :: Maybe Text
certificateType :: Maybe Text
certificateIdentifier :: Maybe Text
certificateArn :: Maybe Text
$sel:validTill:Certificate' :: Certificate -> Maybe ISO8601
$sel:validFrom:Certificate' :: Certificate -> Maybe ISO8601
$sel:thumbprint:Certificate' :: Certificate -> Maybe Text
$sel:certificateType:Certificate' :: Certificate -> Maybe Text
$sel:certificateIdentifier:Certificate' :: Certificate -> Maybe Text
$sel:certificateArn:Certificate' :: Certificate -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
certificateArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
certificateIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
certificateType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thumbprint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
validFrom
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
validTill