{-# 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.NetworkFirewall.Types.SubnetMapping
-- 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.NetworkFirewall.Types.SubnetMapping 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 ID for a subnet that you want to associate with the firewall. This
-- is used with CreateFirewall and AssociateSubnets. Network Firewall
-- creates an instance of the associated firewall in each subnet that you
-- specify, to filter traffic in the subnet\'s Availability Zone.
--
-- /See:/ 'newSubnetMapping' smart constructor.
data SubnetMapping = SubnetMapping'
  { -- | The unique identifier for the subnet.
    SubnetMapping -> Text
subnetId :: Prelude.Text
  }
  deriving (SubnetMapping -> SubnetMapping -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubnetMapping -> SubnetMapping -> Bool
$c/= :: SubnetMapping -> SubnetMapping -> Bool
== :: SubnetMapping -> SubnetMapping -> Bool
$c== :: SubnetMapping -> SubnetMapping -> Bool
Prelude.Eq, ReadPrec [SubnetMapping]
ReadPrec SubnetMapping
Int -> ReadS SubnetMapping
ReadS [SubnetMapping]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubnetMapping]
$creadListPrec :: ReadPrec [SubnetMapping]
readPrec :: ReadPrec SubnetMapping
$creadPrec :: ReadPrec SubnetMapping
readList :: ReadS [SubnetMapping]
$creadList :: ReadS [SubnetMapping]
readsPrec :: Int -> ReadS SubnetMapping
$creadsPrec :: Int -> ReadS SubnetMapping
Prelude.Read, Int -> SubnetMapping -> ShowS
[SubnetMapping] -> ShowS
SubnetMapping -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubnetMapping] -> ShowS
$cshowList :: [SubnetMapping] -> ShowS
show :: SubnetMapping -> String
$cshow :: SubnetMapping -> String
showsPrec :: Int -> SubnetMapping -> ShowS
$cshowsPrec :: Int -> SubnetMapping -> ShowS
Prelude.Show, forall x. Rep SubnetMapping x -> SubnetMapping
forall x. SubnetMapping -> Rep SubnetMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubnetMapping x -> SubnetMapping
$cfrom :: forall x. SubnetMapping -> Rep SubnetMapping x
Prelude.Generic)

-- |
-- Create a value of 'SubnetMapping' 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:
--
-- 'subnetId', 'subnetMapping_subnetId' - The unique identifier for the subnet.
newSubnetMapping ::
  -- | 'subnetId'
  Prelude.Text ->
  SubnetMapping
newSubnetMapping :: Text -> SubnetMapping
newSubnetMapping Text
pSubnetId_ =
  SubnetMapping' {$sel:subnetId:SubnetMapping' :: Text
subnetId = Text
pSubnetId_}

-- | The unique identifier for the subnet.
subnetMapping_subnetId :: Lens.Lens' SubnetMapping Prelude.Text
subnetMapping_subnetId :: Lens' SubnetMapping Text
subnetMapping_subnetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubnetMapping' {Text
subnetId :: Text
$sel:subnetId:SubnetMapping' :: SubnetMapping -> Text
subnetId} -> Text
subnetId) (\s :: SubnetMapping
s@SubnetMapping' {} Text
a -> SubnetMapping
s {$sel:subnetId:SubnetMapping' :: Text
subnetId = Text
a} :: SubnetMapping)

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

instance Prelude.Hashable SubnetMapping where
  hashWithSalt :: Int -> SubnetMapping -> Int
hashWithSalt Int
_salt SubnetMapping' {Text
subnetId :: Text
$sel:subnetId:SubnetMapping' :: SubnetMapping -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
subnetId

instance Prelude.NFData SubnetMapping where
  rnf :: SubnetMapping -> ()
rnf SubnetMapping' {Text
subnetId :: Text
$sel:subnetId:SubnetMapping' :: SubnetMapping -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
subnetId

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