{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_cacheKeyParameters,
    integration_cacheNamespace,
    integration_connectionId,
    integration_connectionType,
    integration_contentHandling,
    integration_credentials,
    integration_httpMethod,
    integration_integrationResponses,
    integration_passthroughBehavior,
    integration_requestParameters,
    integration_requestTemplates,
    integration_timeoutInMillis,
    integration_tlsConfig,
    integration_type,
    integration_uri,
  )
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

-- | Represents a request to get the integration configuration.
--
-- /See:/ 'newGetIntegration' smart constructor.
data GetIntegration = GetIntegration'
  { -- | The string identifier of the associated RestApi.
    GetIntegration -> Text
restApiId :: Prelude.Text,
    -- | Specifies a get integration request\'s resource identifier
    GetIntegration -> Text
resourceId :: Prelude.Text,
    -- | Specifies a get integration request\'s HTTP method.
    GetIntegration -> Text
httpMethod :: Prelude.Text
  }
  deriving (GetIntegration -> GetIntegration -> Bool
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]
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
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. 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' - The string identifier of the associated RestApi.
--
-- 'resourceId', 'getIntegration_resourceId' - Specifies a get integration request\'s resource identifier
--
-- 'httpMethod', 'getIntegration_httpMethod' - 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'
      { $sel:restApiId:GetIntegration' :: Text
restApiId = Text
pRestApiId_,
        $sel:resourceId:GetIntegration' :: Text
resourceId = Text
pResourceId_,
        $sel:httpMethod:GetIntegration' :: Text
httpMethod = Text
pHttpMethod_
      }

-- | The string identifier of the associated RestApi.
getIntegration_restApiId :: Lens.Lens' GetIntegration Prelude.Text
getIntegration_restApiId :: Lens' GetIntegration Text
getIntegration_restApiId = 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)

-- | Specifies a get integration request\'s resource identifier
getIntegration_resourceId :: Lens.Lens' GetIntegration Prelude.Text
getIntegration_resourceId :: Lens' GetIntegration Text
getIntegration_resourceId = 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)

-- | Specifies a get integration request\'s HTTP method.
getIntegration_httpMethod :: Lens.Lens' GetIntegration Prelude.Text
getIntegration_httpMethod :: Lens' GetIntegration Text
getIntegration_httpMethod = 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 :: (Service -> Service) -> GetIntegration -> Request GetIntegration
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 GetIntegration
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetIntegration)))
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 GetIntegration where
  hashWithSalt :: Int -> GetIntegration -> Int
hashWithSalt Int
_salt GetIntegration' {Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
$sel:httpMethod:GetIntegration' :: GetIntegration -> Text
$sel:resourceId:GetIntegration' :: GetIntegration -> Text
$sel:restApiId:GetIntegration' :: GetIntegration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
httpMethod

instance Prelude.NFData GetIntegration where
  rnf :: GetIntegration -> ()
rnf GetIntegration' {Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
$sel:httpMethod:GetIntegration' :: GetIntegration -> Text
$sel:resourceId:GetIntegration' :: GetIntegration -> Text
$sel:restApiId:GetIntegration' :: GetIntegration -> 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 Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
httpMethod

instance Data.ToHeaders GetIntegration where
  toHeaders :: GetIntegration -> 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 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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId,
        ByteString
"/resources/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
resourceId,
        ByteString
"/methods/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
httpMethod,
        ByteString
"/integration"
      ]

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