{-# 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.GetIntegration
-- 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)
--
-- Get the integration settings.
module Amazonka.APIGateway.GetIntegration
  ( -- * Creating a Request
    GetIntegration (..),
    newGetIntegration,

    -- * Request Lenses
    getIntegration_restApiId,
    getIntegration_resourceId,
    getIntegration_httpMethod,

    -- * Destructuring the Response
    Integration (..),
    newIntegration,

    -- * Response Lenses
    integration_httpMethod,
    integration_requestTemplates,
    integration_credentials,
    integration_connectionId,
    integration_requestParameters,
    integration_contentHandling,
    integration_passthroughBehavior,
    integration_uri,
    integration_integrationResponses,
    integration_tlsConfig,
    integration_cacheNamespace,
    integration_timeoutInMillis,
    integration_type,
    integration_connectionType,
    integration_cacheKeyParameters,
  )
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 request to get the integration configuration.
--
-- /See:/ 'newGetIntegration' smart constructor.
data GetIntegration = GetIntegration'
  { -- | [Required] The string identifier of the associated RestApi.
    GetIntegration -> Text
restApiId :: Prelude.Text,
    -- | [Required] Specifies a get integration request\'s resource identifier
    GetIntegration -> Text
resourceId :: Prelude.Text,
    -- | [Required] Specifies a get integration request\'s HTTP method.
    GetIntegration -> Text
httpMethod :: Prelude.Text
  }
  deriving (GetIntegration -> GetIntegration -> Bool
(GetIntegration -> GetIntegration -> Bool)
-> (GetIntegration -> GetIntegration -> Bool) -> Eq GetIntegration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIntegration -> GetIntegration -> Bool
$c/= :: GetIntegration -> GetIntegration -> Bool
== :: GetIntegration -> GetIntegration -> Bool
$c== :: GetIntegration -> GetIntegration -> Bool
Prelude.Eq, ReadPrec [GetIntegration]
ReadPrec GetIntegration
Int -> ReadS GetIntegration
ReadS [GetIntegration]
(Int -> ReadS GetIntegration)
-> ReadS [GetIntegration]
-> ReadPrec GetIntegration
-> ReadPrec [GetIntegration]
-> Read GetIntegration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetIntegration]
$creadListPrec :: ReadPrec [GetIntegration]
readPrec :: ReadPrec GetIntegration
$creadPrec :: ReadPrec GetIntegration
readList :: ReadS [GetIntegration]
$creadList :: ReadS [GetIntegration]
readsPrec :: Int -> ReadS GetIntegration
$creadsPrec :: Int -> ReadS GetIntegration
Prelude.Read, Int -> GetIntegration -> ShowS
[GetIntegration] -> ShowS
GetIntegration -> String
(Int -> GetIntegration -> ShowS)
-> (GetIntegration -> String)
-> ([GetIntegration] -> ShowS)
-> Show GetIntegration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIntegration] -> ShowS
$cshowList :: [GetIntegration] -> ShowS
show :: GetIntegration -> String
$cshow :: GetIntegration -> String
showsPrec :: Int -> GetIntegration -> ShowS
$cshowsPrec :: Int -> GetIntegration -> ShowS
Prelude.Show, (forall x. GetIntegration -> Rep GetIntegration x)
-> (forall x. Rep GetIntegration x -> GetIntegration)
-> Generic GetIntegration
forall x. Rep GetIntegration x -> GetIntegration
forall x. GetIntegration -> Rep GetIntegration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetIntegration x -> GetIntegration
$cfrom :: forall x. GetIntegration -> Rep GetIntegration x
Prelude.Generic)

-- |
-- Create a value of 'GetIntegration' 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', 'getIntegration_restApiId' - [Required] The string identifier of the associated RestApi.
--
-- 'resourceId', 'getIntegration_resourceId' - [Required] Specifies a get integration request\'s resource identifier
--
-- 'httpMethod', 'getIntegration_httpMethod' - [Required] Specifies a get integration request\'s HTTP method.
newGetIntegration ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'httpMethod'
  Prelude.Text ->
  GetIntegration
newGetIntegration :: Text -> Text -> Text -> GetIntegration
newGetIntegration
  Text
pRestApiId_
  Text
pResourceId_
  Text
pHttpMethod_ =
    GetIntegration' :: Text -> Text -> Text -> GetIntegration
GetIntegration'
      { $sel:restApiId:GetIntegration' :: Text
restApiId = Text
pRestApiId_,
        $sel:resourceId:GetIntegration' :: Text
resourceId = Text
pResourceId_,
        $sel:httpMethod:GetIntegration' :: Text
httpMethod = Text
pHttpMethod_
      }

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

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

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

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

instance Prelude.Hashable GetIntegration

instance Prelude.NFData GetIntegration

instance Core.ToHeaders GetIntegration where
  toHeaders :: GetIntegration -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetIntegration -> 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 GetIntegration where
  toPath :: GetIntegration -> ByteString
toPath GetIntegration' {Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
$sel:httpMethod:GetIntegration' :: GetIntegration -> Text
$sel:resourceId:GetIntegration' :: GetIntegration -> Text
$sel:restApiId:GetIntegration' :: GetIntegration -> 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"
      ]

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