{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MemoryDb.Types.SubnetGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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,
    -- | The Amazon Virtual Private Cloud identifier (VPC ID) of the subnet
    -- group.
    SubnetGroup -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text,
    -- | A list of subnets associated with the subnet group.
    SubnetGroup -> Maybe [Subnet]
subnets :: Prelude.Maybe [Subnet],
    -- | The name of the subnet group
    SubnetGroup -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A description of the subnet group
    SubnetGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (SubnetGroup -> SubnetGroup -> Bool
(SubnetGroup -> SubnetGroup -> Bool)
-> (SubnetGroup -> SubnetGroup -> Bool) -> Eq SubnetGroup
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]
(Int -> ReadS SubnetGroup)
-> ReadS [SubnetGroup]
-> ReadPrec SubnetGroup
-> ReadPrec [SubnetGroup]
-> Read 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
(Int -> SubnetGroup -> ShowS)
-> (SubnetGroup -> String)
-> ([SubnetGroup] -> ShowS)
-> Show SubnetGroup
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. SubnetGroup -> Rep SubnetGroup x)
-> (forall x. Rep SubnetGroup x -> SubnetGroup)
-> Generic SubnetGroup
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.
--
-- 'vpcId', 'subnetGroup_vpcId' - The Amazon Virtual Private Cloud identifier (VPC ID) of the subnet
-- group.
--
-- 'subnets', 'subnetGroup_subnets' - A list of subnets associated with the subnet group.
--
-- 'name', 'subnetGroup_name' - The name of the subnet group
--
-- 'description', 'subnetGroup_description' - A description of the subnet group
newSubnetGroup ::
  SubnetGroup
newSubnetGroup :: SubnetGroup
newSubnetGroup =
  SubnetGroup' :: Maybe Text
-> Maybe Text
-> Maybe [Subnet]
-> Maybe Text
-> Maybe Text
-> SubnetGroup
SubnetGroup'
    { $sel:arn:SubnetGroup' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:SubnetGroup' :: Maybe Text
vpcId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:SubnetGroup' :: Maybe [Subnet]
subnets = Maybe [Subnet]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:SubnetGroup' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:SubnetGroup' :: Maybe Text
description = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> SubnetGroup -> f SubnetGroup
subnetGroup_arn = (SubnetGroup -> Maybe Text)
-> (SubnetGroup -> Maybe Text -> SubnetGroup)
-> Lens SubnetGroup SubnetGroup (Maybe Text) (Maybe Text)
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)

-- | The Amazon Virtual Private Cloud identifier (VPC ID) of the subnet
-- group.
subnetGroup_vpcId :: Lens.Lens' SubnetGroup (Prelude.Maybe Prelude.Text)
subnetGroup_vpcId :: (Maybe Text -> f (Maybe Text)) -> SubnetGroup -> f SubnetGroup
subnetGroup_vpcId = (SubnetGroup -> Maybe Text)
-> (SubnetGroup -> Maybe Text -> SubnetGroup)
-> Lens SubnetGroup SubnetGroup (Maybe Text) (Maybe Text)
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)

-- | A list of subnets associated with the subnet group.
subnetGroup_subnets :: Lens.Lens' SubnetGroup (Prelude.Maybe [Subnet])
subnetGroup_subnets :: (Maybe [Subnet] -> f (Maybe [Subnet]))
-> SubnetGroup -> f SubnetGroup
subnetGroup_subnets = (SubnetGroup -> Maybe [Subnet])
-> (SubnetGroup -> Maybe [Subnet] -> SubnetGroup)
-> Lens SubnetGroup SubnetGroup (Maybe [Subnet]) (Maybe [Subnet])
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) ((Maybe [Subnet] -> f (Maybe [Subnet]))
 -> SubnetGroup -> f SubnetGroup)
-> ((Maybe [Subnet] -> f (Maybe [Subnet]))
    -> Maybe [Subnet] -> f (Maybe [Subnet]))
-> (Maybe [Subnet] -> f (Maybe [Subnet]))
-> SubnetGroup
-> f SubnetGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Subnet] [Subnet] [Subnet] [Subnet]
-> Iso
     (Maybe [Subnet]) (Maybe [Subnet]) (Maybe [Subnet]) (Maybe [Subnet])
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 AnIso [Subnet] [Subnet] [Subnet] [Subnet]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the subnet group
subnetGroup_name :: Lens.Lens' SubnetGroup (Prelude.Maybe Prelude.Text)
subnetGroup_name :: (Maybe Text -> f (Maybe Text)) -> SubnetGroup -> f SubnetGroup
subnetGroup_name = (SubnetGroup -> Maybe Text)
-> (SubnetGroup -> Maybe Text -> SubnetGroup)
-> Lens SubnetGroup SubnetGroup (Maybe Text) (Maybe Text)
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 description of the subnet group
subnetGroup_description :: Lens.Lens' SubnetGroup (Prelude.Maybe Prelude.Text)
subnetGroup_description :: (Maybe Text -> f (Maybe Text)) -> SubnetGroup -> f SubnetGroup
subnetGroup_description = (SubnetGroup -> Maybe Text)
-> (SubnetGroup -> Maybe Text -> SubnetGroup)
-> Lens SubnetGroup SubnetGroup (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON SubnetGroup where
  parseJSON :: Value -> Parser SubnetGroup
parseJSON =
    String
-> (Object -> Parser SubnetGroup) -> Value -> Parser SubnetGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SubnetGroup"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe [Subnet]
-> Maybe Text
-> Maybe Text
-> SubnetGroup
SubnetGroup'
            (Maybe Text
 -> Maybe Text
 -> Maybe [Subnet]
 -> Maybe Text
 -> Maybe Text
 -> SubnetGroup)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [Subnet] -> Maybe Text -> Maybe Text -> SubnetGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ARN")
            Parser
  (Maybe Text
   -> Maybe [Subnet] -> Maybe Text -> Maybe Text -> SubnetGroup)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Subnet] -> Maybe Text -> Maybe Text -> SubnetGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"VpcId")
            Parser (Maybe [Subnet] -> Maybe Text -> Maybe Text -> SubnetGroup)
-> Parser (Maybe [Subnet])
-> Parser (Maybe Text -> Maybe Text -> SubnetGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Subnet]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Subnets" Parser (Maybe (Maybe [Subnet]))
-> Maybe [Subnet] -> Parser (Maybe [Subnet])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Subnet]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> SubnetGroup)
-> Parser (Maybe Text) -> Parser (Maybe Text -> SubnetGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser (Maybe Text -> SubnetGroup)
-> Parser (Maybe Text) -> Parser SubnetGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Description")
      )

instance Prelude.Hashable SubnetGroup

instance Prelude.NFData SubnetGroup