{-# 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.UpdateIntegration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Represents an update integration.
module Amazonka.APIGateway.UpdateIntegration
  ( -- * Creating a Request
    UpdateIntegration (..),
    newUpdateIntegration,

    -- * Request Lenses
    updateIntegration_patchOperations,
    updateIntegration_restApiId,
    updateIntegration_resourceId,
    updateIntegration_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 an update integration request.
--
-- /See:/ 'newUpdateIntegration' smart constructor.
data UpdateIntegration = UpdateIntegration'
  { -- | For more information about supported patch operations, see
    -- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
    UpdateIntegration -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
    -- | The string identifier of the associated RestApi.
    UpdateIntegration -> Text
restApiId :: Prelude.Text,
    -- | Represents an update integration request\'s resource identifier.
    UpdateIntegration -> Text
resourceId :: Prelude.Text,
    -- | Represents an update integration request\'s HTTP method.
    UpdateIntegration -> Text
httpMethod :: Prelude.Text
  }
  deriving (UpdateIntegration -> UpdateIntegration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateIntegration -> UpdateIntegration -> Bool
$c/= :: UpdateIntegration -> UpdateIntegration -> Bool
== :: UpdateIntegration -> UpdateIntegration -> Bool
$c== :: UpdateIntegration -> UpdateIntegration -> Bool
Prelude.Eq, ReadPrec [UpdateIntegration]
ReadPrec UpdateIntegration
Int -> ReadS UpdateIntegration
ReadS [UpdateIntegration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateIntegration]
$creadListPrec :: ReadPrec [UpdateIntegration]
readPrec :: ReadPrec UpdateIntegration
$creadPrec :: ReadPrec UpdateIntegration
readList :: ReadS [UpdateIntegration]
$creadList :: ReadS [UpdateIntegration]
readsPrec :: Int -> ReadS UpdateIntegration
$creadsPrec :: Int -> ReadS UpdateIntegration
Prelude.Read, Int -> UpdateIntegration -> ShowS
[UpdateIntegration] -> ShowS
UpdateIntegration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateIntegration] -> ShowS
$cshowList :: [UpdateIntegration] -> ShowS
show :: UpdateIntegration -> String
$cshow :: UpdateIntegration -> String
showsPrec :: Int -> UpdateIntegration -> ShowS
$cshowsPrec :: Int -> UpdateIntegration -> ShowS
Prelude.Show, forall x. Rep UpdateIntegration x -> UpdateIntegration
forall x. UpdateIntegration -> Rep UpdateIntegration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateIntegration x -> UpdateIntegration
$cfrom :: forall x. UpdateIntegration -> Rep UpdateIntegration x
Prelude.Generic)

-- |
-- Create a value of 'UpdateIntegration' 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:
--
-- 'patchOperations', 'updateIntegration_patchOperations' - For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
--
-- 'restApiId', 'updateIntegration_restApiId' - The string identifier of the associated RestApi.
--
-- 'resourceId', 'updateIntegration_resourceId' - Represents an update integration request\'s resource identifier.
--
-- 'httpMethod', 'updateIntegration_httpMethod' - Represents an update integration request\'s HTTP method.
newUpdateIntegration ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'httpMethod'
  Prelude.Text ->
  UpdateIntegration
newUpdateIntegration :: Text -> Text -> Text -> UpdateIntegration
newUpdateIntegration
  Text
pRestApiId_
  Text
pResourceId_
  Text
pHttpMethod_ =
    UpdateIntegration'
      { $sel:patchOperations:UpdateIntegration' :: Maybe [PatchOperation]
patchOperations =
          forall a. Maybe a
Prelude.Nothing,
        $sel:restApiId:UpdateIntegration' :: Text
restApiId = Text
pRestApiId_,
        $sel:resourceId:UpdateIntegration' :: Text
resourceId = Text
pResourceId_,
        $sel:httpMethod:UpdateIntegration' :: Text
httpMethod = Text
pHttpMethod_
      }

-- | For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
updateIntegration_patchOperations :: Lens.Lens' UpdateIntegration (Prelude.Maybe [PatchOperation])
updateIntegration_patchOperations :: Lens' UpdateIntegration (Maybe [PatchOperation])
updateIntegration_patchOperations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateIntegration' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateIntegration' :: UpdateIntegration -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateIntegration
s@UpdateIntegration' {} Maybe [PatchOperation]
a -> UpdateIntegration
s {$sel:patchOperations:UpdateIntegration' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateIntegration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | Represents an update integration request\'s resource identifier.
updateIntegration_resourceId :: Lens.Lens' UpdateIntegration Prelude.Text
updateIntegration_resourceId :: Lens' UpdateIntegration Text
updateIntegration_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateIntegration' {Text
resourceId :: Text
$sel:resourceId:UpdateIntegration' :: UpdateIntegration -> Text
resourceId} -> Text
resourceId) (\s :: UpdateIntegration
s@UpdateIntegration' {} Text
a -> UpdateIntegration
s {$sel:resourceId:UpdateIntegration' :: Text
resourceId = Text
a} :: UpdateIntegration)

-- | Represents an update integration request\'s HTTP method.
updateIntegration_httpMethod :: Lens.Lens' UpdateIntegration Prelude.Text
updateIntegration_httpMethod :: Lens' UpdateIntegration Text
updateIntegration_httpMethod = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateIntegration' {Text
httpMethod :: Text
$sel:httpMethod:UpdateIntegration' :: UpdateIntegration -> Text
httpMethod} -> Text
httpMethod) (\s :: UpdateIntegration
s@UpdateIntegration' {} Text
a -> UpdateIntegration
s {$sel:httpMethod:UpdateIntegration' :: Text
httpMethod = Text
a} :: UpdateIntegration)

instance Core.AWSRequest UpdateIntegration where
  type AWSResponse UpdateIntegration = Integration
  request :: (Service -> Service)
-> UpdateIntegration -> Request UpdateIntegration
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateIntegration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateIntegration)))
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 UpdateIntegration where
  hashWithSalt :: Int -> UpdateIntegration -> Int
hashWithSalt Int
_salt UpdateIntegration' {Maybe [PatchOperation]
Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:httpMethod:UpdateIntegration' :: UpdateIntegration -> Text
$sel:resourceId:UpdateIntegration' :: UpdateIntegration -> Text
$sel:restApiId:UpdateIntegration' :: UpdateIntegration -> Text
$sel:patchOperations:UpdateIntegration' :: UpdateIntegration -> Maybe [PatchOperation]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PatchOperation]
patchOperations
      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 UpdateIntegration where
  rnf :: UpdateIntegration -> ()
rnf UpdateIntegration' {Maybe [PatchOperation]
Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:httpMethod:UpdateIntegration' :: UpdateIntegration -> Text
$sel:resourceId:UpdateIntegration' :: UpdateIntegration -> Text
$sel:restApiId:UpdateIntegration' :: UpdateIntegration -> Text
$sel:patchOperations:UpdateIntegration' :: UpdateIntegration -> Maybe [PatchOperation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PatchOperation]
patchOperations
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 UpdateIntegration where
  toHeaders :: UpdateIntegration -> 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.ToJSON UpdateIntegration where
  toJSON :: UpdateIntegration -> Value
toJSON UpdateIntegration' {Maybe [PatchOperation]
Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:httpMethod:UpdateIntegration' :: UpdateIntegration -> Text
$sel:resourceId:UpdateIntegration' :: UpdateIntegration -> Text
$sel:restApiId:UpdateIntegration' :: UpdateIntegration -> Text
$sel:patchOperations:UpdateIntegration' :: UpdateIntegration -> Maybe [PatchOperation]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"patchOperations" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PatchOperation]
patchOperations
          ]
      )

instance Data.ToPath UpdateIntegration where
  toPath :: UpdateIntegration -> ByteString
toPath UpdateIntegration' {Maybe [PatchOperation]
Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:httpMethod:UpdateIntegration' :: UpdateIntegration -> Text
$sel:resourceId:UpdateIntegration' :: UpdateIntegration -> Text
$sel:restApiId:UpdateIntegration' :: UpdateIntegration -> Text
$sel:patchOperations:UpdateIntegration' :: UpdateIntegration -> Maybe [PatchOperation]
..} =
    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 UpdateIntegration where
  toQuery :: UpdateIntegration -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty