{-# 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.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.IoT.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.IoT.Types.CertificateMode
import Amazonka.IoT.Types.CertificateStatus
import qualified Amazonka.Prelude as Prelude

-- | Information about a certificate.
--
-- /See:/ 'newCertificate' smart constructor.
data Certificate = Certificate'
  { -- | The ARN of the certificate.
    Certificate -> Maybe Text
certificateArn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the certificate. (The last part of the certificate ARN
    -- contains the certificate ID.)
    Certificate -> Maybe Text
certificateId :: Prelude.Maybe Prelude.Text,
    -- | The mode of the certificate.
    --
    -- @DEFAULT@: A certificate in @DEFAULT@ mode is either generated by Amazon
    -- Web Services IoT Core or registered with an issuer certificate authority
    -- (CA) in @DEFAULT@ mode. Devices with certificates in @DEFAULT@ mode
    -- aren\'t required to send the Server Name Indication (SNI) extension when
    -- connecting to Amazon Web Services IoT Core. However, to use features
    -- such as custom domains and VPC endpoints, we recommend that you use the
    -- SNI extension when connecting to Amazon Web Services IoT Core.
    --
    -- @SNI_ONLY@: A certificate in @SNI_ONLY@ mode is registered without an
    -- issuer CA. Devices with certificates in @SNI_ONLY@ mode must send the
    -- SNI extension when connecting to Amazon Web Services IoT Core.
    Certificate -> Maybe CertificateMode
certificateMode :: Prelude.Maybe CertificateMode,
    -- | The date and time the certificate was created.
    Certificate -> Maybe POSIX
creationDate :: Prelude.Maybe Data.POSIX,
    -- | The status of the certificate.
    --
    -- The status value REGISTER_INACTIVE is deprecated and should not be used.
    Certificate -> Maybe CertificateStatus
status :: Prelude.Maybe CertificateStatus
  }
  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:
--
-- 'certificateArn', 'certificate_certificateArn' - The ARN of the certificate.
--
-- 'certificateId', 'certificate_certificateId' - The ID of the certificate. (The last part of the certificate ARN
-- contains the certificate ID.)
--
-- 'certificateMode', 'certificate_certificateMode' - The mode of the certificate.
--
-- @DEFAULT@: A certificate in @DEFAULT@ mode is either generated by Amazon
-- Web Services IoT Core or registered with an issuer certificate authority
-- (CA) in @DEFAULT@ mode. Devices with certificates in @DEFAULT@ mode
-- aren\'t required to send the Server Name Indication (SNI) extension when
-- connecting to Amazon Web Services IoT Core. However, to use features
-- such as custom domains and VPC endpoints, we recommend that you use the
-- SNI extension when connecting to Amazon Web Services IoT Core.
--
-- @SNI_ONLY@: A certificate in @SNI_ONLY@ mode is registered without an
-- issuer CA. Devices with certificates in @SNI_ONLY@ mode must send the
-- SNI extension when connecting to Amazon Web Services IoT Core.
--
-- 'creationDate', 'certificate_creationDate' - The date and time the certificate was created.
--
-- 'status', 'certificate_status' - The status of the certificate.
--
-- The status value REGISTER_INACTIVE is deprecated and should not be used.
newCertificate ::
  Certificate
newCertificate :: Certificate
newCertificate =
  Certificate'
    { $sel:certificateArn:Certificate' :: Maybe Text
certificateArn = forall a. Maybe a
Prelude.Nothing,
      $sel:certificateId:Certificate' :: Maybe Text
certificateId = forall a. Maybe a
Prelude.Nothing,
      $sel:certificateMode:Certificate' :: Maybe CertificateMode
certificateMode = forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:Certificate' :: Maybe POSIX
creationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Certificate' :: Maybe CertificateStatus
status = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The ID of the certificate. (The last part of the certificate ARN
-- contains the certificate ID.)
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)

-- | The mode of the certificate.
--
-- @DEFAULT@: A certificate in @DEFAULT@ mode is either generated by Amazon
-- Web Services IoT Core or registered with an issuer certificate authority
-- (CA) in @DEFAULT@ mode. Devices with certificates in @DEFAULT@ mode
-- aren\'t required to send the Server Name Indication (SNI) extension when
-- connecting to Amazon Web Services IoT Core. However, to use features
-- such as custom domains and VPC endpoints, we recommend that you use the
-- SNI extension when connecting to Amazon Web Services IoT Core.
--
-- @SNI_ONLY@: A certificate in @SNI_ONLY@ mode is registered without an
-- issuer CA. Devices with certificates in @SNI_ONLY@ mode must send the
-- SNI extension when connecting to Amazon Web Services IoT Core.
certificate_certificateMode :: Lens.Lens' Certificate (Prelude.Maybe CertificateMode)
certificate_certificateMode :: Lens' Certificate (Maybe CertificateMode)
certificate_certificateMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe CertificateMode
certificateMode :: Maybe CertificateMode
$sel:certificateMode:Certificate' :: Certificate -> Maybe CertificateMode
certificateMode} -> Maybe CertificateMode
certificateMode) (\s :: Certificate
s@Certificate' {} Maybe CertificateMode
a -> Certificate
s {$sel:certificateMode:Certificate' :: Maybe CertificateMode
certificateMode = Maybe CertificateMode
a} :: Certificate)

-- | The date and time the certificate was created.
certificate_creationDate :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_creationDate :: Lens' Certificate (Maybe UTCTime)
certificate_creationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:Certificate' :: Certificate -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: Certificate
s@Certificate' {} Maybe POSIX
a -> Certificate
s {$sel:creationDate:Certificate' :: Maybe POSIX
creationDate = 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 status of the certificate.
--
-- The status value REGISTER_INACTIVE is deprecated and should not be used.
certificate_status :: Lens.Lens' Certificate (Prelude.Maybe CertificateStatus)
certificate_status :: Lens' Certificate (Maybe CertificateStatus)
certificate_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe CertificateStatus
status :: Maybe CertificateStatus
$sel:status:Certificate' :: Certificate -> Maybe CertificateStatus
status} -> Maybe CertificateStatus
status) (\s :: Certificate
s@Certificate' {} Maybe CertificateStatus
a -> Certificate
s {$sel:status:Certificate' :: Maybe CertificateStatus
status = Maybe CertificateStatus
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 Text
-> Maybe CertificateMode
-> Maybe POSIX
-> Maybe CertificateStatus
-> 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
"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
"certificateMode")
            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 Certificate where
  hashWithSalt :: Int -> Certificate -> Int
hashWithSalt Int
_salt Certificate' {Maybe Text
Maybe POSIX
Maybe CertificateMode
Maybe CertificateStatus
status :: Maybe CertificateStatus
creationDate :: Maybe POSIX
certificateMode :: Maybe CertificateMode
certificateId :: Maybe Text
certificateArn :: Maybe Text
$sel:status:Certificate' :: Certificate -> Maybe CertificateStatus
$sel:creationDate:Certificate' :: Certificate -> Maybe POSIX
$sel:certificateMode:Certificate' :: Certificate -> Maybe CertificateMode
$sel:certificateId:Certificate' :: Certificate -> Maybe Text
$sel:certificateArn:Certificate' :: Certificate -> 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 CertificateMode
certificateMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CertificateStatus
status

instance Prelude.NFData Certificate where
  rnf :: Certificate -> ()
rnf Certificate' {Maybe Text
Maybe POSIX
Maybe CertificateMode
Maybe CertificateStatus
status :: Maybe CertificateStatus
creationDate :: Maybe POSIX
certificateMode :: Maybe CertificateMode
certificateId :: Maybe Text
certificateArn :: Maybe Text
$sel:status:Certificate' :: Certificate -> Maybe CertificateStatus
$sel:creationDate:Certificate' :: Certificate -> Maybe POSIX
$sel:certificateMode:Certificate' :: Certificate -> Maybe CertificateMode
$sel:certificateId:Certificate' :: Certificate -> Maybe Text
$sel:certificateArn:Certificate' :: Certificate -> 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 CertificateMode
certificateMode
      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 CertificateStatus
status