{-# 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-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)
--
-- Describe an existing Authorizer resource.
--
-- <https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-authorizer.html AWS CLI>
module Amazonka.APIGateway.GetAuthorizer
  ( -- * Creating a Request
    GetAuthorizer (..),
    newGetAuthorizer,

    -- * Request Lenses
    getAuthorizer_restApiId,
    getAuthorizer_authorizerId,

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

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

import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | [Required] The string identifier of the associated RestApi.
    GetAuthorizer -> Text
restApiId :: Prelude.Text,
    -- | [Required] The identifier of the Authorizer resource.
    GetAuthorizer -> Text
authorizerId :: Prelude.Text
  }
  deriving (GetAuthorizer -> GetAuthorizer -> Bool
(GetAuthorizer -> GetAuthorizer -> Bool)
-> (GetAuthorizer -> GetAuthorizer -> Bool) -> Eq GetAuthorizer
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]
(Int -> ReadS GetAuthorizer)
-> ReadS [GetAuthorizer]
-> ReadPrec GetAuthorizer
-> ReadPrec [GetAuthorizer]
-> Read 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
(Int -> GetAuthorizer -> ShowS)
-> (GetAuthorizer -> String)
-> ([GetAuthorizer] -> ShowS)
-> Show GetAuthorizer
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. GetAuthorizer -> Rep GetAuthorizer x)
-> (forall x. Rep GetAuthorizer x -> GetAuthorizer)
-> Generic GetAuthorizer
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' - [Required] The string identifier of the associated RestApi.
--
-- 'authorizerId', 'getAuthorizer_authorizerId' - [Required] The identifier of the Authorizer resource.
newGetAuthorizer ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'authorizerId'
  Prelude.Text ->
  GetAuthorizer
newGetAuthorizer :: Text -> Text -> GetAuthorizer
newGetAuthorizer Text
pRestApiId_ Text
pAuthorizerId_ =
  GetAuthorizer' :: Text -> Text -> GetAuthorizer
GetAuthorizer'
    { $sel:restApiId:GetAuthorizer' :: Text
restApiId = Text
pRestApiId_,
      $sel:authorizerId:GetAuthorizer' :: Text
authorizerId = Text
pAuthorizerId_
    }

-- | [Required] The string identifier of the associated RestApi.
getAuthorizer_restApiId :: Lens.Lens' GetAuthorizer Prelude.Text
getAuthorizer_restApiId :: (Text -> f Text) -> GetAuthorizer -> f GetAuthorizer
getAuthorizer_restApiId = (GetAuthorizer -> Text)
-> (GetAuthorizer -> Text -> GetAuthorizer)
-> Lens GetAuthorizer GetAuthorizer Text Text
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)

-- | [Required] The identifier of the Authorizer resource.
getAuthorizer_authorizerId :: Lens.Lens' GetAuthorizer Prelude.Text
getAuthorizer_authorizerId :: (Text -> f Text) -> GetAuthorizer -> f GetAuthorizer
getAuthorizer_authorizerId = (GetAuthorizer -> Text)
-> (GetAuthorizer -> Text -> GetAuthorizer)
-> Lens GetAuthorizer GetAuthorizer Text Text
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 :: GetAuthorizer -> Request GetAuthorizer
request = Service -> GetAuthorizer -> Request GetAuthorizer
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAuthorizer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAuthorizer)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetAuthorizer))
-> Logger
-> Service
-> Proxy GetAuthorizer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAuthorizer)))
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 -> Object -> Either String Authorizer
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetAuthorizer

instance Prelude.NFData GetAuthorizer

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

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

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