{-# 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.MemoryDb.Types.Subnet
-- 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.MemoryDb.Types.Subnet where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MemoryDb.Types.AvailabilityZone
import qualified Amazonka.Prelude as Prelude

-- | Represents the subnet associated with a cluster. This parameter refers
-- to subnets defined in Amazon Virtual Private Cloud (Amazon VPC) and used
-- with MemoryDB.
--
-- /See:/ 'newSubnet' smart constructor.
data Subnet = Subnet'
  { -- | The Availability Zone where the subnet resides
    Subnet -> Maybe AvailabilityZone
availabilityZone :: Prelude.Maybe AvailabilityZone,
    -- | The unique identifier for the subnet.
    Subnet -> Maybe Text
identifier :: Prelude.Maybe Prelude.Text
  }
  deriving (Subnet -> Subnet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Subnet -> Subnet -> Bool
$c/= :: Subnet -> Subnet -> Bool
== :: Subnet -> Subnet -> Bool
$c== :: Subnet -> Subnet -> Bool
Prelude.Eq, ReadPrec [Subnet]
ReadPrec Subnet
Int -> ReadS Subnet
ReadS [Subnet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Subnet]
$creadListPrec :: ReadPrec [Subnet]
readPrec :: ReadPrec Subnet
$creadPrec :: ReadPrec Subnet
readList :: ReadS [Subnet]
$creadList :: ReadS [Subnet]
readsPrec :: Int -> ReadS Subnet
$creadsPrec :: Int -> ReadS Subnet
Prelude.Read, Int -> Subnet -> ShowS
[Subnet] -> ShowS
Subnet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Subnet] -> ShowS
$cshowList :: [Subnet] -> ShowS
show :: Subnet -> String
$cshow :: Subnet -> String
showsPrec :: Int -> Subnet -> ShowS
$cshowsPrec :: Int -> Subnet -> ShowS
Prelude.Show, forall x. Rep Subnet x -> Subnet
forall x. Subnet -> Rep Subnet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Subnet x -> Subnet
$cfrom :: forall x. Subnet -> Rep Subnet x
Prelude.Generic)

-- |
-- Create a value of 'Subnet' 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:
--
-- 'availabilityZone', 'subnet_availabilityZone' - The Availability Zone where the subnet resides
--
-- 'identifier', 'subnet_identifier' - The unique identifier for the subnet.
newSubnet ::
  Subnet
newSubnet :: Subnet
newSubnet =
  Subnet'
    { $sel:availabilityZone:Subnet' :: Maybe AvailabilityZone
availabilityZone = forall a. Maybe a
Prelude.Nothing,
      $sel:identifier:Subnet' :: Maybe Text
identifier = forall a. Maybe a
Prelude.Nothing
    }

-- | The Availability Zone where the subnet resides
subnet_availabilityZone :: Lens.Lens' Subnet (Prelude.Maybe AvailabilityZone)
subnet_availabilityZone :: Lens' Subnet (Maybe AvailabilityZone)
subnet_availabilityZone = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subnet' {Maybe AvailabilityZone
availabilityZone :: Maybe AvailabilityZone
$sel:availabilityZone:Subnet' :: Subnet -> Maybe AvailabilityZone
availabilityZone} -> Maybe AvailabilityZone
availabilityZone) (\s :: Subnet
s@Subnet' {} Maybe AvailabilityZone
a -> Subnet
s {$sel:availabilityZone:Subnet' :: Maybe AvailabilityZone
availabilityZone = Maybe AvailabilityZone
a} :: Subnet)

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

instance Data.FromJSON Subnet where
  parseJSON :: Value -> Parser Subnet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Subnet"
      ( \Object
x ->
          Maybe AvailabilityZone -> Maybe Text -> Subnet
Subnet'
            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
"AvailabilityZone")
            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
"Identifier")
      )

instance Prelude.Hashable Subnet where
  hashWithSalt :: Int -> Subnet -> Int
hashWithSalt Int
_salt Subnet' {Maybe Text
Maybe AvailabilityZone
identifier :: Maybe Text
availabilityZone :: Maybe AvailabilityZone
$sel:identifier:Subnet' :: Subnet -> Maybe Text
$sel:availabilityZone:Subnet' :: Subnet -> Maybe AvailabilityZone
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AvailabilityZone
availabilityZone
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
identifier

instance Prelude.NFData Subnet where
  rnf :: Subnet -> ()
rnf Subnet' {Maybe Text
Maybe AvailabilityZone
identifier :: Maybe Text
availabilityZone :: Maybe AvailabilityZone
$sel:identifier:Subnet' :: Subnet -> Maybe Text
$sel:availabilityZone:Subnet' :: Subnet -> Maybe AvailabilityZone
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AvailabilityZone
availabilityZone
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
identifier