{-# 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-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 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 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

-- | /See:/ 'newDescribeAuthorizer' smart constructor.
data DescribeAuthorizer = DescribeAuthorizer'
  { -- | The name of the authorizer to describe.
    DescribeAuthorizer -> Text
authorizerName :: Prelude.Text
  }
  deriving (DescribeAuthorizer -> DescribeAuthorizer -> Bool
(DescribeAuthorizer -> DescribeAuthorizer -> Bool)
-> (DescribeAuthorizer -> DescribeAuthorizer -> Bool)
-> Eq DescribeAuthorizer
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]
(Int -> ReadS DescribeAuthorizer)
-> ReadS [DescribeAuthorizer]
-> ReadPrec DescribeAuthorizer
-> ReadPrec [DescribeAuthorizer]
-> Read 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
(Int -> DescribeAuthorizer -> ShowS)
-> (DescribeAuthorizer -> String)
-> ([DescribeAuthorizer] -> ShowS)
-> Show DescribeAuthorizer
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. DescribeAuthorizer -> Rep DescribeAuthorizer x)
-> (forall x. Rep DescribeAuthorizer x -> DescribeAuthorizer)
-> Generic DescribeAuthorizer
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' :: Text -> DescribeAuthorizer
DescribeAuthorizer'
    { $sel:authorizerName:DescribeAuthorizer' :: Text
authorizerName =
        Text
pAuthorizerName_
    }

-- | The name of the authorizer to describe.
describeAuthorizer_authorizerName :: Lens.Lens' DescribeAuthorizer Prelude.Text
describeAuthorizer_authorizerName :: (Text -> f Text) -> DescribeAuthorizer -> f DescribeAuthorizer
describeAuthorizer_authorizerName = (DescribeAuthorizer -> Text)
-> (DescribeAuthorizer -> Text -> DescribeAuthorizer)
-> Lens DescribeAuthorizer DescribeAuthorizer Text Text
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 :: DescribeAuthorizer -> Request DescribeAuthorizer
request = Service -> DescribeAuthorizer -> Request DescribeAuthorizer
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeAuthorizer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeAuthorizer)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeAuthorizer))
-> Logger
-> Service
-> Proxy DescribeAuthorizer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeAuthorizer)))
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 AuthorizerDescription -> Int -> DescribeAuthorizerResponse
DescribeAuthorizerResponse'
            (Maybe AuthorizerDescription -> Int -> DescribeAuthorizerResponse)
-> Either String (Maybe AuthorizerDescription)
-> Either String (Int -> DescribeAuthorizerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe AuthorizerDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"authorizerDescription")
            Either String (Int -> DescribeAuthorizerResponse)
-> Either String Int -> Either String DescribeAuthorizerResponse
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 DescribeAuthorizer

instance Prelude.NFData DescribeAuthorizer

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

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

instance Core.ToQuery DescribeAuthorizer where
  toQuery :: DescribeAuthorizer -> QueryString
toQuery = QueryString -> DescribeAuthorizer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DescribeAuthorizerResponse -> DescribeAuthorizerResponse -> Bool)
-> (DescribeAuthorizerResponse
    -> DescribeAuthorizerResponse -> Bool)
-> Eq DescribeAuthorizerResponse
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]
(Int -> ReadS DescribeAuthorizerResponse)
-> ReadS [DescribeAuthorizerResponse]
-> ReadPrec DescribeAuthorizerResponse
-> ReadPrec [DescribeAuthorizerResponse]
-> Read 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
(Int -> DescribeAuthorizerResponse -> ShowS)
-> (DescribeAuthorizerResponse -> String)
-> ([DescribeAuthorizerResponse] -> ShowS)
-> Show DescribeAuthorizerResponse
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.
 DescribeAuthorizerResponse -> Rep DescribeAuthorizerResponse x)
-> (forall x.
    Rep DescribeAuthorizerResponse x -> DescribeAuthorizerResponse)
-> Generic DescribeAuthorizerResponse
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' :: Maybe AuthorizerDescription -> Int -> DescribeAuthorizerResponse
DescribeAuthorizerResponse'
    { $sel:authorizerDescription:DescribeAuthorizerResponse' :: Maybe AuthorizerDescription
authorizerDescription =
        Maybe 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 :: (Maybe AuthorizerDescription -> f (Maybe AuthorizerDescription))
-> DescribeAuthorizerResponse -> f DescribeAuthorizerResponse
describeAuthorizerResponse_authorizerDescription = (DescribeAuthorizerResponse -> Maybe AuthorizerDescription)
-> (DescribeAuthorizerResponse
    -> Maybe AuthorizerDescription -> DescribeAuthorizerResponse)
-> Lens
     DescribeAuthorizerResponse
     DescribeAuthorizerResponse
     (Maybe AuthorizerDescription)
     (Maybe 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 :: (Int -> f Int)
-> DescribeAuthorizerResponse -> f DescribeAuthorizerResponse
describeAuthorizerResponse_httpStatus = (DescribeAuthorizerResponse -> Int)
-> (DescribeAuthorizerResponse
    -> Int -> DescribeAuthorizerResponse)
-> Lens
     DescribeAuthorizerResponse DescribeAuthorizerResponse Int Int
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