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

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.Types.CertificateState
import Amazonka.DirectoryService.Types.CertificateType
import Amazonka.DirectoryService.Types.ClientCertAuthSettings
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the certificate.
--
-- /See:/ 'newCertificate' smart constructor.
data Certificate = Certificate'
  { -- | A @ClientCertAuthSettings@ object that contains client certificate
    -- authentication settings.
    Certificate -> Maybe ClientCertAuthSettings
clientCertAuthSettings :: Prelude.Maybe ClientCertAuthSettings,
    -- | The state of the certificate.
    Certificate -> Maybe CertificateState
state :: Prelude.Maybe CertificateState,
    -- | The common name for the certificate.
    Certificate -> Maybe Text
commonName :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the certificate.
    Certificate -> Maybe Text
certificateId :: Prelude.Maybe Prelude.Text,
    -- | The date and time when the certificate will expire.
    Certificate -> Maybe POSIX
expiryDateTime :: Prelude.Maybe Core.POSIX,
    -- | The date and time that the certificate was registered.
    Certificate -> Maybe POSIX
registeredDateTime :: Prelude.Maybe Core.POSIX,
    -- | The function that the registered certificate performs. Valid values
    -- include @ClientLDAPS@ or @ClientCertAuth@. The default value is
    -- @ClientLDAPS@.
    Certificate -> Maybe CertificateType
type' :: Prelude.Maybe CertificateType,
    -- | Describes a state change for the certificate.
    Certificate -> Maybe Text
stateReason :: Prelude.Maybe Prelude.Text
  }
  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:
--
-- 'clientCertAuthSettings', 'certificate_clientCertAuthSettings' - A @ClientCertAuthSettings@ object that contains client certificate
-- authentication settings.
--
-- 'state', 'certificate_state' - The state of the certificate.
--
-- 'commonName', 'certificate_commonName' - The common name for the certificate.
--
-- 'certificateId', 'certificate_certificateId' - The identifier of the certificate.
--
-- 'expiryDateTime', 'certificate_expiryDateTime' - The date and time when the certificate will expire.
--
-- 'registeredDateTime', 'certificate_registeredDateTime' - The date and time that the certificate was registered.
--
-- 'type'', 'certificate_type' - The function that the registered certificate performs. Valid values
-- include @ClientLDAPS@ or @ClientCertAuth@. The default value is
-- @ClientLDAPS@.
--
-- 'stateReason', 'certificate_stateReason' - Describes a state change for the certificate.
newCertificate ::
  Certificate
newCertificate :: Certificate
newCertificate =
  Certificate' :: Maybe ClientCertAuthSettings
-> Maybe CertificateState
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe CertificateType
-> Maybe Text
-> Certificate
Certificate'
    { $sel:clientCertAuthSettings:Certificate' :: Maybe ClientCertAuthSettings
clientCertAuthSettings =
        Maybe ClientCertAuthSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:state:Certificate' :: Maybe CertificateState
state = Maybe CertificateState
forall a. Maybe a
Prelude.Nothing,
      $sel:commonName:Certificate' :: Maybe Text
commonName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateId:Certificate' :: Maybe Text
certificateId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expiryDateTime:Certificate' :: Maybe POSIX
expiryDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:registeredDateTime:Certificate' :: Maybe POSIX
registeredDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Certificate' :: Maybe CertificateType
type' = Maybe CertificateType
forall a. Maybe a
Prelude.Nothing,
      $sel:stateReason:Certificate' :: Maybe Text
stateReason = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A @ClientCertAuthSettings@ object that contains client certificate
-- authentication settings.
certificate_clientCertAuthSettings :: Lens.Lens' Certificate (Prelude.Maybe ClientCertAuthSettings)
certificate_clientCertAuthSettings :: (Maybe ClientCertAuthSettings -> f (Maybe ClientCertAuthSettings))
-> Certificate -> f Certificate
certificate_clientCertAuthSettings = (Certificate -> Maybe ClientCertAuthSettings)
-> (Certificate -> Maybe ClientCertAuthSettings -> Certificate)
-> Lens
     Certificate
     Certificate
     (Maybe ClientCertAuthSettings)
     (Maybe ClientCertAuthSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe ClientCertAuthSettings
clientCertAuthSettings :: Maybe ClientCertAuthSettings
$sel:clientCertAuthSettings:Certificate' :: Certificate -> Maybe ClientCertAuthSettings
clientCertAuthSettings} -> Maybe ClientCertAuthSettings
clientCertAuthSettings) (\s :: Certificate
s@Certificate' {} Maybe ClientCertAuthSettings
a -> Certificate
s {$sel:clientCertAuthSettings:Certificate' :: Maybe ClientCertAuthSettings
clientCertAuthSettings = Maybe ClientCertAuthSettings
a} :: Certificate)

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

-- | The common name for the certificate.
certificate_commonName :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_commonName :: (Maybe Text -> f (Maybe Text)) -> Certificate -> f Certificate
certificate_commonName = (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
commonName :: Maybe Text
$sel:commonName:Certificate' :: Certificate -> Maybe Text
commonName} -> Maybe Text
commonName) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:commonName:Certificate' :: Maybe Text
commonName = Maybe Text
a} :: Certificate)

-- | The identifier of the certificate.
certificate_certificateId :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_certificateId :: (Maybe Text -> f (Maybe Text)) -> Certificate -> f Certificate
certificate_certificateId = (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
certificateId :: Maybe Text
$sel:certificateId:Certificate' :: Certificate -> Maybe Text
certificateId} -> Maybe Text
certificateId) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:certificateId:Certificate' :: Maybe Text
certificateId = Maybe Text
a} :: Certificate)

-- | The date and time when the certificate will expire.
certificate_expiryDateTime :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_expiryDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate -> f Certificate
certificate_expiryDateTime = (Certificate -> Maybe POSIX)
-> (Certificate -> Maybe POSIX -> Certificate)
-> Lens Certificate Certificate (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe POSIX
expiryDateTime :: Maybe POSIX
$sel:expiryDateTime:Certificate' :: Certificate -> Maybe POSIX
expiryDateTime} -> Maybe POSIX
expiryDateTime) (\s :: Certificate
s@Certificate' {} Maybe POSIX
a -> Certificate
s {$sel:expiryDateTime:Certificate' :: Maybe POSIX
expiryDateTime = Maybe POSIX
a} :: Certificate) ((Maybe POSIX -> f (Maybe POSIX)) -> Certificate -> f Certificate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate
-> f Certificate
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 date and time that the certificate was registered.
certificate_registeredDateTime :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_registeredDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate -> f Certificate
certificate_registeredDateTime = (Certificate -> Maybe POSIX)
-> (Certificate -> Maybe POSIX -> Certificate)
-> Lens Certificate Certificate (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe POSIX
registeredDateTime :: Maybe POSIX
$sel:registeredDateTime:Certificate' :: Certificate -> Maybe POSIX
registeredDateTime} -> Maybe POSIX
registeredDateTime) (\s :: Certificate
s@Certificate' {} Maybe POSIX
a -> Certificate
s {$sel:registeredDateTime:Certificate' :: Maybe POSIX
registeredDateTime = Maybe POSIX
a} :: Certificate) ((Maybe POSIX -> f (Maybe POSIX)) -> Certificate -> f Certificate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Certificate
-> f Certificate
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 function that the registered certificate performs. Valid values
-- include @ClientLDAPS@ or @ClientCertAuth@. The default value is
-- @ClientLDAPS@.
certificate_type :: Lens.Lens' Certificate (Prelude.Maybe CertificateType)
certificate_type :: (Maybe CertificateType -> f (Maybe CertificateType))
-> Certificate -> f Certificate
certificate_type = (Certificate -> Maybe CertificateType)
-> (Certificate -> Maybe CertificateType -> Certificate)
-> Lens
     Certificate
     Certificate
     (Maybe CertificateType)
     (Maybe CertificateType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe CertificateType
type' :: Maybe CertificateType
$sel:type':Certificate' :: Certificate -> Maybe CertificateType
type'} -> Maybe CertificateType
type') (\s :: Certificate
s@Certificate' {} Maybe CertificateType
a -> Certificate
s {$sel:type':Certificate' :: Maybe CertificateType
type' = Maybe CertificateType
a} :: Certificate)

-- | Describes a state change for the certificate.
certificate_stateReason :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_stateReason :: (Maybe Text -> f (Maybe Text)) -> Certificate -> f Certificate
certificate_stateReason = (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
stateReason :: Maybe Text
$sel:stateReason:Certificate' :: Certificate -> Maybe Text
stateReason} -> Maybe Text
stateReason) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:stateReason:Certificate' :: Maybe Text
stateReason = Maybe Text
a} :: Certificate)

instance Core.FromJSON Certificate where
  parseJSON :: Value -> Parser Certificate
parseJSON =
    String
-> (Object -> Parser Certificate) -> Value -> Parser Certificate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Certificate"
      ( \Object
x ->
          Maybe ClientCertAuthSettings
-> Maybe CertificateState
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe CertificateType
-> Maybe Text
-> Certificate
Certificate'
            (Maybe ClientCertAuthSettings
 -> Maybe CertificateState
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe POSIX
 -> Maybe CertificateType
 -> Maybe Text
 -> Certificate)
-> Parser (Maybe ClientCertAuthSettings)
-> Parser
     (Maybe CertificateState
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe POSIX
      -> Maybe CertificateType
      -> Maybe Text
      -> Certificate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ClientCertAuthSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClientCertAuthSettings")
            Parser
  (Maybe CertificateState
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe POSIX
   -> Maybe CertificateType
   -> Maybe Text
   -> Certificate)
-> Parser (Maybe CertificateState)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe POSIX
      -> Maybe CertificateType
      -> Maybe Text
      -> Certificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CertificateState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe POSIX
   -> Maybe CertificateType
   -> Maybe Text
   -> Certificate)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe POSIX
      -> Maybe CertificateType
      -> Maybe Text
      -> Certificate)
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
"CommonName")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe POSIX
   -> Maybe CertificateType
   -> Maybe Text
   -> Certificate)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe POSIX
      -> Maybe CertificateType
      -> Maybe Text
      -> Certificate)
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
"CertificateId")
            Parser
  (Maybe POSIX
   -> Maybe POSIX
   -> Maybe CertificateType
   -> Maybe Text
   -> Certificate)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX -> Maybe CertificateType -> Maybe Text -> Certificate)
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
"ExpiryDateTime")
            Parser
  (Maybe POSIX -> Maybe CertificateType -> Maybe Text -> Certificate)
-> Parser (Maybe POSIX)
-> Parser (Maybe CertificateType -> Maybe Text -> Certificate)
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
"RegisteredDateTime")
            Parser (Maybe CertificateType -> Maybe Text -> Certificate)
-> Parser (Maybe CertificateType)
-> Parser (Maybe Text -> Certificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CertificateType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe Text -> Certificate)
-> Parser (Maybe Text) -> Parser Certificate
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
"StateReason")
      )

instance Prelude.Hashable Certificate

instance Prelude.NFData Certificate