{-# 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.GetGatewayResponse
-- 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 GatewayResponse of a specified response type on the given
-- RestApi.
module Amazonka.APIGateway.GetGatewayResponse
  ( -- * Creating a Request
    GetGatewayResponse (..),
    newGetGatewayResponse,

    -- * Request Lenses
    getGatewayResponse_restApiId,
    getGatewayResponse_responseType,

    -- * Destructuring the Response
    GatewayResponse (..),
    newGatewayResponse,

    -- * Response Lenses
    gatewayResponse_defaultResponse,
    gatewayResponse_responseParameters,
    gatewayResponse_responseTemplates,
    gatewayResponse_responseType,
    gatewayResponse_statusCode,
  )
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 GatewayResponse of a specified response type on the given
-- RestApi.
--
-- /See:/ 'newGetGatewayResponse' smart constructor.
data GetGatewayResponse = GetGatewayResponse'
  { -- | The string identifier of the associated RestApi.
    GetGatewayResponse -> Text
restApiId :: Prelude.Text,
    -- | The response type of the associated GatewayResponse.
    GetGatewayResponse -> GatewayResponseType
responseType :: GatewayResponseType
  }
  deriving (GetGatewayResponse -> GetGatewayResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetGatewayResponse -> GetGatewayResponse -> Bool
$c/= :: GetGatewayResponse -> GetGatewayResponse -> Bool
== :: GetGatewayResponse -> GetGatewayResponse -> Bool
$c== :: GetGatewayResponse -> GetGatewayResponse -> Bool
Prelude.Eq, ReadPrec [GetGatewayResponse]
ReadPrec GetGatewayResponse
Int -> ReadS GetGatewayResponse
ReadS [GetGatewayResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetGatewayResponse]
$creadListPrec :: ReadPrec [GetGatewayResponse]
readPrec :: ReadPrec GetGatewayResponse
$creadPrec :: ReadPrec GetGatewayResponse
readList :: ReadS [GetGatewayResponse]
$creadList :: ReadS [GetGatewayResponse]
readsPrec :: Int -> ReadS GetGatewayResponse
$creadsPrec :: Int -> ReadS GetGatewayResponse
Prelude.Read, Int -> GetGatewayResponse -> ShowS
[GetGatewayResponse] -> ShowS
GetGatewayResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetGatewayResponse] -> ShowS
$cshowList :: [GetGatewayResponse] -> ShowS
show :: GetGatewayResponse -> String
$cshow :: GetGatewayResponse -> String
showsPrec :: Int -> GetGatewayResponse -> ShowS
$cshowsPrec :: Int -> GetGatewayResponse -> ShowS
Prelude.Show, forall x. Rep GetGatewayResponse x -> GetGatewayResponse
forall x. GetGatewayResponse -> Rep GetGatewayResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetGatewayResponse x -> GetGatewayResponse
$cfrom :: forall x. GetGatewayResponse -> Rep GetGatewayResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetGatewayResponse' 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', 'getGatewayResponse_restApiId' - The string identifier of the associated RestApi.
--
-- 'responseType', 'getGatewayResponse_responseType' - The response type of the associated GatewayResponse.
newGetGatewayResponse ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'responseType'
  GatewayResponseType ->
  GetGatewayResponse
newGetGatewayResponse :: Text -> GatewayResponseType -> GetGatewayResponse
newGetGatewayResponse Text
pRestApiId_ GatewayResponseType
pResponseType_ =
  GetGatewayResponse'
    { $sel:restApiId:GetGatewayResponse' :: Text
restApiId = Text
pRestApiId_,
      $sel:responseType:GetGatewayResponse' :: GatewayResponseType
responseType = GatewayResponseType
pResponseType_
    }

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

-- | The response type of the associated GatewayResponse.
getGatewayResponse_responseType :: Lens.Lens' GetGatewayResponse GatewayResponseType
getGatewayResponse_responseType :: Lens' GetGatewayResponse GatewayResponseType
getGatewayResponse_responseType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGatewayResponse' {GatewayResponseType
responseType :: GatewayResponseType
$sel:responseType:GetGatewayResponse' :: GetGatewayResponse -> GatewayResponseType
responseType} -> GatewayResponseType
responseType) (\s :: GetGatewayResponse
s@GetGatewayResponse' {} GatewayResponseType
a -> GetGatewayResponse
s {$sel:responseType:GetGatewayResponse' :: GatewayResponseType
responseType = GatewayResponseType
a} :: GetGatewayResponse)

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

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

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

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