{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.DescribeCACertificate
-- 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)
--
-- Describes a registered CA certificate.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DescribeCACertificate>
-- action.
module Amazonka.IoT.DescribeCACertificate
  ( -- * Creating a Request
    DescribeCACertificate (..),
    newDescribeCACertificate,

    -- * Request Lenses
    describeCACertificate_certificateId,

    -- * Destructuring the Response
    DescribeCACertificateResponse (..),
    newDescribeCACertificateResponse,

    -- * Response Lenses
    describeCACertificateResponse_certificateDescription,
    describeCACertificateResponse_registrationConfig,
    describeCACertificateResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The input for the DescribeCACertificate operation.
--
-- /See:/ 'newDescribeCACertificate' smart constructor.
data DescribeCACertificate = DescribeCACertificate'
  { -- | The CA certificate identifier.
    DescribeCACertificate -> Text
certificateId :: Prelude.Text
  }
  deriving (DescribeCACertificate -> DescribeCACertificate -> Bool
(DescribeCACertificate -> DescribeCACertificate -> Bool)
-> (DescribeCACertificate -> DescribeCACertificate -> Bool)
-> Eq DescribeCACertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCACertificate -> DescribeCACertificate -> Bool
$c/= :: DescribeCACertificate -> DescribeCACertificate -> Bool
== :: DescribeCACertificate -> DescribeCACertificate -> Bool
$c== :: DescribeCACertificate -> DescribeCACertificate -> Bool
Prelude.Eq, ReadPrec [DescribeCACertificate]
ReadPrec DescribeCACertificate
Int -> ReadS DescribeCACertificate
ReadS [DescribeCACertificate]
(Int -> ReadS DescribeCACertificate)
-> ReadS [DescribeCACertificate]
-> ReadPrec DescribeCACertificate
-> ReadPrec [DescribeCACertificate]
-> Read DescribeCACertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCACertificate]
$creadListPrec :: ReadPrec [DescribeCACertificate]
readPrec :: ReadPrec DescribeCACertificate
$creadPrec :: ReadPrec DescribeCACertificate
readList :: ReadS [DescribeCACertificate]
$creadList :: ReadS [DescribeCACertificate]
readsPrec :: Int -> ReadS DescribeCACertificate
$creadsPrec :: Int -> ReadS DescribeCACertificate
Prelude.Read, Int -> DescribeCACertificate -> ShowS
[DescribeCACertificate] -> ShowS
DescribeCACertificate -> String
(Int -> DescribeCACertificate -> ShowS)
-> (DescribeCACertificate -> String)
-> ([DescribeCACertificate] -> ShowS)
-> Show DescribeCACertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCACertificate] -> ShowS
$cshowList :: [DescribeCACertificate] -> ShowS
show :: DescribeCACertificate -> String
$cshow :: DescribeCACertificate -> String
showsPrec :: Int -> DescribeCACertificate -> ShowS
$cshowsPrec :: Int -> DescribeCACertificate -> ShowS
Prelude.Show, (forall x. DescribeCACertificate -> Rep DescribeCACertificate x)
-> (forall x. Rep DescribeCACertificate x -> DescribeCACertificate)
-> Generic DescribeCACertificate
forall x. Rep DescribeCACertificate x -> DescribeCACertificate
forall x. DescribeCACertificate -> Rep DescribeCACertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCACertificate x -> DescribeCACertificate
$cfrom :: forall x. DescribeCACertificate -> Rep DescribeCACertificate x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCACertificate' 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', 'describeCACertificate_certificateId' - The CA certificate identifier.
newDescribeCACertificate ::
  -- | 'certificateId'
  Prelude.Text ->
  DescribeCACertificate
newDescribeCACertificate :: Text -> DescribeCACertificate
newDescribeCACertificate Text
pCertificateId_ =
  DescribeCACertificate' :: Text -> DescribeCACertificate
DescribeCACertificate'
    { $sel:certificateId:DescribeCACertificate' :: Text
certificateId =
        Text
pCertificateId_
    }

-- | The CA certificate identifier.
describeCACertificate_certificateId :: Lens.Lens' DescribeCACertificate Prelude.Text
describeCACertificate_certificateId :: (Text -> f Text)
-> DescribeCACertificate -> f DescribeCACertificate
describeCACertificate_certificateId = (DescribeCACertificate -> Text)
-> (DescribeCACertificate -> Text -> DescribeCACertificate)
-> Lens DescribeCACertificate DescribeCACertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCACertificate' {Text
certificateId :: Text
$sel:certificateId:DescribeCACertificate' :: DescribeCACertificate -> Text
certificateId} -> Text
certificateId) (\s :: DescribeCACertificate
s@DescribeCACertificate' {} Text
a -> DescribeCACertificate
s {$sel:certificateId:DescribeCACertificate' :: Text
certificateId = Text
a} :: DescribeCACertificate)

instance Core.AWSRequest DescribeCACertificate where
  type
    AWSResponse DescribeCACertificate =
      DescribeCACertificateResponse
  request :: DescribeCACertificate -> Request DescribeCACertificate
request = Service -> DescribeCACertificate -> Request DescribeCACertificate
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeCACertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCACertificate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeCACertificate))
-> Logger
-> Service
-> Proxy DescribeCACertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCACertificate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe CACertificateDescription
-> Maybe RegistrationConfig -> Int -> DescribeCACertificateResponse
DescribeCACertificateResponse'
            (Maybe CACertificateDescription
 -> Maybe RegistrationConfig
 -> Int
 -> DescribeCACertificateResponse)
-> Either String (Maybe CACertificateDescription)
-> Either
     String
     (Maybe RegistrationConfig -> Int -> DescribeCACertificateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe CACertificateDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"certificateDescription")
            Either
  String
  (Maybe RegistrationConfig -> Int -> DescribeCACertificateResponse)
-> Either String (Maybe RegistrationConfig)
-> Either String (Int -> DescribeCACertificateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe RegistrationConfig)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"registrationConfig")
            Either String (Int -> DescribeCACertificateResponse)
-> Either String Int -> Either String DescribeCACertificateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeCACertificate

instance Prelude.NFData DescribeCACertificate

instance Core.ToHeaders DescribeCACertificate where
  toHeaders :: DescribeCACertificate -> ResponseHeaders
toHeaders = ResponseHeaders -> DescribeCACertificate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DescribeCACertificate where
  toPath :: DescribeCACertificate -> ByteString
toPath DescribeCACertificate' {Text
certificateId :: Text
$sel:certificateId:DescribeCACertificate' :: DescribeCACertificate -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/cacertificate/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
certificateId]

instance Core.ToQuery DescribeCACertificate where
  toQuery :: DescribeCACertificate -> QueryString
toQuery = QueryString -> DescribeCACertificate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | The output from the DescribeCACertificate operation.
--
-- /See:/ 'newDescribeCACertificateResponse' smart constructor.
data DescribeCACertificateResponse = DescribeCACertificateResponse'
  { -- | The CA certificate description.
    DescribeCACertificateResponse -> Maybe CACertificateDescription
certificateDescription :: Prelude.Maybe CACertificateDescription,
    -- | Information about the registration configuration.
    DescribeCACertificateResponse -> Maybe RegistrationConfig
registrationConfig :: Prelude.Maybe RegistrationConfig,
    -- | The response's http status code.
    DescribeCACertificateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeCACertificateResponse
-> DescribeCACertificateResponse -> Bool
(DescribeCACertificateResponse
 -> DescribeCACertificateResponse -> Bool)
-> (DescribeCACertificateResponse
    -> DescribeCACertificateResponse -> Bool)
-> Eq DescribeCACertificateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCACertificateResponse
-> DescribeCACertificateResponse -> Bool
$c/= :: DescribeCACertificateResponse
-> DescribeCACertificateResponse -> Bool
== :: DescribeCACertificateResponse
-> DescribeCACertificateResponse -> Bool
$c== :: DescribeCACertificateResponse
-> DescribeCACertificateResponse -> Bool
Prelude.Eq, ReadPrec [DescribeCACertificateResponse]
ReadPrec DescribeCACertificateResponse
Int -> ReadS DescribeCACertificateResponse
ReadS [DescribeCACertificateResponse]
(Int -> ReadS DescribeCACertificateResponse)
-> ReadS [DescribeCACertificateResponse]
-> ReadPrec DescribeCACertificateResponse
-> ReadPrec [DescribeCACertificateResponse]
-> Read DescribeCACertificateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCACertificateResponse]
$creadListPrec :: ReadPrec [DescribeCACertificateResponse]
readPrec :: ReadPrec DescribeCACertificateResponse
$creadPrec :: ReadPrec DescribeCACertificateResponse
readList :: ReadS [DescribeCACertificateResponse]
$creadList :: ReadS [DescribeCACertificateResponse]
readsPrec :: Int -> ReadS DescribeCACertificateResponse
$creadsPrec :: Int -> ReadS DescribeCACertificateResponse
Prelude.Read, Int -> DescribeCACertificateResponse -> ShowS
[DescribeCACertificateResponse] -> ShowS
DescribeCACertificateResponse -> String
(Int -> DescribeCACertificateResponse -> ShowS)
-> (DescribeCACertificateResponse -> String)
-> ([DescribeCACertificateResponse] -> ShowS)
-> Show DescribeCACertificateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCACertificateResponse] -> ShowS
$cshowList :: [DescribeCACertificateResponse] -> ShowS
show :: DescribeCACertificateResponse -> String
$cshow :: DescribeCACertificateResponse -> String
showsPrec :: Int -> DescribeCACertificateResponse -> ShowS
$cshowsPrec :: Int -> DescribeCACertificateResponse -> ShowS
Prelude.Show, (forall x.
 DescribeCACertificateResponse
 -> Rep DescribeCACertificateResponse x)
-> (forall x.
    Rep DescribeCACertificateResponse x
    -> DescribeCACertificateResponse)
-> Generic DescribeCACertificateResponse
forall x.
Rep DescribeCACertificateResponse x
-> DescribeCACertificateResponse
forall x.
DescribeCACertificateResponse
-> Rep DescribeCACertificateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeCACertificateResponse x
-> DescribeCACertificateResponse
$cfrom :: forall x.
DescribeCACertificateResponse
-> Rep DescribeCACertificateResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCACertificateResponse' 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:
--
-- 'certificateDescription', 'describeCACertificateResponse_certificateDescription' - The CA certificate description.
--
-- 'registrationConfig', 'describeCACertificateResponse_registrationConfig' - Information about the registration configuration.
--
-- 'httpStatus', 'describeCACertificateResponse_httpStatus' - The response's http status code.
newDescribeCACertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeCACertificateResponse
newDescribeCACertificateResponse :: Int -> DescribeCACertificateResponse
newDescribeCACertificateResponse Int
pHttpStatus_ =
  DescribeCACertificateResponse' :: Maybe CACertificateDescription
-> Maybe RegistrationConfig -> Int -> DescribeCACertificateResponse
DescribeCACertificateResponse'
    { $sel:certificateDescription:DescribeCACertificateResponse' :: Maybe CACertificateDescription
certificateDescription =
        Maybe CACertificateDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:registrationConfig:DescribeCACertificateResponse' :: Maybe RegistrationConfig
registrationConfig = Maybe RegistrationConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeCACertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The CA certificate description.
describeCACertificateResponse_certificateDescription :: Lens.Lens' DescribeCACertificateResponse (Prelude.Maybe CACertificateDescription)
describeCACertificateResponse_certificateDescription :: (Maybe CACertificateDescription
 -> f (Maybe CACertificateDescription))
-> DescribeCACertificateResponse -> f DescribeCACertificateResponse
describeCACertificateResponse_certificateDescription = (DescribeCACertificateResponse -> Maybe CACertificateDescription)
-> (DescribeCACertificateResponse
    -> Maybe CACertificateDescription -> DescribeCACertificateResponse)
-> Lens
     DescribeCACertificateResponse
     DescribeCACertificateResponse
     (Maybe CACertificateDescription)
     (Maybe CACertificateDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCACertificateResponse' {Maybe CACertificateDescription
certificateDescription :: Maybe CACertificateDescription
$sel:certificateDescription:DescribeCACertificateResponse' :: DescribeCACertificateResponse -> Maybe CACertificateDescription
certificateDescription} -> Maybe CACertificateDescription
certificateDescription) (\s :: DescribeCACertificateResponse
s@DescribeCACertificateResponse' {} Maybe CACertificateDescription
a -> DescribeCACertificateResponse
s {$sel:certificateDescription:DescribeCACertificateResponse' :: Maybe CACertificateDescription
certificateDescription = Maybe CACertificateDescription
a} :: DescribeCACertificateResponse)

-- | Information about the registration configuration.
describeCACertificateResponse_registrationConfig :: Lens.Lens' DescribeCACertificateResponse (Prelude.Maybe RegistrationConfig)
describeCACertificateResponse_registrationConfig :: (Maybe RegistrationConfig -> f (Maybe RegistrationConfig))
-> DescribeCACertificateResponse -> f DescribeCACertificateResponse
describeCACertificateResponse_registrationConfig = (DescribeCACertificateResponse -> Maybe RegistrationConfig)
-> (DescribeCACertificateResponse
    -> Maybe RegistrationConfig -> DescribeCACertificateResponse)
-> Lens
     DescribeCACertificateResponse
     DescribeCACertificateResponse
     (Maybe RegistrationConfig)
     (Maybe RegistrationConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCACertificateResponse' {Maybe RegistrationConfig
registrationConfig :: Maybe RegistrationConfig
$sel:registrationConfig:DescribeCACertificateResponse' :: DescribeCACertificateResponse -> Maybe RegistrationConfig
registrationConfig} -> Maybe RegistrationConfig
registrationConfig) (\s :: DescribeCACertificateResponse
s@DescribeCACertificateResponse' {} Maybe RegistrationConfig
a -> DescribeCACertificateResponse
s {$sel:registrationConfig:DescribeCACertificateResponse' :: Maybe RegistrationConfig
registrationConfig = Maybe RegistrationConfig
a} :: DescribeCACertificateResponse)

-- | The response's http status code.
describeCACertificateResponse_httpStatus :: Lens.Lens' DescribeCACertificateResponse Prelude.Int
describeCACertificateResponse_httpStatus :: (Int -> f Int)
-> DescribeCACertificateResponse -> f DescribeCACertificateResponse
describeCACertificateResponse_httpStatus = (DescribeCACertificateResponse -> Int)
-> (DescribeCACertificateResponse
    -> Int -> DescribeCACertificateResponse)
-> Lens
     DescribeCACertificateResponse DescribeCACertificateResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCACertificateResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeCACertificateResponse' :: DescribeCACertificateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeCACertificateResponse
s@DescribeCACertificateResponse' {} Int
a -> DescribeCACertificateResponse
s {$sel:httpStatus:DescribeCACertificateResponse' :: Int
httpStatus = Int
a} :: DescribeCACertificateResponse)

instance Prelude.NFData DescribeCACertificateResponse