{-# 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-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)
--
-- 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_validateRequestParameters,
    requestValidator_name,
    requestValidator_validateRequestBody,
    requestValidator_id,
  )
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

-- | Gets a RequestValidator of a given RestApi.
--
-- /See:/ 'newGetRequestValidator' smart constructor.
data GetRequestValidator = GetRequestValidator'
  { -- | [Required] The string identifier of the associated RestApi.
    GetRequestValidator -> Text
restApiId :: Prelude.Text,
    -- | [Required] The identifier of the RequestValidator to be retrieved.
    GetRequestValidator -> Text
requestValidatorId :: Prelude.Text
  }
  deriving (GetRequestValidator -> GetRequestValidator -> Bool
(GetRequestValidator -> GetRequestValidator -> Bool)
-> (GetRequestValidator -> GetRequestValidator -> Bool)
-> Eq GetRequestValidator
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]
(Int -> ReadS GetRequestValidator)
-> ReadS [GetRequestValidator]
-> ReadPrec GetRequestValidator
-> ReadPrec [GetRequestValidator]
-> Read 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
(Int -> GetRequestValidator -> ShowS)
-> (GetRequestValidator -> String)
-> ([GetRequestValidator] -> ShowS)
-> Show GetRequestValidator
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. GetRequestValidator -> Rep GetRequestValidator x)
-> (forall x. Rep GetRequestValidator x -> GetRequestValidator)
-> Generic GetRequestValidator
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' - [Required] The string identifier of the associated RestApi.
--
-- 'requestValidatorId', 'getRequestValidator_requestValidatorId' - [Required] 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' :: Text -> Text -> GetRequestValidator
GetRequestValidator'
      { $sel:restApiId:GetRequestValidator' :: Text
restApiId = Text
pRestApiId_,
        $sel:requestValidatorId:GetRequestValidator' :: Text
requestValidatorId = Text
pRequestValidatorId_
      }

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

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

instance Prelude.Hashable GetRequestValidator

instance Prelude.NFData GetRequestValidator

instance Core.ToHeaders GetRequestValidator where
  toHeaders :: GetRequestValidator -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetRequestValidator -> 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 GetRequestValidator where
  toPath :: GetRequestValidator -> ByteString
toPath GetRequestValidator' {Text
requestValidatorId :: Text
restApiId :: Text
$sel:requestValidatorId:GetRequestValidator' :: GetRequestValidator -> Text
$sel:restApiId:GetRequestValidator' :: GetRequestValidator -> 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
"/requestvalidators/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
requestValidatorId
      ]

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