{-# 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.UpdateIntegrationResponse
-- 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 response.
module Amazonka.APIGateway.UpdateIntegrationResponse
  ( -- * Creating a Request
    UpdateIntegrationResponse (..),
    newUpdateIntegrationResponse,

    -- * Request Lenses
    updateIntegrationResponse_patchOperations,
    updateIntegrationResponse_restApiId,
    updateIntegrationResponse_resourceId,
    updateIntegrationResponse_httpMethod,
    updateIntegrationResponse_statusCode,

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

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

-- |
-- Create a value of 'UpdateIntegrationResponse' 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', 'updateIntegrationResponse_patchOperations' - For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
--
-- 'restApiId', 'updateIntegrationResponse_restApiId' - The string identifier of the associated RestApi.
--
-- 'resourceId', 'updateIntegrationResponse_resourceId' - Specifies an update integration response request\'s resource identifier.
--
-- 'httpMethod', 'updateIntegrationResponse_httpMethod' - Specifies an update integration response request\'s HTTP method.
--
-- 'statusCode', 'updateIntegrationResponse_statusCode' - Specifies an update integration response request\'s status code.
newUpdateIntegrationResponse ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'httpMethod'
  Prelude.Text ->
  -- | 'statusCode'
  Prelude.Text ->
  UpdateIntegrationResponse
newUpdateIntegrationResponse :: Text -> Text -> Text -> Text -> UpdateIntegrationResponse
newUpdateIntegrationResponse
  Text
pRestApiId_
  Text
pResourceId_
  Text
pHttpMethod_
  Text
pStatusCode_ =
    UpdateIntegrationResponse'
      { $sel:patchOperations:UpdateIntegrationResponse' :: Maybe [PatchOperation]
patchOperations =
          forall a. Maybe a
Prelude.Nothing,
        $sel:restApiId:UpdateIntegrationResponse' :: Text
restApiId = Text
pRestApiId_,
        $sel:resourceId:UpdateIntegrationResponse' :: Text
resourceId = Text
pResourceId_,
        $sel:httpMethod:UpdateIntegrationResponse' :: Text
httpMethod = Text
pHttpMethod_,
        $sel:statusCode:UpdateIntegrationResponse' :: Text
statusCode = Text
pStatusCode_
      }

-- | For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
updateIntegrationResponse_patchOperations :: Lens.Lens' UpdateIntegrationResponse (Prelude.Maybe [PatchOperation])
updateIntegrationResponse_patchOperations :: Lens' UpdateIntegrationResponse (Maybe [PatchOperation])
updateIntegrationResponse_patchOperations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateIntegrationResponse' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateIntegrationResponse
s@UpdateIntegrationResponse' {} Maybe [PatchOperation]
a -> UpdateIntegrationResponse
s {$sel:patchOperations:UpdateIntegrationResponse' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateIntegrationResponse) 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.
updateIntegrationResponse_restApiId :: Lens.Lens' UpdateIntegrationResponse Prelude.Text
updateIntegrationResponse_restApiId :: Lens' UpdateIntegrationResponse Text
updateIntegrationResponse_restApiId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateIntegrationResponse' {Text
restApiId :: Text
$sel:restApiId:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
restApiId} -> Text
restApiId) (\s :: UpdateIntegrationResponse
s@UpdateIntegrationResponse' {} Text
a -> UpdateIntegrationResponse
s {$sel:restApiId:UpdateIntegrationResponse' :: Text
restApiId = Text
a} :: UpdateIntegrationResponse)

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

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

-- | Specifies an update integration response request\'s status code.
updateIntegrationResponse_statusCode :: Lens.Lens' UpdateIntegrationResponse Prelude.Text
updateIntegrationResponse_statusCode :: Lens' UpdateIntegrationResponse Text
updateIntegrationResponse_statusCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateIntegrationResponse' {Text
statusCode :: Text
$sel:statusCode:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
statusCode} -> Text
statusCode) (\s :: UpdateIntegrationResponse
s@UpdateIntegrationResponse' {} Text
a -> UpdateIntegrationResponse
s {$sel:statusCode:UpdateIntegrationResponse' :: Text
statusCode = Text
a} :: UpdateIntegrationResponse)

instance Core.AWSRequest UpdateIntegrationResponse where
  type
    AWSResponse UpdateIntegrationResponse =
      IntegrationResponse
  request :: (Service -> Service)
-> UpdateIntegrationResponse -> Request UpdateIntegrationResponse
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 UpdateIntegrationResponse
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateIntegrationResponse)))
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 UpdateIntegrationResponse where
  hashWithSalt :: Int -> UpdateIntegrationResponse -> Int
hashWithSalt Int
_salt UpdateIntegrationResponse' {Maybe [PatchOperation]
Text
statusCode :: Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:statusCode:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:httpMethod:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:resourceId:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:restApiId:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:patchOperations:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> 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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
statusCode

instance Prelude.NFData UpdateIntegrationResponse where
  rnf :: UpdateIntegrationResponse -> ()
rnf UpdateIntegrationResponse' {Maybe [PatchOperation]
Text
statusCode :: Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:statusCode:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:httpMethod:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:resourceId:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:restApiId:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:patchOperations:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
statusCode

instance Data.ToHeaders UpdateIntegrationResponse where
  toHeaders :: UpdateIntegrationResponse -> 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 UpdateIntegrationResponse where
  toJSON :: UpdateIntegrationResponse -> Value
toJSON UpdateIntegrationResponse' {Maybe [PatchOperation]
Text
statusCode :: Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:statusCode:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:httpMethod:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:resourceId:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:restApiId:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:patchOperations:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> 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 UpdateIntegrationResponse where
  toPath :: UpdateIntegrationResponse -> ByteString
toPath UpdateIntegrationResponse' {Maybe [PatchOperation]
Text
statusCode :: Text
httpMethod :: Text
resourceId :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:statusCode:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:httpMethod:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:resourceId:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:restApiId:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> Text
$sel:patchOperations:UpdateIntegrationResponse' :: UpdateIntegrationResponse -> 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/responses/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
statusCode
      ]

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