{-# 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-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 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_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 an update integration response request.
--
-- /See:/ 'newUpdateIntegrationResponse' smart constructor.
data UpdateIntegrationResponse = UpdateIntegrationResponse'
  { -- | A list of update operations to be applied to the specified resource and
    -- in the order specified in this list.
    UpdateIntegrationResponse -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
    -- | [Required] The string identifier of the associated RestApi.
    UpdateIntegrationResponse -> Text
restApiId :: Prelude.Text,
    -- | [Required] Specifies an update integration response request\'s resource
    -- identifier.
    UpdateIntegrationResponse -> Text
resourceId :: Prelude.Text,
    -- | [Required] Specifies an update integration response request\'s HTTP
    -- method.
    UpdateIntegrationResponse -> Text
httpMethod :: Prelude.Text,
    -- | [Required] Specifies an update integration response request\'s status
    -- code.
    UpdateIntegrationResponse -> Text
statusCode :: Prelude.Text
  }
  deriving (UpdateIntegrationResponse -> UpdateIntegrationResponse -> Bool
(UpdateIntegrationResponse -> UpdateIntegrationResponse -> Bool)
-> (UpdateIntegrationResponse -> UpdateIntegrationResponse -> Bool)
-> Eq UpdateIntegrationResponse
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]
(Int -> ReadS UpdateIntegrationResponse)
-> ReadS [UpdateIntegrationResponse]
-> ReadPrec UpdateIntegrationResponse
-> ReadPrec [UpdateIntegrationResponse]
-> Read 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
(Int -> UpdateIntegrationResponse -> ShowS)
-> (UpdateIntegrationResponse -> String)
-> ([UpdateIntegrationResponse] -> ShowS)
-> Show UpdateIntegrationResponse
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.
 UpdateIntegrationResponse -> Rep UpdateIntegrationResponse x)
-> (forall x.
    Rep UpdateIntegrationResponse x -> UpdateIntegrationResponse)
-> Generic UpdateIntegrationResponse
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' - A list of update operations to be applied to the specified resource and
-- in the order specified in this list.
--
-- 'restApiId', 'updateIntegrationResponse_restApiId' - [Required] The string identifier of the associated RestApi.
--
-- 'resourceId', 'updateIntegrationResponse_resourceId' - [Required] Specifies an update integration response request\'s resource
-- identifier.
--
-- 'httpMethod', 'updateIntegrationResponse_httpMethod' - [Required] Specifies an update integration response request\'s HTTP
-- method.
--
-- 'statusCode', 'updateIntegrationResponse_statusCode' - [Required] 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' :: Maybe [PatchOperation]
-> Text -> Text -> Text -> Text -> UpdateIntegrationResponse
UpdateIntegrationResponse'
      { $sel:patchOperations:UpdateIntegrationResponse' :: Maybe [PatchOperation]
patchOperations =
          Maybe [PatchOperation]
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_
      }

-- | A list of update operations to be applied to the specified resource and
-- in the order specified in this list.
updateIntegrationResponse_patchOperations :: Lens.Lens' UpdateIntegrationResponse (Prelude.Maybe [PatchOperation])
updateIntegrationResponse_patchOperations :: (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateIntegrationResponse -> f UpdateIntegrationResponse
updateIntegrationResponse_patchOperations = (UpdateIntegrationResponse -> Maybe [PatchOperation])
-> (UpdateIntegrationResponse
    -> Maybe [PatchOperation] -> UpdateIntegrationResponse)
-> Lens
     UpdateIntegrationResponse
     UpdateIntegrationResponse
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
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) ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
 -> UpdateIntegrationResponse -> f UpdateIntegrationResponse)
-> ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
    -> Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateIntegrationResponse
-> f UpdateIntegrationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
-> Iso
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
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 AnIso
  [PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | [Required] The string identifier of the associated RestApi.
updateIntegrationResponse_restApiId :: Lens.Lens' UpdateIntegrationResponse Prelude.Text
updateIntegrationResponse_restApiId :: (Text -> f Text)
-> UpdateIntegrationResponse -> f UpdateIntegrationResponse
updateIntegrationResponse_restApiId = (UpdateIntegrationResponse -> Text)
-> (UpdateIntegrationResponse -> Text -> UpdateIntegrationResponse)
-> Lens
     UpdateIntegrationResponse UpdateIntegrationResponse Text Text
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)

-- | [Required] Specifies an update integration response request\'s resource
-- identifier.
updateIntegrationResponse_resourceId :: Lens.Lens' UpdateIntegrationResponse Prelude.Text
updateIntegrationResponse_resourceId :: (Text -> f Text)
-> UpdateIntegrationResponse -> f UpdateIntegrationResponse
updateIntegrationResponse_resourceId = (UpdateIntegrationResponse -> Text)
-> (UpdateIntegrationResponse -> Text -> UpdateIntegrationResponse)
-> Lens
     UpdateIntegrationResponse UpdateIntegrationResponse Text Text
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)

-- | [Required] Specifies an update integration response request\'s HTTP
-- method.
updateIntegrationResponse_httpMethod :: Lens.Lens' UpdateIntegrationResponse Prelude.Text
updateIntegrationResponse_httpMethod :: (Text -> f Text)
-> UpdateIntegrationResponse -> f UpdateIntegrationResponse
updateIntegrationResponse_httpMethod = (UpdateIntegrationResponse -> Text)
-> (UpdateIntegrationResponse -> Text -> UpdateIntegrationResponse)
-> Lens
     UpdateIntegrationResponse UpdateIntegrationResponse Text Text
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)

-- | [Required] Specifies an update integration response request\'s status
-- code.
updateIntegrationResponse_statusCode :: Lens.Lens' UpdateIntegrationResponse Prelude.Text
updateIntegrationResponse_statusCode :: (Text -> f Text)
-> UpdateIntegrationResponse -> f UpdateIntegrationResponse
updateIntegrationResponse_statusCode = (UpdateIntegrationResponse -> Text)
-> (UpdateIntegrationResponse -> Text -> UpdateIntegrationResponse)
-> Lens
     UpdateIntegrationResponse UpdateIntegrationResponse Text Text
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 :: UpdateIntegrationResponse -> Request UpdateIntegrationResponse
request = Service
-> UpdateIntegrationResponse -> Request UpdateIntegrationResponse
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateIntegrationResponse
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateIntegrationResponse)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateIntegrationResponse))
-> Logger
-> Service
-> Proxy UpdateIntegrationResponse
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateIntegrationResponse)))
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 UpdateIntegrationResponse

instance Prelude.NFData UpdateIntegrationResponse

instance Core.ToHeaders UpdateIntegrationResponse where
  toHeaders :: UpdateIntegrationResponse -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateIntegrationResponse -> 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.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"patchOperations" Text -> [PatchOperation] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([PatchOperation] -> Pair) -> Maybe [PatchOperation] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PatchOperation]
patchOperations
          ]
      )

instance Core.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]
..} =
    [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 UpdateIntegrationResponse where
  toQuery :: UpdateIntegrationResponse -> QueryString
toQuery = QueryString -> UpdateIntegrationResponse -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty