{-# 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.UpdateVpcLink
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an existing VpcLink of a specified identifier.
module Amazonka.APIGateway.UpdateVpcLink
  ( -- * Creating a Request
    UpdateVpcLink (..),
    newUpdateVpcLink,

    -- * Request Lenses
    updateVpcLink_patchOperations,
    updateVpcLink_vpcLinkId,

    -- * Destructuring the Response
    VpcLink (..),
    newVpcLink,

    -- * Response Lenses
    vpcLink_description,
    vpcLink_id,
    vpcLink_name,
    vpcLink_status,
    vpcLink_statusMessage,
    vpcLink_tags,
    vpcLink_targetArns,
  )
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

-- | Updates an existing VpcLink of a specified identifier.
--
-- /See:/ 'newUpdateVpcLink' smart constructor.
data UpdateVpcLink = UpdateVpcLink'
  { -- | For more information about supported patch operations, see
    -- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
    UpdateVpcLink -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
    -- | The identifier of the VpcLink. It is used in an Integration to reference
    -- this VpcLink.
    UpdateVpcLink -> Text
vpcLinkId :: Prelude.Text
  }
  deriving (UpdateVpcLink -> UpdateVpcLink -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateVpcLink -> UpdateVpcLink -> Bool
$c/= :: UpdateVpcLink -> UpdateVpcLink -> Bool
== :: UpdateVpcLink -> UpdateVpcLink -> Bool
$c== :: UpdateVpcLink -> UpdateVpcLink -> Bool
Prelude.Eq, ReadPrec [UpdateVpcLink]
ReadPrec UpdateVpcLink
Int -> ReadS UpdateVpcLink
ReadS [UpdateVpcLink]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateVpcLink]
$creadListPrec :: ReadPrec [UpdateVpcLink]
readPrec :: ReadPrec UpdateVpcLink
$creadPrec :: ReadPrec UpdateVpcLink
readList :: ReadS [UpdateVpcLink]
$creadList :: ReadS [UpdateVpcLink]
readsPrec :: Int -> ReadS UpdateVpcLink
$creadsPrec :: Int -> ReadS UpdateVpcLink
Prelude.Read, Int -> UpdateVpcLink -> ShowS
[UpdateVpcLink] -> ShowS
UpdateVpcLink -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateVpcLink] -> ShowS
$cshowList :: [UpdateVpcLink] -> ShowS
show :: UpdateVpcLink -> String
$cshow :: UpdateVpcLink -> String
showsPrec :: Int -> UpdateVpcLink -> ShowS
$cshowsPrec :: Int -> UpdateVpcLink -> ShowS
Prelude.Show, forall x. Rep UpdateVpcLink x -> UpdateVpcLink
forall x. UpdateVpcLink -> Rep UpdateVpcLink x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateVpcLink x -> UpdateVpcLink
$cfrom :: forall x. UpdateVpcLink -> Rep UpdateVpcLink x
Prelude.Generic)

-- |
-- Create a value of 'UpdateVpcLink' 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', 'updateVpcLink_patchOperations' - For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
--
-- 'vpcLinkId', 'updateVpcLink_vpcLinkId' - The identifier of the VpcLink. It is used in an Integration to reference
-- this VpcLink.
newUpdateVpcLink ::
  -- | 'vpcLinkId'
  Prelude.Text ->
  UpdateVpcLink
newUpdateVpcLink :: Text -> UpdateVpcLink
newUpdateVpcLink Text
pVpcLinkId_ =
  UpdateVpcLink'
    { $sel:patchOperations:UpdateVpcLink' :: Maybe [PatchOperation]
patchOperations = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcLinkId:UpdateVpcLink' :: Text
vpcLinkId = Text
pVpcLinkId_
    }

-- | For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
updateVpcLink_patchOperations :: Lens.Lens' UpdateVpcLink (Prelude.Maybe [PatchOperation])
updateVpcLink_patchOperations :: Lens' UpdateVpcLink (Maybe [PatchOperation])
updateVpcLink_patchOperations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVpcLink' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateVpcLink' :: UpdateVpcLink -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateVpcLink
s@UpdateVpcLink' {} Maybe [PatchOperation]
a -> UpdateVpcLink
s {$sel:patchOperations:UpdateVpcLink' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateVpcLink) 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 identifier of the VpcLink. It is used in an Integration to reference
-- this VpcLink.
updateVpcLink_vpcLinkId :: Lens.Lens' UpdateVpcLink Prelude.Text
updateVpcLink_vpcLinkId :: Lens' UpdateVpcLink Text
updateVpcLink_vpcLinkId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVpcLink' {Text
vpcLinkId :: Text
$sel:vpcLinkId:UpdateVpcLink' :: UpdateVpcLink -> Text
vpcLinkId} -> Text
vpcLinkId) (\s :: UpdateVpcLink
s@UpdateVpcLink' {} Text
a -> UpdateVpcLink
s {$sel:vpcLinkId:UpdateVpcLink' :: Text
vpcLinkId = Text
a} :: UpdateVpcLink)

instance Core.AWSRequest UpdateVpcLink where
  type AWSResponse UpdateVpcLink = VpcLink
  request :: (Service -> Service) -> UpdateVpcLink -> Request UpdateVpcLink
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 UpdateVpcLink
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateVpcLink)))
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 UpdateVpcLink where
  hashWithSalt :: Int -> UpdateVpcLink -> Int
hashWithSalt Int
_salt UpdateVpcLink' {Maybe [PatchOperation]
Text
vpcLinkId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:vpcLinkId:UpdateVpcLink' :: UpdateVpcLink -> Text
$sel:patchOperations:UpdateVpcLink' :: UpdateVpcLink -> 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
vpcLinkId

instance Prelude.NFData UpdateVpcLink where
  rnf :: UpdateVpcLink -> ()
rnf UpdateVpcLink' {Maybe [PatchOperation]
Text
vpcLinkId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:vpcLinkId:UpdateVpcLink' :: UpdateVpcLink -> Text
$sel:patchOperations:UpdateVpcLink' :: UpdateVpcLink -> 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
vpcLinkId

instance Data.ToHeaders UpdateVpcLink where
  toHeaders :: UpdateVpcLink -> 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 UpdateVpcLink where
  toJSON :: UpdateVpcLink -> Value
toJSON UpdateVpcLink' {Maybe [PatchOperation]
Text
vpcLinkId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:vpcLinkId:UpdateVpcLink' :: UpdateVpcLink -> Text
$sel:patchOperations:UpdateVpcLink' :: UpdateVpcLink -> 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 UpdateVpcLink where
  toPath :: UpdateVpcLink -> ByteString
toPath UpdateVpcLink' {Maybe [PatchOperation]
Text
vpcLinkId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:vpcLinkId:UpdateVpcLink' :: UpdateVpcLink -> Text
$sel:patchOperations:UpdateVpcLink' :: UpdateVpcLink -> Maybe [PatchOperation]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/vpclinks/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
vpcLinkId]

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