{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.IngressVpcConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppRunner.Types.IngressVpcConfiguration where

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

-- | The configuration of your VPC and the associated VPC endpoint. The VPC
-- endpoint is an Amazon Web Services PrivateLink resource that allows
-- access to your App Runner services from within an Amazon VPC.
--
-- /See:/ 'newIngressVpcConfiguration' smart constructor.
data IngressVpcConfiguration = IngressVpcConfiguration'
  { -- | The ID of the VPC endpoint that your App Runner service connects to.
    IngressVpcConfiguration -> Maybe Text
vpcEndpointId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the VPC that is used for the VPC endpoint.
    IngressVpcConfiguration -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text
  }
  deriving (IngressVpcConfiguration -> IngressVpcConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IngressVpcConfiguration -> IngressVpcConfiguration -> Bool
$c/= :: IngressVpcConfiguration -> IngressVpcConfiguration -> Bool
== :: IngressVpcConfiguration -> IngressVpcConfiguration -> Bool
$c== :: IngressVpcConfiguration -> IngressVpcConfiguration -> Bool
Prelude.Eq, ReadPrec [IngressVpcConfiguration]
ReadPrec IngressVpcConfiguration
Int -> ReadS IngressVpcConfiguration
ReadS [IngressVpcConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IngressVpcConfiguration]
$creadListPrec :: ReadPrec [IngressVpcConfiguration]
readPrec :: ReadPrec IngressVpcConfiguration
$creadPrec :: ReadPrec IngressVpcConfiguration
readList :: ReadS [IngressVpcConfiguration]
$creadList :: ReadS [IngressVpcConfiguration]
readsPrec :: Int -> ReadS IngressVpcConfiguration
$creadsPrec :: Int -> ReadS IngressVpcConfiguration
Prelude.Read, Int -> IngressVpcConfiguration -> ShowS
[IngressVpcConfiguration] -> ShowS
IngressVpcConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IngressVpcConfiguration] -> ShowS
$cshowList :: [IngressVpcConfiguration] -> ShowS
show :: IngressVpcConfiguration -> String
$cshow :: IngressVpcConfiguration -> String
showsPrec :: Int -> IngressVpcConfiguration -> ShowS
$cshowsPrec :: Int -> IngressVpcConfiguration -> ShowS
Prelude.Show, forall x. Rep IngressVpcConfiguration x -> IngressVpcConfiguration
forall x. IngressVpcConfiguration -> Rep IngressVpcConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IngressVpcConfiguration x -> IngressVpcConfiguration
$cfrom :: forall x. IngressVpcConfiguration -> Rep IngressVpcConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'IngressVpcConfiguration' 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:
--
-- 'vpcEndpointId', 'ingressVpcConfiguration_vpcEndpointId' - The ID of the VPC endpoint that your App Runner service connects to.
--
-- 'vpcId', 'ingressVpcConfiguration_vpcId' - The ID of the VPC that is used for the VPC endpoint.
newIngressVpcConfiguration ::
  IngressVpcConfiguration
newIngressVpcConfiguration :: IngressVpcConfiguration
newIngressVpcConfiguration =
  IngressVpcConfiguration'
    { $sel:vpcEndpointId:IngressVpcConfiguration' :: Maybe Text
vpcEndpointId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:IngressVpcConfiguration' :: Maybe Text
vpcId = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the VPC endpoint that your App Runner service connects to.
ingressVpcConfiguration_vpcEndpointId :: Lens.Lens' IngressVpcConfiguration (Prelude.Maybe Prelude.Text)
ingressVpcConfiguration_vpcEndpointId :: Lens' IngressVpcConfiguration (Maybe Text)
ingressVpcConfiguration_vpcEndpointId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IngressVpcConfiguration' {Maybe Text
vpcEndpointId :: Maybe Text
$sel:vpcEndpointId:IngressVpcConfiguration' :: IngressVpcConfiguration -> Maybe Text
vpcEndpointId} -> Maybe Text
vpcEndpointId) (\s :: IngressVpcConfiguration
s@IngressVpcConfiguration' {} Maybe Text
a -> IngressVpcConfiguration
s {$sel:vpcEndpointId:IngressVpcConfiguration' :: Maybe Text
vpcEndpointId = Maybe Text
a} :: IngressVpcConfiguration)

-- | The ID of the VPC that is used for the VPC endpoint.
ingressVpcConfiguration_vpcId :: Lens.Lens' IngressVpcConfiguration (Prelude.Maybe Prelude.Text)
ingressVpcConfiguration_vpcId :: Lens' IngressVpcConfiguration (Maybe Text)
ingressVpcConfiguration_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IngressVpcConfiguration' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:IngressVpcConfiguration' :: IngressVpcConfiguration -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: IngressVpcConfiguration
s@IngressVpcConfiguration' {} Maybe Text
a -> IngressVpcConfiguration
s {$sel:vpcId:IngressVpcConfiguration' :: Maybe Text
vpcId = Maybe Text
a} :: IngressVpcConfiguration)

instance Data.FromJSON IngressVpcConfiguration where
  parseJSON :: Value -> Parser IngressVpcConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IngressVpcConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> IngressVpcConfiguration
IngressVpcConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"VpcEndpointId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"VpcId")
      )

instance Prelude.Hashable IngressVpcConfiguration where
  hashWithSalt :: Int -> IngressVpcConfiguration -> Int
hashWithSalt Int
_salt IngressVpcConfiguration' {Maybe Text
vpcId :: Maybe Text
vpcEndpointId :: Maybe Text
$sel:vpcId:IngressVpcConfiguration' :: IngressVpcConfiguration -> Maybe Text
$sel:vpcEndpointId:IngressVpcConfiguration' :: IngressVpcConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcEndpointId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId

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

instance Data.ToJSON IngressVpcConfiguration where
  toJSON :: IngressVpcConfiguration -> Value
toJSON IngressVpcConfiguration' {Maybe Text
vpcId :: Maybe Text
vpcEndpointId :: Maybe Text
$sel:vpcId:IngressVpcConfiguration' :: IngressVpcConfiguration -> Maybe Text
$sel:vpcEndpointId:IngressVpcConfiguration' :: IngressVpcConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"VpcEndpointId" 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 Text
vpcEndpointId,
            (Key
"VpcId" 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 Text
vpcId
          ]
      )