{-# 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.IoT.Types.CACertificate
-- 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.IoT.Types.CACertificate where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.CACertificateStatus
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A CA certificate.
--
-- /See:/ 'newCACertificate' smart constructor.
data CACertificate = CACertificate'
  { -- | The status of the CA certificate.
    --
    -- The status value REGISTER_INACTIVE is deprecated and should not be used.
    CACertificate -> Maybe CACertificateStatus
status :: Prelude.Maybe CACertificateStatus,
    -- | The ARN of the CA certificate.
    CACertificate -> Maybe Text
certificateArn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the CA certificate.
    CACertificate -> Maybe Text
certificateId :: Prelude.Maybe Prelude.Text,
    -- | The date the CA certificate was created.
    CACertificate -> Maybe POSIX
creationDate :: Prelude.Maybe Core.POSIX
  }
  deriving (CACertificate -> CACertificate -> Bool
(CACertificate -> CACertificate -> Bool)
-> (CACertificate -> CACertificate -> Bool) -> Eq CACertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CACertificate -> CACertificate -> Bool
$c/= :: CACertificate -> CACertificate -> Bool
== :: CACertificate -> CACertificate -> Bool
$c== :: CACertificate -> CACertificate -> Bool
Prelude.Eq, ReadPrec [CACertificate]
ReadPrec CACertificate
Int -> ReadS CACertificate
ReadS [CACertificate]
(Int -> ReadS CACertificate)
-> ReadS [CACertificate]
-> ReadPrec CACertificate
-> ReadPrec [CACertificate]
-> Read CACertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CACertificate]
$creadListPrec :: ReadPrec [CACertificate]
readPrec :: ReadPrec CACertificate
$creadPrec :: ReadPrec CACertificate
readList :: ReadS [CACertificate]
$creadList :: ReadS [CACertificate]
readsPrec :: Int -> ReadS CACertificate
$creadsPrec :: Int -> ReadS CACertificate
Prelude.Read, Int -> CACertificate -> ShowS
[CACertificate] -> ShowS
CACertificate -> String
(Int -> CACertificate -> ShowS)
-> (CACertificate -> String)
-> ([CACertificate] -> ShowS)
-> Show CACertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CACertificate] -> ShowS
$cshowList :: [CACertificate] -> ShowS
show :: CACertificate -> String
$cshow :: CACertificate -> String
showsPrec :: Int -> CACertificate -> ShowS
$cshowsPrec :: Int -> CACertificate -> ShowS
Prelude.Show, (forall x. CACertificate -> Rep CACertificate x)
-> (forall x. Rep CACertificate x -> CACertificate)
-> Generic CACertificate
forall x. Rep CACertificate x -> CACertificate
forall x. CACertificate -> Rep CACertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CACertificate x -> CACertificate
$cfrom :: forall x. CACertificate -> Rep CACertificate x
Prelude.Generic)

-- |
-- Create a value of 'CACertificate' 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:
--
-- 'status', 'cACertificate_status' - The status of the CA certificate.
--
-- The status value REGISTER_INACTIVE is deprecated and should not be used.
--
-- 'certificateArn', 'cACertificate_certificateArn' - The ARN of the CA certificate.
--
-- 'certificateId', 'cACertificate_certificateId' - The ID of the CA certificate.
--
-- 'creationDate', 'cACertificate_creationDate' - The date the CA certificate was created.
newCACertificate ::
  CACertificate
newCACertificate :: CACertificate
newCACertificate =
  CACertificate' :: Maybe CACertificateStatus
-> Maybe Text -> Maybe Text -> Maybe POSIX -> CACertificate
CACertificate'
    { $sel:status:CACertificate' :: Maybe CACertificateStatus
status = Maybe CACertificateStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateArn:CACertificate' :: Maybe Text
certificateArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateId:CACertificate' :: Maybe Text
certificateId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:CACertificate' :: Maybe POSIX
creationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the CA certificate.
--
-- The status value REGISTER_INACTIVE is deprecated and should not be used.
cACertificate_status :: Lens.Lens' CACertificate (Prelude.Maybe CACertificateStatus)
cACertificate_status :: (Maybe CACertificateStatus -> f (Maybe CACertificateStatus))
-> CACertificate -> f CACertificate
cACertificate_status = (CACertificate -> Maybe CACertificateStatus)
-> (CACertificate -> Maybe CACertificateStatus -> CACertificate)
-> Lens
     CACertificate
     CACertificate
     (Maybe CACertificateStatus)
     (Maybe CACertificateStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CACertificate' {Maybe CACertificateStatus
status :: Maybe CACertificateStatus
$sel:status:CACertificate' :: CACertificate -> Maybe CACertificateStatus
status} -> Maybe CACertificateStatus
status) (\s :: CACertificate
s@CACertificate' {} Maybe CACertificateStatus
a -> CACertificate
s {$sel:status:CACertificate' :: Maybe CACertificateStatus
status = Maybe CACertificateStatus
a} :: CACertificate)

-- | The ARN of the CA certificate.
cACertificate_certificateArn :: Lens.Lens' CACertificate (Prelude.Maybe Prelude.Text)
cACertificate_certificateArn :: (Maybe Text -> f (Maybe Text)) -> CACertificate -> f CACertificate
cACertificate_certificateArn = (CACertificate -> Maybe Text)
-> (CACertificate -> Maybe Text -> CACertificate)
-> Lens CACertificate CACertificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CACertificate' {Maybe Text
certificateArn :: Maybe Text
$sel:certificateArn:CACertificate' :: CACertificate -> Maybe Text
certificateArn} -> Maybe Text
certificateArn) (\s :: CACertificate
s@CACertificate' {} Maybe Text
a -> CACertificate
s {$sel:certificateArn:CACertificate' :: Maybe Text
certificateArn = Maybe Text
a} :: CACertificate)

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

-- | The date the CA certificate was created.
cACertificate_creationDate :: Lens.Lens' CACertificate (Prelude.Maybe Prelude.UTCTime)
cACertificate_creationDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CACertificate -> f CACertificate
cACertificate_creationDate = (CACertificate -> Maybe POSIX)
-> (CACertificate -> Maybe POSIX -> CACertificate)
-> Lens CACertificate CACertificate (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CACertificate' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:CACertificate' :: CACertificate -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: CACertificate
s@CACertificate' {} Maybe POSIX
a -> CACertificate
s {$sel:creationDate:CACertificate' :: Maybe POSIX
creationDate = Maybe POSIX
a} :: CACertificate) ((Maybe POSIX -> f (Maybe POSIX))
 -> CACertificate -> f CACertificate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CACertificate
-> f CACertificate
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

instance Core.FromJSON CACertificate where
  parseJSON :: Value -> Parser CACertificate
parseJSON =
    String
-> (Object -> Parser CACertificate)
-> Value
-> Parser CACertificate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CACertificate"
      ( \Object
x ->
          Maybe CACertificateStatus
-> Maybe Text -> Maybe Text -> Maybe POSIX -> CACertificate
CACertificate'
            (Maybe CACertificateStatus
 -> Maybe Text -> Maybe Text -> Maybe POSIX -> CACertificate)
-> Parser (Maybe CACertificateStatus)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe POSIX -> CACertificate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CACertificateStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser (Maybe Text -> Maybe Text -> Maybe POSIX -> CACertificate)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> CACertificate)
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
"certificateArn")
            Parser (Maybe Text -> Maybe POSIX -> CACertificate)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> CACertificate)
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 -> CACertificate)
-> Parser (Maybe POSIX) -> Parser CACertificate
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
"creationDate")
      )

instance Prelude.Hashable CACertificate

instance Prelude.NFData CACertificate