{-# 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.DescribeAuthorizer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes an authorizer.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DescribeAuthorizer>
-- action.
module Amazonka.IoT.DescribeAuthorizer
  ( -- * Creating a Request
    DescribeAuthorizer (..),
    newDescribeAuthorizer,

    -- * Request Lenses
    describeAuthorizer_authorizerName,

    -- * Destructuring the Response
    DescribeAuthorizerResponse (..),
    newDescribeAuthorizerResponse,

    -- * Response Lenses
    describeAuthorizerResponse_authorizerDescription,
    describeAuthorizerResponse_httpStatus,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeAuthorizer' smart constructor.
data DescribeAuthorizer = DescribeAuthorizer'
  { -- | The name of the authorizer to describe.
    DescribeAuthorizer -> Text
authorizerName :: Prelude.Text
  }
  deriving (DescribeAuthorizer -> DescribeAuthorizer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAuthorizer -> DescribeAuthorizer -> Bool
$c/= :: DescribeAuthorizer -> DescribeAuthorizer -> Bool
== :: DescribeAuthorizer -> DescribeAuthorizer -> Bool
$c== :: DescribeAuthorizer -> DescribeAuthorizer -> Bool
Prelude.Eq, ReadPrec [DescribeAuthorizer]
ReadPrec DescribeAuthorizer
Int -> ReadS DescribeAuthorizer
ReadS [DescribeAuthorizer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAuthorizer]
$creadListPrec :: ReadPrec [DescribeAuthorizer]
readPrec :: ReadPrec DescribeAuthorizer
$creadPrec :: ReadPrec DescribeAuthorizer
readList :: ReadS [DescribeAuthorizer]
$creadList :: ReadS [DescribeAuthorizer]
readsPrec :: Int -> ReadS DescribeAuthorizer
$creadsPrec :: Int -> ReadS DescribeAuthorizer
Prelude.Read, Int -> DescribeAuthorizer -> ShowS
[DescribeAuthorizer] -> ShowS
DescribeAuthorizer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAuthorizer] -> ShowS
$cshowList :: [DescribeAuthorizer] -> ShowS
show :: DescribeAuthorizer -> String
$cshow :: DescribeAuthorizer -> String
showsPrec :: Int -> DescribeAuthorizer -> ShowS
$cshowsPrec :: Int -> DescribeAuthorizer -> ShowS
Prelude.Show, forall x. Rep DescribeAuthorizer x -> DescribeAuthorizer
forall x. DescribeAuthorizer -> Rep DescribeAuthorizer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAuthorizer x -> DescribeAuthorizer
$cfrom :: forall x. DescribeAuthorizer -> Rep DescribeAuthorizer x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAuthorizer' 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:
--
-- 'authorizerName', 'describeAuthorizer_authorizerName' - The name of the authorizer to describe.
newDescribeAuthorizer ::
  -- | 'authorizerName'
  Prelude.Text ->
  DescribeAuthorizer
newDescribeAuthorizer :: Text -> DescribeAuthorizer
newDescribeAuthorizer Text
pAuthorizerName_ =
  DescribeAuthorizer'
    { $sel:authorizerName:DescribeAuthorizer' :: Text
authorizerName =
        Text
pAuthorizerName_
    }

-- | The name of the authorizer to describe.
describeAuthorizer_authorizerName :: Lens.Lens' DescribeAuthorizer Prelude.Text
describeAuthorizer_authorizerName :: Lens' DescribeAuthorizer Text
describeAuthorizer_authorizerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAuthorizer' {Text
authorizerName :: Text
$sel:authorizerName:DescribeAuthorizer' :: DescribeAuthorizer -> Text
authorizerName} -> Text
authorizerName) (\s :: DescribeAuthorizer
s@DescribeAuthorizer' {} Text
a -> DescribeAuthorizer
s {$sel:authorizerName:DescribeAuthorizer' :: Text
authorizerName = Text
a} :: DescribeAuthorizer)

instance Core.AWSRequest DescribeAuthorizer where
  type
    AWSResponse DescribeAuthorizer =
      DescribeAuthorizerResponse
  request :: (Service -> Service)
-> DescribeAuthorizer -> Request DescribeAuthorizer
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeAuthorizer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeAuthorizer)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe AuthorizerDescription -> Int -> DescribeAuthorizerResponse
DescribeAuthorizerResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"authorizerDescription")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeAuthorizer where
  hashWithSalt :: Int -> DescribeAuthorizer -> Int
hashWithSalt Int
_salt DescribeAuthorizer' {Text
authorizerName :: Text
$sel:authorizerName:DescribeAuthorizer' :: DescribeAuthorizer -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
authorizerName

instance Prelude.NFData DescribeAuthorizer where
  rnf :: DescribeAuthorizer -> ()
rnf DescribeAuthorizer' {Text
authorizerName :: Text
$sel:authorizerName:DescribeAuthorizer' :: DescribeAuthorizer -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
authorizerName

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

instance Data.ToPath DescribeAuthorizer where
  toPath :: DescribeAuthorizer -> ByteString
toPath DescribeAuthorizer' {Text
authorizerName :: Text
$sel:authorizerName:DescribeAuthorizer' :: DescribeAuthorizer -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/authorizer/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
authorizerName]

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

-- | /See:/ 'newDescribeAuthorizerResponse' smart constructor.
data DescribeAuthorizerResponse = DescribeAuthorizerResponse'
  { -- | The authorizer description.
    DescribeAuthorizerResponse -> Maybe AuthorizerDescription
authorizerDescription :: Prelude.Maybe AuthorizerDescription,
    -- | The response's http status code.
    DescribeAuthorizerResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAuthorizerResponse -> DescribeAuthorizerResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAuthorizerResponse -> DescribeAuthorizerResponse -> Bool
$c/= :: DescribeAuthorizerResponse -> DescribeAuthorizerResponse -> Bool
== :: DescribeAuthorizerResponse -> DescribeAuthorizerResponse -> Bool
$c== :: DescribeAuthorizerResponse -> DescribeAuthorizerResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAuthorizerResponse]
ReadPrec DescribeAuthorizerResponse
Int -> ReadS DescribeAuthorizerResponse
ReadS [DescribeAuthorizerResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAuthorizerResponse]
$creadListPrec :: ReadPrec [DescribeAuthorizerResponse]
readPrec :: ReadPrec DescribeAuthorizerResponse
$creadPrec :: ReadPrec DescribeAuthorizerResponse
readList :: ReadS [DescribeAuthorizerResponse]
$creadList :: ReadS [DescribeAuthorizerResponse]
readsPrec :: Int -> ReadS DescribeAuthorizerResponse
$creadsPrec :: Int -> ReadS DescribeAuthorizerResponse
Prelude.Read, Int -> DescribeAuthorizerResponse -> ShowS
[DescribeAuthorizerResponse] -> ShowS
DescribeAuthorizerResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAuthorizerResponse] -> ShowS
$cshowList :: [DescribeAuthorizerResponse] -> ShowS
show :: DescribeAuthorizerResponse -> String
$cshow :: DescribeAuthorizerResponse -> String
showsPrec :: Int -> DescribeAuthorizerResponse -> ShowS
$cshowsPrec :: Int -> DescribeAuthorizerResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeAuthorizerResponse x -> DescribeAuthorizerResponse
forall x.
DescribeAuthorizerResponse -> Rep DescribeAuthorizerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAuthorizerResponse x -> DescribeAuthorizerResponse
$cfrom :: forall x.
DescribeAuthorizerResponse -> Rep DescribeAuthorizerResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAuthorizerResponse' 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:
--
-- 'authorizerDescription', 'describeAuthorizerResponse_authorizerDescription' - The authorizer description.
--
-- 'httpStatus', 'describeAuthorizerResponse_httpStatus' - The response's http status code.
newDescribeAuthorizerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAuthorizerResponse
newDescribeAuthorizerResponse :: Int -> DescribeAuthorizerResponse
newDescribeAuthorizerResponse Int
pHttpStatus_ =
  DescribeAuthorizerResponse'
    { $sel:authorizerDescription:DescribeAuthorizerResponse' :: Maybe AuthorizerDescription
authorizerDescription =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAuthorizerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The authorizer description.
describeAuthorizerResponse_authorizerDescription :: Lens.Lens' DescribeAuthorizerResponse (Prelude.Maybe AuthorizerDescription)
describeAuthorizerResponse_authorizerDescription :: Lens' DescribeAuthorizerResponse (Maybe AuthorizerDescription)
describeAuthorizerResponse_authorizerDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAuthorizerResponse' {Maybe AuthorizerDescription
authorizerDescription :: Maybe AuthorizerDescription
$sel:authorizerDescription:DescribeAuthorizerResponse' :: DescribeAuthorizerResponse -> Maybe AuthorizerDescription
authorizerDescription} -> Maybe AuthorizerDescription
authorizerDescription) (\s :: DescribeAuthorizerResponse
s@DescribeAuthorizerResponse' {} Maybe AuthorizerDescription
a -> DescribeAuthorizerResponse
s {$sel:authorizerDescription:DescribeAuthorizerResponse' :: Maybe AuthorizerDescription
authorizerDescription = Maybe AuthorizerDescription
a} :: DescribeAuthorizerResponse)

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

instance Prelude.NFData DescribeAuthorizerResponse where
  rnf :: DescribeAuthorizerResponse -> ()
rnf DescribeAuthorizerResponse' {Int
Maybe AuthorizerDescription
httpStatus :: Int
authorizerDescription :: Maybe AuthorizerDescription
$sel:httpStatus:DescribeAuthorizerResponse' :: DescribeAuthorizerResponse -> Int
$sel:authorizerDescription:DescribeAuthorizerResponse' :: DescribeAuthorizerResponse -> Maybe AuthorizerDescription
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AuthorizerDescription
authorizerDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus