{-# 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.GetIntegrationResponse
-- 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)
--
-- Represents a get integration response.
module Amazonka.APIGateway.GetIntegrationResponse
  ( -- * Creating a Request
    GetIntegrationResponse (..),
    newGetIntegrationResponse,

    -- * Request Lenses
    getIntegrationResponse_restApiId,
    getIntegrationResponse_resourceId,
    getIntegrationResponse_httpMethod,
    getIntegrationResponse_statusCode,

    -- * Destructuring the Response
    IntegrationResponse (..),
    newIntegrationResponse,

    -- * Response Lenses
    integrationResponse_contentHandling,
    integrationResponse_responseTemplates,
    integrationResponse_selectionPattern,
    integrationResponse_statusCode,
    integrationResponse_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

-- | Represents a get integration response request.
--
-- /See:/ 'newGetIntegrationResponse' smart constructor.
data GetIntegrationResponse = GetIntegrationResponse'
  { -- | [Required] The string identifier of the associated RestApi.
    GetIntegrationResponse -> Text
restApiId :: Prelude.Text,
    -- | [Required] Specifies a get integration response request\'s resource
    -- identifier.
    GetIntegrationResponse -> Text
resourceId :: Prelude.Text,
    -- | [Required] Specifies a get integration response request\'s HTTP method.
    GetIntegrationResponse -> Text
httpMethod :: Prelude.Text,
    -- | [Required] Specifies a get integration response request\'s status code.
    GetIntegrationResponse -> Text
statusCode :: Prelude.Text
  }
  deriving (GetIntegrationResponse -> GetIntegrationResponse -> Bool
(GetIntegrationResponse -> GetIntegrationResponse -> Bool)
-> (GetIntegrationResponse -> GetIntegrationResponse -> Bool)
-> Eq GetIntegrationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIntegrationResponse -> GetIntegrationResponse -> Bool
$c/= :: GetIntegrationResponse -> GetIntegrationResponse -> Bool
== :: GetIntegrationResponse -> GetIntegrationResponse -> Bool
$c== :: GetIntegrationResponse -> GetIntegrationResponse -> Bool
Prelude.Eq, ReadPrec [GetIntegrationResponse]
ReadPrec GetIntegrationResponse
Int -> ReadS GetIntegrationResponse
ReadS [GetIntegrationResponse]
(Int -> ReadS GetIntegrationResponse)
-> ReadS [GetIntegrationResponse]
-> ReadPrec GetIntegrationResponse
-> ReadPrec [GetIntegrationResponse]
-> Read GetIntegrationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetIntegrationResponse]
$creadListPrec :: ReadPrec [GetIntegrationResponse]
readPrec :: ReadPrec GetIntegrationResponse
$creadPrec :: ReadPrec GetIntegrationResponse
readList :: ReadS [GetIntegrationResponse]
$creadList :: ReadS [GetIntegrationResponse]
readsPrec :: Int -> ReadS GetIntegrationResponse
$creadsPrec :: Int -> ReadS GetIntegrationResponse
Prelude.Read, Int -> GetIntegrationResponse -> ShowS
[GetIntegrationResponse] -> ShowS
GetIntegrationResponse -> String
(Int -> GetIntegrationResponse -> ShowS)
-> (GetIntegrationResponse -> String)
-> ([GetIntegrationResponse] -> ShowS)
-> Show GetIntegrationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIntegrationResponse] -> ShowS
$cshowList :: [GetIntegrationResponse] -> ShowS
show :: GetIntegrationResponse -> String
$cshow :: GetIntegrationResponse -> String
showsPrec :: Int -> GetIntegrationResponse -> ShowS
$cshowsPrec :: Int -> GetIntegrationResponse -> ShowS
Prelude.Show, (forall x. GetIntegrationResponse -> Rep GetIntegrationResponse x)
-> (forall x.
    Rep GetIntegrationResponse x -> GetIntegrationResponse)
-> Generic GetIntegrationResponse
forall x. Rep GetIntegrationResponse x -> GetIntegrationResponse
forall x. GetIntegrationResponse -> Rep GetIntegrationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetIntegrationResponse x -> GetIntegrationResponse
$cfrom :: forall x. GetIntegrationResponse -> Rep GetIntegrationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetIntegrationResponse' 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', 'getIntegrationResponse_restApiId' - [Required] The string identifier of the associated RestApi.
--
-- 'resourceId', 'getIntegrationResponse_resourceId' - [Required] Specifies a get integration response request\'s resource
-- identifier.
--
-- 'httpMethod', 'getIntegrationResponse_httpMethod' - [Required] Specifies a get integration response request\'s HTTP method.
--
-- 'statusCode', 'getIntegrationResponse_statusCode' - [Required] Specifies a get integration response request\'s status code.
newGetIntegrationResponse ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'httpMethod'
  Prelude.Text ->
  -- | 'statusCode'
  Prelude.Text ->
  GetIntegrationResponse
newGetIntegrationResponse :: Text -> Text -> Text -> Text -> GetIntegrationResponse
newGetIntegrationResponse
  Text
pRestApiId_
  Text
pResourceId_
  Text
pHttpMethod_
  Text
pStatusCode_ =
    GetIntegrationResponse' :: Text -> Text -> Text -> Text -> GetIntegrationResponse
GetIntegrationResponse'
      { $sel:restApiId:GetIntegrationResponse' :: Text
restApiId = Text
pRestApiId_,
        $sel:resourceId:GetIntegrationResponse' :: Text
resourceId = Text
pResourceId_,
        $sel:httpMethod:GetIntegrationResponse' :: Text
httpMethod = Text
pHttpMethod_,
        $sel:statusCode:GetIntegrationResponse' :: Text
statusCode = Text
pStatusCode_
      }

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

-- | [Required] Specifies a get integration response request\'s resource
-- identifier.
getIntegrationResponse_resourceId :: Lens.Lens' GetIntegrationResponse Prelude.Text
getIntegrationResponse_resourceId :: (Text -> f Text)
-> GetIntegrationResponse -> f GetIntegrationResponse
getIntegrationResponse_resourceId = (GetIntegrationResponse -> Text)
-> (GetIntegrationResponse -> Text -> GetIntegrationResponse)
-> Lens GetIntegrationResponse GetIntegrationResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIntegrationResponse' {Text
resourceId :: Text
$sel:resourceId:GetIntegrationResponse' :: GetIntegrationResponse -> Text
resourceId} -> Text
resourceId) (\s :: GetIntegrationResponse
s@GetIntegrationResponse' {} Text
a -> GetIntegrationResponse
s {$sel:resourceId:GetIntegrationResponse' :: Text
resourceId = Text
a} :: GetIntegrationResponse)

-- | [Required] Specifies a get integration response request\'s HTTP method.
getIntegrationResponse_httpMethod :: Lens.Lens' GetIntegrationResponse Prelude.Text
getIntegrationResponse_httpMethod :: (Text -> f Text)
-> GetIntegrationResponse -> f GetIntegrationResponse
getIntegrationResponse_httpMethod = (GetIntegrationResponse -> Text)
-> (GetIntegrationResponse -> Text -> GetIntegrationResponse)
-> Lens GetIntegrationResponse GetIntegrationResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIntegrationResponse' {Text
httpMethod :: Text
$sel:httpMethod:GetIntegrationResponse' :: GetIntegrationResponse -> Text
httpMethod} -> Text
httpMethod) (\s :: GetIntegrationResponse
s@GetIntegrationResponse' {} Text
a -> GetIntegrationResponse
s {$sel:httpMethod:GetIntegrationResponse' :: Text
httpMethod = Text
a} :: GetIntegrationResponse)

-- | [Required] Specifies a get integration response request\'s status code.
getIntegrationResponse_statusCode :: Lens.Lens' GetIntegrationResponse Prelude.Text
getIntegrationResponse_statusCode :: (Text -> f Text)
-> GetIntegrationResponse -> f GetIntegrationResponse
getIntegrationResponse_statusCode = (GetIntegrationResponse -> Text)
-> (GetIntegrationResponse -> Text -> GetIntegrationResponse)
-> Lens GetIntegrationResponse GetIntegrationResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIntegrationResponse' {Text
statusCode :: Text
$sel:statusCode:GetIntegrationResponse' :: GetIntegrationResponse -> Text
statusCode} -> Text
statusCode) (\s :: GetIntegrationResponse
s@GetIntegrationResponse' {} Text
a -> GetIntegrationResponse
s {$sel:statusCode:GetIntegrationResponse' :: Text
statusCode = Text
a} :: GetIntegrationResponse)

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

instance Prelude.Hashable GetIntegrationResponse

instance Prelude.NFData GetIntegrationResponse

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

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