{-# 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.AppRunner.UpdateVpcIngressConnection
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update an existing App Runner VPC Ingress Connection resource. The VPC
-- Ingress Connection must be in one of the following states to be updated:
--
-- -   AVAILABLE
--
-- -   FAILED_CREATION
--
-- -   FAILED_UPDATE
module Amazonka.AppRunner.UpdateVpcIngressConnection
  ( -- * Creating a Request
    UpdateVpcIngressConnection (..),
    newUpdateVpcIngressConnection,

    -- * Request Lenses
    updateVpcIngressConnection_vpcIngressConnectionArn,
    updateVpcIngressConnection_ingressVpcConfiguration,

    -- * Destructuring the Response
    UpdateVpcIngressConnectionResponse (..),
    newUpdateVpcIngressConnectionResponse,

    -- * Response Lenses
    updateVpcIngressConnectionResponse_httpStatus,
    updateVpcIngressConnectionResponse_vpcIngressConnection,
  )
where

import Amazonka.AppRunner.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

-- | /See:/ 'newUpdateVpcIngressConnection' smart constructor.
data UpdateVpcIngressConnection = UpdateVpcIngressConnection'
  { -- | The Amazon Resource Name (Arn) for the App Runner VPC Ingress Connection
    -- resource that you want to update.
    UpdateVpcIngressConnection -> Text
vpcIngressConnectionArn :: Prelude.Text,
    -- | Specifications for the customer’s Amazon VPC and the related Amazon Web
    -- Services PrivateLink VPC endpoint that are used to update the VPC
    -- Ingress Connection resource.
    UpdateVpcIngressConnection -> IngressVpcConfiguration
ingressVpcConfiguration :: IngressVpcConfiguration
  }
  deriving (UpdateVpcIngressConnection -> UpdateVpcIngressConnection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateVpcIngressConnection -> UpdateVpcIngressConnection -> Bool
$c/= :: UpdateVpcIngressConnection -> UpdateVpcIngressConnection -> Bool
== :: UpdateVpcIngressConnection -> UpdateVpcIngressConnection -> Bool
$c== :: UpdateVpcIngressConnection -> UpdateVpcIngressConnection -> Bool
Prelude.Eq, ReadPrec [UpdateVpcIngressConnection]
ReadPrec UpdateVpcIngressConnection
Int -> ReadS UpdateVpcIngressConnection
ReadS [UpdateVpcIngressConnection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateVpcIngressConnection]
$creadListPrec :: ReadPrec [UpdateVpcIngressConnection]
readPrec :: ReadPrec UpdateVpcIngressConnection
$creadPrec :: ReadPrec UpdateVpcIngressConnection
readList :: ReadS [UpdateVpcIngressConnection]
$creadList :: ReadS [UpdateVpcIngressConnection]
readsPrec :: Int -> ReadS UpdateVpcIngressConnection
$creadsPrec :: Int -> ReadS UpdateVpcIngressConnection
Prelude.Read, Int -> UpdateVpcIngressConnection -> ShowS
[UpdateVpcIngressConnection] -> ShowS
UpdateVpcIngressConnection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateVpcIngressConnection] -> ShowS
$cshowList :: [UpdateVpcIngressConnection] -> ShowS
show :: UpdateVpcIngressConnection -> String
$cshow :: UpdateVpcIngressConnection -> String
showsPrec :: Int -> UpdateVpcIngressConnection -> ShowS
$cshowsPrec :: Int -> UpdateVpcIngressConnection -> ShowS
Prelude.Show, forall x.
Rep UpdateVpcIngressConnection x -> UpdateVpcIngressConnection
forall x.
UpdateVpcIngressConnection -> Rep UpdateVpcIngressConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateVpcIngressConnection x -> UpdateVpcIngressConnection
$cfrom :: forall x.
UpdateVpcIngressConnection -> Rep UpdateVpcIngressConnection x
Prelude.Generic)

-- |
-- Create a value of 'UpdateVpcIngressConnection' 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:
--
-- 'vpcIngressConnectionArn', 'updateVpcIngressConnection_vpcIngressConnectionArn' - The Amazon Resource Name (Arn) for the App Runner VPC Ingress Connection
-- resource that you want to update.
--
-- 'ingressVpcConfiguration', 'updateVpcIngressConnection_ingressVpcConfiguration' - Specifications for the customer’s Amazon VPC and the related Amazon Web
-- Services PrivateLink VPC endpoint that are used to update the VPC
-- Ingress Connection resource.
newUpdateVpcIngressConnection ::
  -- | 'vpcIngressConnectionArn'
  Prelude.Text ->
  -- | 'ingressVpcConfiguration'
  IngressVpcConfiguration ->
  UpdateVpcIngressConnection
newUpdateVpcIngressConnection :: Text -> IngressVpcConfiguration -> UpdateVpcIngressConnection
newUpdateVpcIngressConnection
  Text
pVpcIngressConnectionArn_
  IngressVpcConfiguration
pIngressVpcConfiguration_ =
    UpdateVpcIngressConnection'
      { $sel:vpcIngressConnectionArn:UpdateVpcIngressConnection' :: Text
vpcIngressConnectionArn =
          Text
pVpcIngressConnectionArn_,
        $sel:ingressVpcConfiguration:UpdateVpcIngressConnection' :: IngressVpcConfiguration
ingressVpcConfiguration =
          IngressVpcConfiguration
pIngressVpcConfiguration_
      }

-- | The Amazon Resource Name (Arn) for the App Runner VPC Ingress Connection
-- resource that you want to update.
updateVpcIngressConnection_vpcIngressConnectionArn :: Lens.Lens' UpdateVpcIngressConnection Prelude.Text
updateVpcIngressConnection_vpcIngressConnectionArn :: Lens' UpdateVpcIngressConnection Text
updateVpcIngressConnection_vpcIngressConnectionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVpcIngressConnection' {Text
vpcIngressConnectionArn :: Text
$sel:vpcIngressConnectionArn:UpdateVpcIngressConnection' :: UpdateVpcIngressConnection -> Text
vpcIngressConnectionArn} -> Text
vpcIngressConnectionArn) (\s :: UpdateVpcIngressConnection
s@UpdateVpcIngressConnection' {} Text
a -> UpdateVpcIngressConnection
s {$sel:vpcIngressConnectionArn:UpdateVpcIngressConnection' :: Text
vpcIngressConnectionArn = Text
a} :: UpdateVpcIngressConnection)

-- | Specifications for the customer’s Amazon VPC and the related Amazon Web
-- Services PrivateLink VPC endpoint that are used to update the VPC
-- Ingress Connection resource.
updateVpcIngressConnection_ingressVpcConfiguration :: Lens.Lens' UpdateVpcIngressConnection IngressVpcConfiguration
updateVpcIngressConnection_ingressVpcConfiguration :: Lens' UpdateVpcIngressConnection IngressVpcConfiguration
updateVpcIngressConnection_ingressVpcConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVpcIngressConnection' {IngressVpcConfiguration
ingressVpcConfiguration :: IngressVpcConfiguration
$sel:ingressVpcConfiguration:UpdateVpcIngressConnection' :: UpdateVpcIngressConnection -> IngressVpcConfiguration
ingressVpcConfiguration} -> IngressVpcConfiguration
ingressVpcConfiguration) (\s :: UpdateVpcIngressConnection
s@UpdateVpcIngressConnection' {} IngressVpcConfiguration
a -> UpdateVpcIngressConnection
s {$sel:ingressVpcConfiguration:UpdateVpcIngressConnection' :: IngressVpcConfiguration
ingressVpcConfiguration = IngressVpcConfiguration
a} :: UpdateVpcIngressConnection)

instance Core.AWSRequest UpdateVpcIngressConnection where
  type
    AWSResponse UpdateVpcIngressConnection =
      UpdateVpcIngressConnectionResponse
  request :: (Service -> Service)
-> UpdateVpcIngressConnection -> Request UpdateVpcIngressConnection
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateVpcIngressConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateVpcIngressConnection)))
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 ->
          Int -> VpcIngressConnection -> UpdateVpcIngressConnectionResponse
UpdateVpcIngressConnectionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"VpcIngressConnection")
      )

instance Prelude.Hashable UpdateVpcIngressConnection where
  hashWithSalt :: Int -> UpdateVpcIngressConnection -> Int
hashWithSalt Int
_salt UpdateVpcIngressConnection' {Text
IngressVpcConfiguration
ingressVpcConfiguration :: IngressVpcConfiguration
vpcIngressConnectionArn :: Text
$sel:ingressVpcConfiguration:UpdateVpcIngressConnection' :: UpdateVpcIngressConnection -> IngressVpcConfiguration
$sel:vpcIngressConnectionArn:UpdateVpcIngressConnection' :: UpdateVpcIngressConnection -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
vpcIngressConnectionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` IngressVpcConfiguration
ingressVpcConfiguration

instance Prelude.NFData UpdateVpcIngressConnection where
  rnf :: UpdateVpcIngressConnection -> ()
rnf UpdateVpcIngressConnection' {Text
IngressVpcConfiguration
ingressVpcConfiguration :: IngressVpcConfiguration
vpcIngressConnectionArn :: Text
$sel:ingressVpcConfiguration:UpdateVpcIngressConnection' :: UpdateVpcIngressConnection -> IngressVpcConfiguration
$sel:vpcIngressConnectionArn:UpdateVpcIngressConnection' :: UpdateVpcIngressConnection -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
vpcIngressConnectionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf IngressVpcConfiguration
ingressVpcConfiguration

instance Data.ToHeaders UpdateVpcIngressConnection where
  toHeaders :: UpdateVpcIngressConnection -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AppRunner.UpdateVpcIngressConnection" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateVpcIngressConnection where
  toJSON :: UpdateVpcIngressConnection -> Value
toJSON UpdateVpcIngressConnection' {Text
IngressVpcConfiguration
ingressVpcConfiguration :: IngressVpcConfiguration
vpcIngressConnectionArn :: Text
$sel:ingressVpcConfiguration:UpdateVpcIngressConnection' :: UpdateVpcIngressConnection -> IngressVpcConfiguration
$sel:vpcIngressConnectionArn:UpdateVpcIngressConnection' :: UpdateVpcIngressConnection -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"VpcIngressConnectionArn"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
vpcIngressConnectionArn
              ),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"IngressVpcConfiguration"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= IngressVpcConfiguration
ingressVpcConfiguration
              )
          ]
      )

instance Data.ToPath UpdateVpcIngressConnection where
  toPath :: UpdateVpcIngressConnection -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newUpdateVpcIngressConnectionResponse' smart constructor.
data UpdateVpcIngressConnectionResponse = UpdateVpcIngressConnectionResponse'
  { -- | The response's http status code.
    UpdateVpcIngressConnectionResponse -> Int
httpStatus :: Prelude.Int,
    -- | A description of the App Runner VPC Ingress Connection resource that\'s
    -- updated by this request.
    UpdateVpcIngressConnectionResponse -> VpcIngressConnection
vpcIngressConnection :: VpcIngressConnection
  }
  deriving (UpdateVpcIngressConnectionResponse
-> UpdateVpcIngressConnectionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateVpcIngressConnectionResponse
-> UpdateVpcIngressConnectionResponse -> Bool
$c/= :: UpdateVpcIngressConnectionResponse
-> UpdateVpcIngressConnectionResponse -> Bool
== :: UpdateVpcIngressConnectionResponse
-> UpdateVpcIngressConnectionResponse -> Bool
$c== :: UpdateVpcIngressConnectionResponse
-> UpdateVpcIngressConnectionResponse -> Bool
Prelude.Eq, ReadPrec [UpdateVpcIngressConnectionResponse]
ReadPrec UpdateVpcIngressConnectionResponse
Int -> ReadS UpdateVpcIngressConnectionResponse
ReadS [UpdateVpcIngressConnectionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateVpcIngressConnectionResponse]
$creadListPrec :: ReadPrec [UpdateVpcIngressConnectionResponse]
readPrec :: ReadPrec UpdateVpcIngressConnectionResponse
$creadPrec :: ReadPrec UpdateVpcIngressConnectionResponse
readList :: ReadS [UpdateVpcIngressConnectionResponse]
$creadList :: ReadS [UpdateVpcIngressConnectionResponse]
readsPrec :: Int -> ReadS UpdateVpcIngressConnectionResponse
$creadsPrec :: Int -> ReadS UpdateVpcIngressConnectionResponse
Prelude.Read, Int -> UpdateVpcIngressConnectionResponse -> ShowS
[UpdateVpcIngressConnectionResponse] -> ShowS
UpdateVpcIngressConnectionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateVpcIngressConnectionResponse] -> ShowS
$cshowList :: [UpdateVpcIngressConnectionResponse] -> ShowS
show :: UpdateVpcIngressConnectionResponse -> String
$cshow :: UpdateVpcIngressConnectionResponse -> String
showsPrec :: Int -> UpdateVpcIngressConnectionResponse -> ShowS
$cshowsPrec :: Int -> UpdateVpcIngressConnectionResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateVpcIngressConnectionResponse x
-> UpdateVpcIngressConnectionResponse
forall x.
UpdateVpcIngressConnectionResponse
-> Rep UpdateVpcIngressConnectionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateVpcIngressConnectionResponse x
-> UpdateVpcIngressConnectionResponse
$cfrom :: forall x.
UpdateVpcIngressConnectionResponse
-> Rep UpdateVpcIngressConnectionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateVpcIngressConnectionResponse' 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:
--
-- 'httpStatus', 'updateVpcIngressConnectionResponse_httpStatus' - The response's http status code.
--
-- 'vpcIngressConnection', 'updateVpcIngressConnectionResponse_vpcIngressConnection' - A description of the App Runner VPC Ingress Connection resource that\'s
-- updated by this request.
newUpdateVpcIngressConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'vpcIngressConnection'
  VpcIngressConnection ->
  UpdateVpcIngressConnectionResponse
newUpdateVpcIngressConnectionResponse :: Int -> VpcIngressConnection -> UpdateVpcIngressConnectionResponse
newUpdateVpcIngressConnectionResponse
  Int
pHttpStatus_
  VpcIngressConnection
pVpcIngressConnection_ =
    UpdateVpcIngressConnectionResponse'
      { $sel:httpStatus:UpdateVpcIngressConnectionResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:vpcIngressConnection:UpdateVpcIngressConnectionResponse' :: VpcIngressConnection
vpcIngressConnection =
          VpcIngressConnection
pVpcIngressConnection_
      }

-- | The response's http status code.
updateVpcIngressConnectionResponse_httpStatus :: Lens.Lens' UpdateVpcIngressConnectionResponse Prelude.Int
updateVpcIngressConnectionResponse_httpStatus :: Lens' UpdateVpcIngressConnectionResponse Int
updateVpcIngressConnectionResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVpcIngressConnectionResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateVpcIngressConnectionResponse' :: UpdateVpcIngressConnectionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateVpcIngressConnectionResponse
s@UpdateVpcIngressConnectionResponse' {} Int
a -> UpdateVpcIngressConnectionResponse
s {$sel:httpStatus:UpdateVpcIngressConnectionResponse' :: Int
httpStatus = Int
a} :: UpdateVpcIngressConnectionResponse)

-- | A description of the App Runner VPC Ingress Connection resource that\'s
-- updated by this request.
updateVpcIngressConnectionResponse_vpcIngressConnection :: Lens.Lens' UpdateVpcIngressConnectionResponse VpcIngressConnection
updateVpcIngressConnectionResponse_vpcIngressConnection :: Lens' UpdateVpcIngressConnectionResponse VpcIngressConnection
updateVpcIngressConnectionResponse_vpcIngressConnection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVpcIngressConnectionResponse' {VpcIngressConnection
vpcIngressConnection :: VpcIngressConnection
$sel:vpcIngressConnection:UpdateVpcIngressConnectionResponse' :: UpdateVpcIngressConnectionResponse -> VpcIngressConnection
vpcIngressConnection} -> VpcIngressConnection
vpcIngressConnection) (\s :: UpdateVpcIngressConnectionResponse
s@UpdateVpcIngressConnectionResponse' {} VpcIngressConnection
a -> UpdateVpcIngressConnectionResponse
s {$sel:vpcIngressConnection:UpdateVpcIngressConnectionResponse' :: VpcIngressConnection
vpcIngressConnection = VpcIngressConnection
a} :: UpdateVpcIngressConnectionResponse)

instance
  Prelude.NFData
    UpdateVpcIngressConnectionResponse
  where
  rnf :: UpdateVpcIngressConnectionResponse -> ()
rnf UpdateVpcIngressConnectionResponse' {Int
VpcIngressConnection
vpcIngressConnection :: VpcIngressConnection
httpStatus :: Int
$sel:vpcIngressConnection:UpdateVpcIngressConnectionResponse' :: UpdateVpcIngressConnectionResponse -> VpcIngressConnection
$sel:httpStatus:UpdateVpcIngressConnectionResponse' :: UpdateVpcIngressConnectionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf VpcIngressConnection
vpcIngressConnection