{-# 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.SubnetGroup
-- 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.SubnetGroup 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.Subnet
import qualified Amazonka.Prelude as Prelude

-- | Represents the output of one of the following operations:
--
-- -   CreateSubnetGroup
--
-- -   UpdateSubnetGroup
--
-- A subnet group is a collection of subnets (typically private) that you
-- can designate for your clusters running in an Amazon Virtual Private
-- Cloud (VPC) environment.
--
-- /See:/ 'newSubnetGroup' smart constructor.
data SubnetGroup = SubnetGroup'
  { -- | The ARN (Amazon Resource Name) of the subnet group.
    SubnetGroup -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | A description of the subnet group
    SubnetGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the subnet group
    SubnetGroup -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A list of subnets associated with the subnet group.
    SubnetGroup -> Maybe [Subnet]
subnets :: Prelude.Maybe [Subnet],
    -- | The Amazon Virtual Private Cloud identifier (VPC ID) of the subnet
    -- group.
    SubnetGroup -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text
  }
  deriving (SubnetGroup -> SubnetGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubnetGroup -> SubnetGroup -> Bool
$c/= :: SubnetGroup -> SubnetGroup -> Bool
== :: SubnetGroup -> SubnetGroup -> Bool
$c== :: SubnetGroup -> SubnetGroup -> Bool
Prelude.Eq, ReadPrec [SubnetGroup]
ReadPrec SubnetGroup
Int -> ReadS SubnetGroup
ReadS [SubnetGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubnetGroup]
$creadListPrec :: ReadPrec [SubnetGroup]
readPrec :: ReadPrec SubnetGroup
$creadPrec :: ReadPrec SubnetGroup
readList :: ReadS [SubnetGroup]
$creadList :: ReadS [SubnetGroup]
readsPrec :: Int -> ReadS SubnetGroup
$creadsPrec :: Int -> ReadS SubnetGroup
Prelude.Read, Int -> SubnetGroup -> ShowS
[SubnetGroup] -> ShowS
SubnetGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubnetGroup] -> ShowS
$cshowList :: [SubnetGroup] -> ShowS
show :: SubnetGroup -> String
$cshow :: SubnetGroup -> String
showsPrec :: Int -> SubnetGroup -> ShowS
$cshowsPrec :: Int -> SubnetGroup -> ShowS
Prelude.Show, forall x. Rep SubnetGroup x -> SubnetGroup
forall x. SubnetGroup -> Rep SubnetGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubnetGroup x -> SubnetGroup
$cfrom :: forall x. SubnetGroup -> Rep SubnetGroup x
Prelude.Generic)

-- |
-- Create a value of 'SubnetGroup' 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:
--
-- 'arn', 'subnetGroup_arn' - The ARN (Amazon Resource Name) of the subnet group.
--
-- 'description', 'subnetGroup_description' - A description of the subnet group
--
-- 'name', 'subnetGroup_name' - The name of the subnet group
--
-- 'subnets', 'subnetGroup_subnets' - A list of subnets associated with the subnet group.
--
-- 'vpcId', 'subnetGroup_vpcId' - The Amazon Virtual Private Cloud identifier (VPC ID) of the subnet
-- group.
newSubnetGroup ::
  SubnetGroup
newSubnetGroup :: SubnetGroup
newSubnetGroup =
  SubnetGroup'
    { $sel:arn:SubnetGroup' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:description:SubnetGroup' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:name:SubnetGroup' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:SubnetGroup' :: Maybe [Subnet]
subnets = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:SubnetGroup' :: Maybe Text
vpcId = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN (Amazon Resource Name) of the subnet group.
subnetGroup_arn :: Lens.Lens' SubnetGroup (Prelude.Maybe Prelude.Text)
subnetGroup_arn :: Lens' SubnetGroup (Maybe Text)
subnetGroup_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubnetGroup' {Maybe Text
arn :: Maybe Text
$sel:arn:SubnetGroup' :: SubnetGroup -> Maybe Text
arn} -> Maybe Text
arn) (\s :: SubnetGroup
s@SubnetGroup' {} Maybe Text
a -> SubnetGroup
s {$sel:arn:SubnetGroup' :: Maybe Text
arn = Maybe Text
a} :: SubnetGroup)

-- | A description of the subnet group
subnetGroup_description :: Lens.Lens' SubnetGroup (Prelude.Maybe Prelude.Text)
subnetGroup_description :: Lens' SubnetGroup (Maybe Text)
subnetGroup_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubnetGroup' {Maybe Text
description :: Maybe Text
$sel:description:SubnetGroup' :: SubnetGroup -> Maybe Text
description} -> Maybe Text
description) (\s :: SubnetGroup
s@SubnetGroup' {} Maybe Text
a -> SubnetGroup
s {$sel:description:SubnetGroup' :: Maybe Text
description = Maybe Text
a} :: SubnetGroup)

-- | The name of the subnet group
subnetGroup_name :: Lens.Lens' SubnetGroup (Prelude.Maybe Prelude.Text)
subnetGroup_name :: Lens' SubnetGroup (Maybe Text)
subnetGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubnetGroup' {Maybe Text
name :: Maybe Text
$sel:name:SubnetGroup' :: SubnetGroup -> Maybe Text
name} -> Maybe Text
name) (\s :: SubnetGroup
s@SubnetGroup' {} Maybe Text
a -> SubnetGroup
s {$sel:name:SubnetGroup' :: Maybe Text
name = Maybe Text
a} :: SubnetGroup)

-- | A list of subnets associated with the subnet group.
subnetGroup_subnets :: Lens.Lens' SubnetGroup (Prelude.Maybe [Subnet])
subnetGroup_subnets :: Lens' SubnetGroup (Maybe [Subnet])
subnetGroup_subnets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubnetGroup' {Maybe [Subnet]
subnets :: Maybe [Subnet]
$sel:subnets:SubnetGroup' :: SubnetGroup -> Maybe [Subnet]
subnets} -> Maybe [Subnet]
subnets) (\s :: SubnetGroup
s@SubnetGroup' {} Maybe [Subnet]
a -> SubnetGroup
s {$sel:subnets:SubnetGroup' :: Maybe [Subnet]
subnets = Maybe [Subnet]
a} :: SubnetGroup) 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 Amazon Virtual Private Cloud identifier (VPC ID) of the subnet
-- group.
subnetGroup_vpcId :: Lens.Lens' SubnetGroup (Prelude.Maybe Prelude.Text)
subnetGroup_vpcId :: Lens' SubnetGroup (Maybe Text)
subnetGroup_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubnetGroup' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:SubnetGroup' :: SubnetGroup -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: SubnetGroup
s@SubnetGroup' {} Maybe Text
a -> SubnetGroup
s {$sel:vpcId:SubnetGroup' :: Maybe Text
vpcId = Maybe Text
a} :: SubnetGroup)

instance Data.FromJSON SubnetGroup where
  parseJSON :: Value -> Parser SubnetGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SubnetGroup"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Subnet]
-> Maybe Text
-> SubnetGroup
SubnetGroup'
            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
"ARN")
            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
"Description")
            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
"Name")
            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
"Subnets" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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 SubnetGroup where
  hashWithSalt :: Int -> SubnetGroup -> Int
hashWithSalt Int
_salt SubnetGroup' {Maybe [Subnet]
Maybe Text
vpcId :: Maybe Text
subnets :: Maybe [Subnet]
name :: Maybe Text
description :: Maybe Text
arn :: Maybe Text
$sel:vpcId:SubnetGroup' :: SubnetGroup -> Maybe Text
$sel:subnets:SubnetGroup' :: SubnetGroup -> Maybe [Subnet]
$sel:name:SubnetGroup' :: SubnetGroup -> Maybe Text
$sel:description:SubnetGroup' :: SubnetGroup -> Maybe Text
$sel:arn:SubnetGroup' :: SubnetGroup -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Subnet]
subnets
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId

instance Prelude.NFData SubnetGroup where
  rnf :: SubnetGroup -> ()
rnf SubnetGroup' {Maybe [Subnet]
Maybe Text
vpcId :: Maybe Text
subnets :: Maybe [Subnet]
name :: Maybe Text
description :: Maybe Text
arn :: Maybe Text
$sel:vpcId:SubnetGroup' :: SubnetGroup -> Maybe Text
$sel:subnets:SubnetGroup' :: SubnetGroup -> Maybe [Subnet]
$sel:name:SubnetGroup' :: SubnetGroup -> Maybe Text
$sel:description:SubnetGroup' :: SubnetGroup -> Maybe Text
$sel:arn:SubnetGroup' :: SubnetGroup -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Subnet]
subnets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcId