{-# 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.GetMethodResponse
-- 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)
--
-- Describes a MethodResponse resource.
module Amazonka.APIGateway.GetMethodResponse
  ( -- * Creating a Request
    GetMethodResponse (..),
    newGetMethodResponse,

    -- * Request Lenses
    getMethodResponse_restApiId,
    getMethodResponse_resourceId,
    getMethodResponse_httpMethod,
    getMethodResponse_statusCode,

    -- * Destructuring the Response
    MethodResponse (..),
    newMethodResponse,

    -- * Response Lenses
    methodResponse_responseModels,
    methodResponse_statusCode,
    methodResponse_responseParameters,
  )
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 a MethodResponse resource.
--
-- /See:/ 'newGetMethodResponse' smart constructor.
data GetMethodResponse = GetMethodResponse'
  { -- | [Required] The string identifier of the associated RestApi.
    GetMethodResponse -> Text
restApiId :: Prelude.Text,
    -- | [Required] The Resource identifier for the MethodResponse resource.
    GetMethodResponse -> Text
resourceId :: Prelude.Text,
    -- | [Required] The HTTP verb of the Method resource.
    GetMethodResponse -> Text
httpMethod :: Prelude.Text,
    -- | [Required] The status code for the MethodResponse resource.
    GetMethodResponse -> Text
statusCode :: Prelude.Text
  }
  deriving (GetMethodResponse -> GetMethodResponse -> Bool
(GetMethodResponse -> GetMethodResponse -> Bool)
-> (GetMethodResponse -> GetMethodResponse -> Bool)
-> Eq GetMethodResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMethodResponse -> GetMethodResponse -> Bool
$c/= :: GetMethodResponse -> GetMethodResponse -> Bool
== :: GetMethodResponse -> GetMethodResponse -> Bool
$c== :: GetMethodResponse -> GetMethodResponse -> Bool
Prelude.Eq, ReadPrec [GetMethodResponse]
ReadPrec GetMethodResponse
Int -> ReadS GetMethodResponse
ReadS [GetMethodResponse]
(Int -> ReadS GetMethodResponse)
-> ReadS [GetMethodResponse]
-> ReadPrec GetMethodResponse
-> ReadPrec [GetMethodResponse]
-> Read GetMethodResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMethodResponse]
$creadListPrec :: ReadPrec [GetMethodResponse]
readPrec :: ReadPrec GetMethodResponse
$creadPrec :: ReadPrec GetMethodResponse
readList :: ReadS [GetMethodResponse]
$creadList :: ReadS [GetMethodResponse]
readsPrec :: Int -> ReadS GetMethodResponse
$creadsPrec :: Int -> ReadS GetMethodResponse
Prelude.Read, Int -> GetMethodResponse -> ShowS
[GetMethodResponse] -> ShowS
GetMethodResponse -> String
(Int -> GetMethodResponse -> ShowS)
-> (GetMethodResponse -> String)
-> ([GetMethodResponse] -> ShowS)
-> Show GetMethodResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMethodResponse] -> ShowS
$cshowList :: [GetMethodResponse] -> ShowS
show :: GetMethodResponse -> String
$cshow :: GetMethodResponse -> String
showsPrec :: Int -> GetMethodResponse -> ShowS
$cshowsPrec :: Int -> GetMethodResponse -> ShowS
Prelude.Show, (forall x. GetMethodResponse -> Rep GetMethodResponse x)
-> (forall x. Rep GetMethodResponse x -> GetMethodResponse)
-> Generic GetMethodResponse
forall x. Rep GetMethodResponse x -> GetMethodResponse
forall x. GetMethodResponse -> Rep GetMethodResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMethodResponse x -> GetMethodResponse
$cfrom :: forall x. GetMethodResponse -> Rep GetMethodResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetMethodResponse' 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', 'getMethodResponse_restApiId' - [Required] The string identifier of the associated RestApi.
--
-- 'resourceId', 'getMethodResponse_resourceId' - [Required] The Resource identifier for the MethodResponse resource.
--
-- 'httpMethod', 'getMethodResponse_httpMethod' - [Required] The HTTP verb of the Method resource.
--
-- 'statusCode', 'getMethodResponse_statusCode' - [Required] The status code for the MethodResponse resource.
newGetMethodResponse ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'httpMethod'
  Prelude.Text ->
  -- | 'statusCode'
  Prelude.Text ->
  GetMethodResponse
newGetMethodResponse :: Text -> Text -> Text -> Text -> GetMethodResponse
newGetMethodResponse
  Text
pRestApiId_
  Text
pResourceId_
  Text
pHttpMethod_
  Text
pStatusCode_ =
    GetMethodResponse' :: Text -> Text -> Text -> Text -> GetMethodResponse
GetMethodResponse'
      { $sel:restApiId:GetMethodResponse' :: Text
restApiId = Text
pRestApiId_,
        $sel:resourceId:GetMethodResponse' :: Text
resourceId = Text
pResourceId_,
        $sel:httpMethod:GetMethodResponse' :: Text
httpMethod = Text
pHttpMethod_,
        $sel:statusCode:GetMethodResponse' :: Text
statusCode = Text
pStatusCode_
      }

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

-- | [Required] The Resource identifier for the MethodResponse resource.
getMethodResponse_resourceId :: Lens.Lens' GetMethodResponse Prelude.Text
getMethodResponse_resourceId :: (Text -> f Text) -> GetMethodResponse -> f GetMethodResponse
getMethodResponse_resourceId = (GetMethodResponse -> Text)
-> (GetMethodResponse -> Text -> GetMethodResponse)
-> Lens GetMethodResponse GetMethodResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMethodResponse' {Text
resourceId :: Text
$sel:resourceId:GetMethodResponse' :: GetMethodResponse -> Text
resourceId} -> Text
resourceId) (\s :: GetMethodResponse
s@GetMethodResponse' {} Text
a -> GetMethodResponse
s {$sel:resourceId:GetMethodResponse' :: Text
resourceId = Text
a} :: GetMethodResponse)

-- | [Required] The HTTP verb of the Method resource.
getMethodResponse_httpMethod :: Lens.Lens' GetMethodResponse Prelude.Text
getMethodResponse_httpMethod :: (Text -> f Text) -> GetMethodResponse -> f GetMethodResponse
getMethodResponse_httpMethod = (GetMethodResponse -> Text)
-> (GetMethodResponse -> Text -> GetMethodResponse)
-> Lens GetMethodResponse GetMethodResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMethodResponse' {Text
httpMethod :: Text
$sel:httpMethod:GetMethodResponse' :: GetMethodResponse -> Text
httpMethod} -> Text
httpMethod) (\s :: GetMethodResponse
s@GetMethodResponse' {} Text
a -> GetMethodResponse
s {$sel:httpMethod:GetMethodResponse' :: Text
httpMethod = Text
a} :: GetMethodResponse)

-- | [Required] The status code for the MethodResponse resource.
getMethodResponse_statusCode :: Lens.Lens' GetMethodResponse Prelude.Text
getMethodResponse_statusCode :: (Text -> f Text) -> GetMethodResponse -> f GetMethodResponse
getMethodResponse_statusCode = (GetMethodResponse -> Text)
-> (GetMethodResponse -> Text -> GetMethodResponse)
-> Lens GetMethodResponse GetMethodResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMethodResponse' {Text
statusCode :: Text
$sel:statusCode:GetMethodResponse' :: GetMethodResponse -> Text
statusCode} -> Text
statusCode) (\s :: GetMethodResponse
s@GetMethodResponse' {} Text
a -> GetMethodResponse
s {$sel:statusCode:GetMethodResponse' :: Text
statusCode = Text
a} :: GetMethodResponse)

instance Core.AWSRequest GetMethodResponse where
  type AWSResponse GetMethodResponse = MethodResponse
  request :: GetMethodResponse -> Request GetMethodResponse
request = Service -> GetMethodResponse -> Request GetMethodResponse
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetMethodResponse
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetMethodResponse)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetMethodResponse))
-> Logger
-> Service
-> Proxy GetMethodResponse
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetMethodResponse)))
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 MethodResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetMethodResponse

instance Prelude.NFData GetMethodResponse

instance Core.ToHeaders GetMethodResponse where
  toHeaders :: GetMethodResponse -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetMethodResponse -> 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 GetMethodResponse where
  toPath :: GetMethodResponse -> ByteString
toPath GetMethodResponse' {Text
statusCode :: Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
$sel:statusCode:GetMethodResponse' :: GetMethodResponse -> Text
$sel:httpMethod:GetMethodResponse' :: GetMethodResponse -> Text
$sel:resourceId:GetMethodResponse' :: GetMethodResponse -> Text
$sel:restApiId:GetMethodResponse' :: GetMethodResponse -> 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
"/resources/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
resourceId,
        ByteString
"/methods/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
httpMethod,
        ByteString
"/responses/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
statusCode
      ]

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