{-# 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.GetRequestValidator
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets a RequestValidator of a given RestApi.
module Amazonka.APIGateway.GetRequestValidator
  ( -- * Creating a Request
    GetRequestValidator (..),
    newGetRequestValidator,

    -- * Request Lenses
    getRequestValidator_restApiId,
    getRequestValidator_requestValidatorId,

    -- * Destructuring the Response
    RequestValidator (..),
    newRequestValidator,

    -- * Response Lenses
    requestValidator_id,
    requestValidator_name,
    requestValidator_validateRequestBody,
    requestValidator_validateRequestParameters,
  )
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

-- | Gets a RequestValidator of a given RestApi.
--
-- /See:/ 'newGetRequestValidator' smart constructor.
data GetRequestValidator = GetRequestValidator'
  { -- | The string identifier of the associated RestApi.
    GetRequestValidator -> Text
restApiId :: Prelude.Text,
    -- | The identifier of the RequestValidator to be retrieved.
    GetRequestValidator -> Text
requestValidatorId :: Prelude.Text
  }
  deriving (GetRequestValidator -> GetRequestValidator -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRequestValidator -> GetRequestValidator -> Bool
$c/= :: GetRequestValidator -> GetRequestValidator -> Bool
== :: GetRequestValidator -> GetRequestValidator -> Bool
$c== :: GetRequestValidator -> GetRequestValidator -> Bool
Prelude.Eq, ReadPrec [GetRequestValidator]
ReadPrec GetRequestValidator
Int -> ReadS GetRequestValidator
ReadS [GetRequestValidator]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRequestValidator]
$creadListPrec :: ReadPrec [GetRequestValidator]
readPrec :: ReadPrec GetRequestValidator
$creadPrec :: ReadPrec GetRequestValidator
readList :: ReadS [GetRequestValidator]
$creadList :: ReadS [GetRequestValidator]
readsPrec :: Int -> ReadS GetRequestValidator
$creadsPrec :: Int -> ReadS GetRequestValidator
Prelude.Read, Int -> GetRequestValidator -> ShowS
[GetRequestValidator] -> ShowS
GetRequestValidator -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRequestValidator] -> ShowS
$cshowList :: [GetRequestValidator] -> ShowS
show :: GetRequestValidator -> String
$cshow :: GetRequestValidator -> String
showsPrec :: Int -> GetRequestValidator -> ShowS
$cshowsPrec :: Int -> GetRequestValidator -> ShowS
Prelude.Show, forall x. Rep GetRequestValidator x -> GetRequestValidator
forall x. GetRequestValidator -> Rep GetRequestValidator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRequestValidator x -> GetRequestValidator
$cfrom :: forall x. GetRequestValidator -> Rep GetRequestValidator x
Prelude.Generic)

-- |
-- Create a value of 'GetRequestValidator' 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', 'getRequestValidator_restApiId' - The string identifier of the associated RestApi.
--
-- 'requestValidatorId', 'getRequestValidator_requestValidatorId' - The identifier of the RequestValidator to be retrieved.
newGetRequestValidator ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'requestValidatorId'
  Prelude.Text ->
  GetRequestValidator
newGetRequestValidator :: Text -> Text -> GetRequestValidator
newGetRequestValidator
  Text
pRestApiId_
  Text
pRequestValidatorId_ =
    GetRequestValidator'
      { $sel:restApiId:GetRequestValidator' :: Text
restApiId = Text
pRestApiId_,
        $sel:requestValidatorId:GetRequestValidator' :: Text
requestValidatorId = Text
pRequestValidatorId_
      }

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

-- | The identifier of the RequestValidator to be retrieved.
getRequestValidator_requestValidatorId :: Lens.Lens' GetRequestValidator Prelude.Text
getRequestValidator_requestValidatorId :: Lens' GetRequestValidator Text
getRequestValidator_requestValidatorId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRequestValidator' {Text
requestValidatorId :: Text
$sel:requestValidatorId:GetRequestValidator' :: GetRequestValidator -> Text
requestValidatorId} -> Text
requestValidatorId) (\s :: GetRequestValidator
s@GetRequestValidator' {} Text
a -> GetRequestValidator
s {$sel:requestValidatorId:GetRequestValidator' :: Text
requestValidatorId = Text
a} :: GetRequestValidator)

instance Core.AWSRequest GetRequestValidator where
  type
    AWSResponse GetRequestValidator =
      RequestValidator
  request :: (Service -> Service)
-> GetRequestValidator -> Request GetRequestValidator
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 GetRequestValidator
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRequestValidator)))
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 GetRequestValidator where
  hashWithSalt :: Int -> GetRequestValidator -> Int
hashWithSalt Int
_salt GetRequestValidator' {Text
requestValidatorId :: Text
restApiId :: Text
$sel:requestValidatorId:GetRequestValidator' :: GetRequestValidator -> Text
$sel:restApiId:GetRequestValidator' :: GetRequestValidator -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
requestValidatorId

instance Prelude.NFData GetRequestValidator where
  rnf :: GetRequestValidator -> ()
rnf GetRequestValidator' {Text
requestValidatorId :: Text
restApiId :: Text
$sel:requestValidatorId:GetRequestValidator' :: GetRequestValidator -> Text
$sel:restApiId:GetRequestValidator' :: GetRequestValidator -> 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
requestValidatorId

instance Data.ToHeaders GetRequestValidator where
  toHeaders :: GetRequestValidator -> 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 GetRequestValidator where
  toPath :: GetRequestValidator -> ByteString
toPath GetRequestValidator' {Text
requestValidatorId :: Text
restApiId :: Text
$sel:requestValidatorId:GetRequestValidator' :: GetRequestValidator -> Text
$sel:restApiId:GetRequestValidator' :: GetRequestValidator -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId,
        ByteString
"/requestvalidators/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
requestValidatorId
      ]

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