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

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

-- | A CA certificate.
--
-- /See:/ 'newCACertificate' smart constructor.
data CACertificate = CACertificate'
  { -- | 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 Data.POSIX,
    -- | 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
  }
  deriving (CACertificate -> CACertificate -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'status', 'cACertificate_status' - The status of the CA certificate.
--
-- The status value REGISTER_INACTIVE is deprecated and should not be used.
newCACertificate ::
  CACertificate
newCACertificate :: CACertificate
newCACertificate =
  CACertificate'
    { $sel:certificateArn:CACertificate' :: Maybe Text
certificateArn = forall a. Maybe a
Prelude.Nothing,
      $sel:certificateId:CACertificate' :: Maybe Text
certificateId = forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:CACertificate' :: Maybe POSIX
creationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:status:CACertificate' :: Maybe CACertificateStatus
status = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the CA certificate.
cACertificate_certificateArn :: Lens.Lens' CACertificate (Prelude.Maybe Prelude.Text)
cACertificate_certificateArn :: Lens' CACertificate (Maybe Text)
cACertificate_certificateArn = 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 :: Lens' CACertificate (Maybe Text)
cACertificate_certificateId = 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 :: Lens' CACertificate (Maybe UTCTime)
cACertificate_creationDate = 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) 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 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 :: Lens' CACertificate (Maybe CACertificateStatus)
cACertificate_status = 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)

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

instance Prelude.Hashable CACertificate where
  hashWithSalt :: Int -> CACertificate -> Int
hashWithSalt Int
_salt CACertificate' {Maybe Text
Maybe POSIX
Maybe CACertificateStatus
status :: Maybe CACertificateStatus
creationDate :: Maybe POSIX
certificateId :: Maybe Text
certificateArn :: Maybe Text
$sel:status:CACertificate' :: CACertificate -> Maybe CACertificateStatus
$sel:creationDate:CACertificate' :: CACertificate -> Maybe POSIX
$sel:certificateId:CACertificate' :: CACertificate -> Maybe Text
$sel:certificateArn:CACertificate' :: CACertificate -> 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
certificateId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CACertificateStatus
status

instance Prelude.NFData CACertificate where
  rnf :: CACertificate -> ()
rnf CACertificate' {Maybe Text
Maybe POSIX
Maybe CACertificateStatus
status :: Maybe CACertificateStatus
creationDate :: Maybe POSIX
certificateId :: Maybe Text
certificateArn :: Maybe Text
$sel:status:CACertificate' :: CACertificate -> Maybe CACertificateStatus
$sel:creationDate:CACertificate' :: CACertificate -> Maybe POSIX
$sel:certificateId:CACertificate' :: CACertificate -> Maybe Text
$sel:certificateArn:CACertificate' :: CACertificate -> 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
certificateId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CACertificateStatus
status