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

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

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

-- | The identifier of the certificate.
certificate_certificateId :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_certificateId :: Lens' Certificate (Maybe Text)
certificate_certificateId = 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)

-- | A @ClientCertAuthSettings@ object that contains client certificate
-- authentication settings.
certificate_clientCertAuthSettings :: Lens.Lens' Certificate (Prelude.Maybe ClientCertAuthSettings)
certificate_clientCertAuthSettings :: Lens' Certificate (Maybe ClientCertAuthSettings)
certificate_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 common name for the certificate.
certificate_commonName :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_commonName :: Lens' Certificate (Maybe Text)
certificate_commonName = 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 date and time when the certificate will expire.
certificate_expiryDateTime :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_expiryDateTime :: Lens' Certificate (Maybe UTCTime)
certificate_expiryDateTime = 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) 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 and time that the certificate was registered.
certificate_registeredDateTime :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_registeredDateTime :: Lens' Certificate (Maybe UTCTime)
certificate_registeredDateTime = 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) 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 state of the certificate.
certificate_state :: Lens.Lens' Certificate (Prelude.Maybe CertificateState)
certificate_state :: Lens' Certificate (Maybe CertificateState)
certificate_state = 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)

-- | Describes a state change for the certificate.
certificate_stateReason :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_stateReason :: Lens' Certificate (Maybe Text)
certificate_stateReason = 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)

-- | 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 :: Lens' Certificate (Maybe CertificateType)
certificate_type = 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)

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

instance Prelude.Hashable Certificate where
  hashWithSalt :: Int -> Certificate -> Int
hashWithSalt Int
_salt Certificate' {Maybe Text
Maybe POSIX
Maybe CertificateState
Maybe CertificateType
Maybe ClientCertAuthSettings
type' :: Maybe CertificateType
stateReason :: Maybe Text
state :: Maybe CertificateState
registeredDateTime :: Maybe POSIX
expiryDateTime :: Maybe POSIX
commonName :: Maybe Text
clientCertAuthSettings :: Maybe ClientCertAuthSettings
certificateId :: Maybe Text
$sel:type':Certificate' :: Certificate -> Maybe CertificateType
$sel:stateReason:Certificate' :: Certificate -> Maybe Text
$sel:state:Certificate' :: Certificate -> Maybe CertificateState
$sel:registeredDateTime:Certificate' :: Certificate -> Maybe POSIX
$sel:expiryDateTime:Certificate' :: Certificate -> Maybe POSIX
$sel:commonName:Certificate' :: Certificate -> Maybe Text
$sel:clientCertAuthSettings:Certificate' :: Certificate -> Maybe ClientCertAuthSettings
$sel:certificateId:Certificate' :: Certificate -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
certificateId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ClientCertAuthSettings
clientCertAuthSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
commonName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
expiryDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
registeredDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CertificateState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stateReason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CertificateType
type'

instance Prelude.NFData Certificate where
  rnf :: Certificate -> ()
rnf Certificate' {Maybe Text
Maybe POSIX
Maybe CertificateState
Maybe CertificateType
Maybe ClientCertAuthSettings
type' :: Maybe CertificateType
stateReason :: Maybe Text
state :: Maybe CertificateState
registeredDateTime :: Maybe POSIX
expiryDateTime :: Maybe POSIX
commonName :: Maybe Text
clientCertAuthSettings :: Maybe ClientCertAuthSettings
certificateId :: Maybe Text
$sel:type':Certificate' :: Certificate -> Maybe CertificateType
$sel:stateReason:Certificate' :: Certificate -> Maybe Text
$sel:state:Certificate' :: Certificate -> Maybe CertificateState
$sel:registeredDateTime:Certificate' :: Certificate -> Maybe POSIX
$sel:expiryDateTime:Certificate' :: Certificate -> Maybe POSIX
$sel:commonName:Certificate' :: Certificate -> Maybe Text
$sel:clientCertAuthSettings:Certificate' :: Certificate -> Maybe ClientCertAuthSettings
$sel:certificateId:Certificate' :: Certificate -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
certificateId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ClientCertAuthSettings
clientCertAuthSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
commonName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
expiryDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
registeredDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CertificateState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stateReason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CertificateType
type'