{-# 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.CertificateInfo
-- 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.CertificateInfo where

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

-- | Contains general information about a certificate.
--
-- /See:/ 'newCertificateInfo' smart constructor.
data CertificateInfo = CertificateInfo'
  { -- | The state of the certificate.
    CertificateInfo -> Maybe CertificateState
state :: Prelude.Maybe CertificateState,
    -- | The common name for the certificate.
    CertificateInfo -> Maybe Text
commonName :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the certificate.
    CertificateInfo -> Maybe Text
certificateId :: Prelude.Maybe Prelude.Text,
    -- | The date and time when the certificate will expire.
    CertificateInfo -> Maybe POSIX
expiryDateTime :: Prelude.Maybe Core.POSIX,
    -- | The function that the registered certificate performs. Valid values
    -- include @ClientLDAPS@ or @ClientCertAuth@. The default value is
    -- @ClientLDAPS@.
    CertificateInfo -> Maybe CertificateType
type' :: Prelude.Maybe CertificateType
  }
  deriving (CertificateInfo -> CertificateInfo -> Bool
(CertificateInfo -> CertificateInfo -> Bool)
-> (CertificateInfo -> CertificateInfo -> Bool)
-> Eq CertificateInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CertificateInfo -> CertificateInfo -> Bool
$c/= :: CertificateInfo -> CertificateInfo -> Bool
== :: CertificateInfo -> CertificateInfo -> Bool
$c== :: CertificateInfo -> CertificateInfo -> Bool
Prelude.Eq, ReadPrec [CertificateInfo]
ReadPrec CertificateInfo
Int -> ReadS CertificateInfo
ReadS [CertificateInfo]
(Int -> ReadS CertificateInfo)
-> ReadS [CertificateInfo]
-> ReadPrec CertificateInfo
-> ReadPrec [CertificateInfo]
-> Read CertificateInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CertificateInfo]
$creadListPrec :: ReadPrec [CertificateInfo]
readPrec :: ReadPrec CertificateInfo
$creadPrec :: ReadPrec CertificateInfo
readList :: ReadS [CertificateInfo]
$creadList :: ReadS [CertificateInfo]
readsPrec :: Int -> ReadS CertificateInfo
$creadsPrec :: Int -> ReadS CertificateInfo
Prelude.Read, Int -> CertificateInfo -> ShowS
[CertificateInfo] -> ShowS
CertificateInfo -> String
(Int -> CertificateInfo -> ShowS)
-> (CertificateInfo -> String)
-> ([CertificateInfo] -> ShowS)
-> Show CertificateInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CertificateInfo] -> ShowS
$cshowList :: [CertificateInfo] -> ShowS
show :: CertificateInfo -> String
$cshow :: CertificateInfo -> String
showsPrec :: Int -> CertificateInfo -> ShowS
$cshowsPrec :: Int -> CertificateInfo -> ShowS
Prelude.Show, (forall x. CertificateInfo -> Rep CertificateInfo x)
-> (forall x. Rep CertificateInfo x -> CertificateInfo)
-> Generic CertificateInfo
forall x. Rep CertificateInfo x -> CertificateInfo
forall x. CertificateInfo -> Rep CertificateInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CertificateInfo x -> CertificateInfo
$cfrom :: forall x. CertificateInfo -> Rep CertificateInfo x
Prelude.Generic)

-- |
-- Create a value of 'CertificateInfo' 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:
--
-- 'state', 'certificateInfo_state' - The state of the certificate.
--
-- 'commonName', 'certificateInfo_commonName' - The common name for the certificate.
--
-- 'certificateId', 'certificateInfo_certificateId' - The identifier of the certificate.
--
-- 'expiryDateTime', 'certificateInfo_expiryDateTime' - The date and time when the certificate will expire.
--
-- 'type'', 'certificateInfo_type' - The function that the registered certificate performs. Valid values
-- include @ClientLDAPS@ or @ClientCertAuth@. The default value is
-- @ClientLDAPS@.
newCertificateInfo ::
  CertificateInfo
newCertificateInfo :: CertificateInfo
newCertificateInfo =
  CertificateInfo' :: Maybe CertificateState
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe CertificateType
-> CertificateInfo
CertificateInfo'
    { $sel:state:CertificateInfo' :: Maybe CertificateState
state = Maybe CertificateState
forall a. Maybe a
Prelude.Nothing,
      $sel:commonName:CertificateInfo' :: Maybe Text
commonName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateId:CertificateInfo' :: Maybe Text
certificateId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expiryDateTime:CertificateInfo' :: Maybe POSIX
expiryDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:type':CertificateInfo' :: Maybe CertificateType
type' = Maybe CertificateType
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The common name for the certificate.
certificateInfo_commonName :: Lens.Lens' CertificateInfo (Prelude.Maybe Prelude.Text)
certificateInfo_commonName :: (Maybe Text -> f (Maybe Text))
-> CertificateInfo -> f CertificateInfo
certificateInfo_commonName = (CertificateInfo -> Maybe Text)
-> (CertificateInfo -> Maybe Text -> CertificateInfo)
-> Lens CertificateInfo CertificateInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CertificateInfo' {Maybe Text
commonName :: Maybe Text
$sel:commonName:CertificateInfo' :: CertificateInfo -> Maybe Text
commonName} -> Maybe Text
commonName) (\s :: CertificateInfo
s@CertificateInfo' {} Maybe Text
a -> CertificateInfo
s {$sel:commonName:CertificateInfo' :: Maybe Text
commonName = Maybe Text
a} :: CertificateInfo)

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

-- | The date and time when the certificate will expire.
certificateInfo_expiryDateTime :: Lens.Lens' CertificateInfo (Prelude.Maybe Prelude.UTCTime)
certificateInfo_expiryDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CertificateInfo -> f CertificateInfo
certificateInfo_expiryDateTime = (CertificateInfo -> Maybe POSIX)
-> (CertificateInfo -> Maybe POSIX -> CertificateInfo)
-> Lens CertificateInfo CertificateInfo (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CertificateInfo' {Maybe POSIX
expiryDateTime :: Maybe POSIX
$sel:expiryDateTime:CertificateInfo' :: CertificateInfo -> Maybe POSIX
expiryDateTime} -> Maybe POSIX
expiryDateTime) (\s :: CertificateInfo
s@CertificateInfo' {} Maybe POSIX
a -> CertificateInfo
s {$sel:expiryDateTime:CertificateInfo' :: Maybe POSIX
expiryDateTime = Maybe POSIX
a} :: CertificateInfo) ((Maybe POSIX -> f (Maybe POSIX))
 -> CertificateInfo -> f CertificateInfo)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CertificateInfo
-> f CertificateInfo
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@.
certificateInfo_type :: Lens.Lens' CertificateInfo (Prelude.Maybe CertificateType)
certificateInfo_type :: (Maybe CertificateType -> f (Maybe CertificateType))
-> CertificateInfo -> f CertificateInfo
certificateInfo_type = (CertificateInfo -> Maybe CertificateType)
-> (CertificateInfo -> Maybe CertificateType -> CertificateInfo)
-> Lens
     CertificateInfo
     CertificateInfo
     (Maybe CertificateType)
     (Maybe CertificateType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CertificateInfo' {Maybe CertificateType
type' :: Maybe CertificateType
$sel:type':CertificateInfo' :: CertificateInfo -> Maybe CertificateType
type'} -> Maybe CertificateType
type') (\s :: CertificateInfo
s@CertificateInfo' {} Maybe CertificateType
a -> CertificateInfo
s {$sel:type':CertificateInfo' :: Maybe CertificateType
type' = Maybe CertificateType
a} :: CertificateInfo)

instance Core.FromJSON CertificateInfo where
  parseJSON :: Value -> Parser CertificateInfo
parseJSON =
    String
-> (Object -> Parser CertificateInfo)
-> Value
-> Parser CertificateInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CertificateInfo"
      ( \Object
x ->
          Maybe CertificateState
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe CertificateType
-> CertificateInfo
CertificateInfo'
            (Maybe CertificateState
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe CertificateType
 -> CertificateInfo)
-> Parser (Maybe CertificateState)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe CertificateType
      -> CertificateInfo)
forall (f :: * -> *) a b. Functor 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 CertificateType
   -> CertificateInfo)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe POSIX -> Maybe CertificateType -> CertificateInfo)
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 CertificateType -> CertificateInfo)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe CertificateType -> CertificateInfo)
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 CertificateType -> CertificateInfo)
-> Parser (Maybe POSIX)
-> Parser (Maybe CertificateType -> CertificateInfo)
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 CertificateType -> CertificateInfo)
-> Parser (Maybe CertificateType) -> Parser CertificateInfo
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")
      )

instance Prelude.Hashable CertificateInfo

instance Prelude.NFData CertificateInfo