{-# 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.APIGateway.GetAuthorizer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describe an existing Authorizer resource.
module Amazonka.APIGateway.GetAuthorizer
  ( -- * Creating a Request
    GetAuthorizer (..),
    newGetAuthorizer,

    -- * Request Lenses
    getAuthorizer_restApiId,
    getAuthorizer_authorizerId,

    -- * Destructuring the Response
    Authorizer (..),
    newAuthorizer,

    -- * Response Lenses
    authorizer_authType,
    authorizer_authorizerCredentials,
    authorizer_authorizerResultTtlInSeconds,
    authorizer_authorizerUri,
    authorizer_id,
    authorizer_identitySource,
    authorizer_identityValidationExpression,
    authorizer_name,
    authorizer_providerARNs,
    authorizer_type,
  )
where

import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Request to describe an existing Authorizer resource.
--
-- /See:/ 'newGetAuthorizer' smart constructor.
data GetAuthorizer = GetAuthorizer'
  { -- | The string identifier of the associated RestApi.
    GetAuthorizer -> Text
restApiId :: Prelude.Text,
    -- | The identifier of the Authorizer resource.
    GetAuthorizer -> Text
authorizerId :: Prelude.Text
  }
  deriving (GetAuthorizer -> GetAuthorizer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAuthorizer -> GetAuthorizer -> Bool
$c/= :: GetAuthorizer -> GetAuthorizer -> Bool
== :: GetAuthorizer -> GetAuthorizer -> Bool
$c== :: GetAuthorizer -> GetAuthorizer -> Bool
Prelude.Eq, ReadPrec [GetAuthorizer]
ReadPrec GetAuthorizer
Int -> ReadS GetAuthorizer
ReadS [GetAuthorizer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAuthorizer]
$creadListPrec :: ReadPrec [GetAuthorizer]
readPrec :: ReadPrec GetAuthorizer
$creadPrec :: ReadPrec GetAuthorizer
readList :: ReadS [GetAuthorizer]
$creadList :: ReadS [GetAuthorizer]
readsPrec :: Int -> ReadS GetAuthorizer
$creadsPrec :: Int -> ReadS GetAuthorizer
Prelude.Read, Int -> GetAuthorizer -> ShowS
[GetAuthorizer] -> ShowS
GetAuthorizer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAuthorizer] -> ShowS
$cshowList :: [GetAuthorizer] -> ShowS
show :: GetAuthorizer -> String
$cshow :: GetAuthorizer -> String
showsPrec :: Int -> GetAuthorizer -> ShowS
$cshowsPrec :: Int -> GetAuthorizer -> ShowS
Prelude.Show, forall x. Rep GetAuthorizer x -> GetAuthorizer
forall x. GetAuthorizer -> Rep GetAuthorizer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAuthorizer x -> GetAuthorizer
$cfrom :: forall x. GetAuthorizer -> Rep GetAuthorizer x
Prelude.Generic)

-- |
-- Create a value of 'GetAuthorizer' 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:
--
-- 'restApiId', 'getAuthorizer_restApiId' - The string identifier of the associated RestApi.
--
-- 'authorizerId', 'getAuthorizer_authorizerId' - The identifier of the Authorizer resource.
newGetAuthorizer ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'authorizerId'
  Prelude.Text ->
  GetAuthorizer
newGetAuthorizer :: Text -> Text -> GetAuthorizer
newGetAuthorizer Text
pRestApiId_ Text
pAuthorizerId_ =
  GetAuthorizer'
    { $sel:restApiId:GetAuthorizer' :: Text
restApiId = Text
pRestApiId_,
      $sel:authorizerId:GetAuthorizer' :: Text
authorizerId = Text
pAuthorizerId_
    }

-- | The string identifier of the associated RestApi.
getAuthorizer_restApiId :: Lens.Lens' GetAuthorizer Prelude.Text
getAuthorizer_restApiId :: Lens' GetAuthorizer Text
getAuthorizer_restApiId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizer' {Text
restApiId :: Text
$sel:restApiId:GetAuthorizer' :: GetAuthorizer -> Text
restApiId} -> Text
restApiId) (\s :: GetAuthorizer
s@GetAuthorizer' {} Text
a -> GetAuthorizer
s {$sel:restApiId:GetAuthorizer' :: Text
restApiId = Text
a} :: GetAuthorizer)

-- | The identifier of the Authorizer resource.
getAuthorizer_authorizerId :: Lens.Lens' GetAuthorizer Prelude.Text
getAuthorizer_authorizerId :: Lens' GetAuthorizer Text
getAuthorizer_authorizerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizer' {Text
authorizerId :: Text
$sel:authorizerId:GetAuthorizer' :: GetAuthorizer -> Text
authorizerId} -> Text
authorizerId) (\s :: GetAuthorizer
s@GetAuthorizer' {} Text
a -> GetAuthorizer
s {$sel:authorizerId:GetAuthorizer' :: Text
authorizerId = Text
a} :: GetAuthorizer)

instance Core.AWSRequest GetAuthorizer where
  type AWSResponse GetAuthorizer = Authorizer
  request :: (Service -> Service) -> GetAuthorizer -> Request GetAuthorizer
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 GetAuthorizer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAuthorizer)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

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

instance Prelude.NFData GetAuthorizer where
  rnf :: GetAuthorizer -> ()
rnf GetAuthorizer' {Text
authorizerId :: Text
restApiId :: Text
$sel:authorizerId:GetAuthorizer' :: GetAuthorizer -> Text
$sel:restApiId:GetAuthorizer' :: GetAuthorizer -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
restApiId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
authorizerId

instance Data.ToHeaders GetAuthorizer where
  toHeaders :: GetAuthorizer -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Data.ToPath GetAuthorizer where
  toPath :: GetAuthorizer -> ByteString
toPath GetAuthorizer' {Text
authorizerId :: Text
restApiId :: Text
$sel:authorizerId:GetAuthorizer' :: GetAuthorizer -> Text
$sel:restApiId:GetAuthorizer' :: GetAuthorizer -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId,
        ByteString
"/authorizers/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
authorizerId
      ]

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