{-# 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.DocumentDB.Types.DBSubnetGroup
-- 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.DocumentDB.Types.DBSubnetGroup where

import qualified Amazonka.Core as Core
import Amazonka.DocumentDB.Types.Subnet
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Detailed information about a subnet group.
--
-- /See:/ 'newDBSubnetGroup' smart constructor.
data DBSubnetGroup = DBSubnetGroup'
  { -- | The name of the subnet group.
    DBSubnetGroup -> Maybe Text
dbSubnetGroupName :: Prelude.Maybe Prelude.Text,
    -- | Provides the virtual private cloud (VPC) ID of the subnet group.
    DBSubnetGroup -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text,
    -- | Detailed information about one or more subnets within a subnet group.
    DBSubnetGroup -> Maybe [Subnet]
subnets :: Prelude.Maybe [Subnet],
    -- | Provides the description of the subnet group.
    DBSubnetGroup -> Maybe Text
dbSubnetGroupDescription :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) for the DB subnet group.
    DBSubnetGroup -> Maybe Text
dbSubnetGroupArn :: Prelude.Maybe Prelude.Text,
    -- | Provides the status of the subnet group.
    DBSubnetGroup -> Maybe Text
subnetGroupStatus :: Prelude.Maybe Prelude.Text
  }
  deriving (DBSubnetGroup -> DBSubnetGroup -> Bool
(DBSubnetGroup -> DBSubnetGroup -> Bool)
-> (DBSubnetGroup -> DBSubnetGroup -> Bool) -> Eq DBSubnetGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBSubnetGroup -> DBSubnetGroup -> Bool
$c/= :: DBSubnetGroup -> DBSubnetGroup -> Bool
== :: DBSubnetGroup -> DBSubnetGroup -> Bool
$c== :: DBSubnetGroup -> DBSubnetGroup -> Bool
Prelude.Eq, ReadPrec [DBSubnetGroup]
ReadPrec DBSubnetGroup
Int -> ReadS DBSubnetGroup
ReadS [DBSubnetGroup]
(Int -> ReadS DBSubnetGroup)
-> ReadS [DBSubnetGroup]
-> ReadPrec DBSubnetGroup
-> ReadPrec [DBSubnetGroup]
-> Read DBSubnetGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DBSubnetGroup]
$creadListPrec :: ReadPrec [DBSubnetGroup]
readPrec :: ReadPrec DBSubnetGroup
$creadPrec :: ReadPrec DBSubnetGroup
readList :: ReadS [DBSubnetGroup]
$creadList :: ReadS [DBSubnetGroup]
readsPrec :: Int -> ReadS DBSubnetGroup
$creadsPrec :: Int -> ReadS DBSubnetGroup
Prelude.Read, Int -> DBSubnetGroup -> ShowS
[DBSubnetGroup] -> ShowS
DBSubnetGroup -> String
(Int -> DBSubnetGroup -> ShowS)
-> (DBSubnetGroup -> String)
-> ([DBSubnetGroup] -> ShowS)
-> Show DBSubnetGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DBSubnetGroup] -> ShowS
$cshowList :: [DBSubnetGroup] -> ShowS
show :: DBSubnetGroup -> String
$cshow :: DBSubnetGroup -> String
showsPrec :: Int -> DBSubnetGroup -> ShowS
$cshowsPrec :: Int -> DBSubnetGroup -> ShowS
Prelude.Show, (forall x. DBSubnetGroup -> Rep DBSubnetGroup x)
-> (forall x. Rep DBSubnetGroup x -> DBSubnetGroup)
-> Generic DBSubnetGroup
forall x. Rep DBSubnetGroup x -> DBSubnetGroup
forall x. DBSubnetGroup -> Rep DBSubnetGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DBSubnetGroup x -> DBSubnetGroup
$cfrom :: forall x. DBSubnetGroup -> Rep DBSubnetGroup x
Prelude.Generic)

-- |
-- Create a value of 'DBSubnetGroup' 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:
--
-- 'dbSubnetGroupName', 'dbSubnetGroup_dbSubnetGroupName' - The name of the subnet group.
--
-- 'vpcId', 'dbSubnetGroup_vpcId' - Provides the virtual private cloud (VPC) ID of the subnet group.
--
-- 'subnets', 'dbSubnetGroup_subnets' - Detailed information about one or more subnets within a subnet group.
--
-- 'dbSubnetGroupDescription', 'dbSubnetGroup_dbSubnetGroupDescription' - Provides the description of the subnet group.
--
-- 'dbSubnetGroupArn', 'dbSubnetGroup_dbSubnetGroupArn' - The Amazon Resource Name (ARN) for the DB subnet group.
--
-- 'subnetGroupStatus', 'dbSubnetGroup_subnetGroupStatus' - Provides the status of the subnet group.
newDBSubnetGroup ::
  DBSubnetGroup
newDBSubnetGroup :: DBSubnetGroup
newDBSubnetGroup =
  DBSubnetGroup' :: Maybe Text
-> Maybe Text
-> Maybe [Subnet]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> DBSubnetGroup
DBSubnetGroup'
    { $sel:dbSubnetGroupName:DBSubnetGroup' :: Maybe Text
dbSubnetGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:DBSubnetGroup' :: Maybe Text
vpcId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:DBSubnetGroup' :: Maybe [Subnet]
subnets = Maybe [Subnet]
forall a. Maybe a
Prelude.Nothing,
      $sel:dbSubnetGroupDescription:DBSubnetGroup' :: Maybe Text
dbSubnetGroupDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dbSubnetGroupArn:DBSubnetGroup' :: Maybe Text
dbSubnetGroupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subnetGroupStatus:DBSubnetGroup' :: Maybe Text
subnetGroupStatus = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | Provides the virtual private cloud (VPC) ID of the subnet group.
dbSubnetGroup_vpcId :: Lens.Lens' DBSubnetGroup (Prelude.Maybe Prelude.Text)
dbSubnetGroup_vpcId :: (Maybe Text -> f (Maybe Text)) -> DBSubnetGroup -> f DBSubnetGroup
dbSubnetGroup_vpcId = (DBSubnetGroup -> Maybe Text)
-> (DBSubnetGroup -> Maybe Text -> DBSubnetGroup)
-> Lens DBSubnetGroup DBSubnetGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSubnetGroup' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:DBSubnetGroup' :: DBSubnetGroup -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: DBSubnetGroup
s@DBSubnetGroup' {} Maybe Text
a -> DBSubnetGroup
s {$sel:vpcId:DBSubnetGroup' :: Maybe Text
vpcId = Maybe Text
a} :: DBSubnetGroup)

-- | Detailed information about one or more subnets within a subnet group.
dbSubnetGroup_subnets :: Lens.Lens' DBSubnetGroup (Prelude.Maybe [Subnet])
dbSubnetGroup_subnets :: (Maybe [Subnet] -> f (Maybe [Subnet]))
-> DBSubnetGroup -> f DBSubnetGroup
dbSubnetGroup_subnets = (DBSubnetGroup -> Maybe [Subnet])
-> (DBSubnetGroup -> Maybe [Subnet] -> DBSubnetGroup)
-> Lens
     DBSubnetGroup DBSubnetGroup (Maybe [Subnet]) (Maybe [Subnet])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSubnetGroup' {Maybe [Subnet]
subnets :: Maybe [Subnet]
$sel:subnets:DBSubnetGroup' :: DBSubnetGroup -> Maybe [Subnet]
subnets} -> Maybe [Subnet]
subnets) (\s :: DBSubnetGroup
s@DBSubnetGroup' {} Maybe [Subnet]
a -> DBSubnetGroup
s {$sel:subnets:DBSubnetGroup' :: Maybe [Subnet]
subnets = Maybe [Subnet]
a} :: DBSubnetGroup) ((Maybe [Subnet] -> f (Maybe [Subnet]))
 -> DBSubnetGroup -> f DBSubnetGroup)
-> ((Maybe [Subnet] -> f (Maybe [Subnet]))
    -> Maybe [Subnet] -> f (Maybe [Subnet]))
-> (Maybe [Subnet] -> f (Maybe [Subnet]))
-> DBSubnetGroup
-> f DBSubnetGroup
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

-- | Provides the description of the subnet group.
dbSubnetGroup_dbSubnetGroupDescription :: Lens.Lens' DBSubnetGroup (Prelude.Maybe Prelude.Text)
dbSubnetGroup_dbSubnetGroupDescription :: (Maybe Text -> f (Maybe Text)) -> DBSubnetGroup -> f DBSubnetGroup
dbSubnetGroup_dbSubnetGroupDescription = (DBSubnetGroup -> Maybe Text)
-> (DBSubnetGroup -> Maybe Text -> DBSubnetGroup)
-> Lens DBSubnetGroup DBSubnetGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSubnetGroup' {Maybe Text
dbSubnetGroupDescription :: Maybe Text
$sel:dbSubnetGroupDescription:DBSubnetGroup' :: DBSubnetGroup -> Maybe Text
dbSubnetGroupDescription} -> Maybe Text
dbSubnetGroupDescription) (\s :: DBSubnetGroup
s@DBSubnetGroup' {} Maybe Text
a -> DBSubnetGroup
s {$sel:dbSubnetGroupDescription:DBSubnetGroup' :: Maybe Text
dbSubnetGroupDescription = Maybe Text
a} :: DBSubnetGroup)

-- | The Amazon Resource Name (ARN) for the DB subnet group.
dbSubnetGroup_dbSubnetGroupArn :: Lens.Lens' DBSubnetGroup (Prelude.Maybe Prelude.Text)
dbSubnetGroup_dbSubnetGroupArn :: (Maybe Text -> f (Maybe Text)) -> DBSubnetGroup -> f DBSubnetGroup
dbSubnetGroup_dbSubnetGroupArn = (DBSubnetGroup -> Maybe Text)
-> (DBSubnetGroup -> Maybe Text -> DBSubnetGroup)
-> Lens DBSubnetGroup DBSubnetGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSubnetGroup' {Maybe Text
dbSubnetGroupArn :: Maybe Text
$sel:dbSubnetGroupArn:DBSubnetGroup' :: DBSubnetGroup -> Maybe Text
dbSubnetGroupArn} -> Maybe Text
dbSubnetGroupArn) (\s :: DBSubnetGroup
s@DBSubnetGroup' {} Maybe Text
a -> DBSubnetGroup
s {$sel:dbSubnetGroupArn:DBSubnetGroup' :: Maybe Text
dbSubnetGroupArn = Maybe Text
a} :: DBSubnetGroup)

-- | Provides the status of the subnet group.
dbSubnetGroup_subnetGroupStatus :: Lens.Lens' DBSubnetGroup (Prelude.Maybe Prelude.Text)
dbSubnetGroup_subnetGroupStatus :: (Maybe Text -> f (Maybe Text)) -> DBSubnetGroup -> f DBSubnetGroup
dbSubnetGroup_subnetGroupStatus = (DBSubnetGroup -> Maybe Text)
-> (DBSubnetGroup -> Maybe Text -> DBSubnetGroup)
-> Lens DBSubnetGroup DBSubnetGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSubnetGroup' {Maybe Text
subnetGroupStatus :: Maybe Text
$sel:subnetGroupStatus:DBSubnetGroup' :: DBSubnetGroup -> Maybe Text
subnetGroupStatus} -> Maybe Text
subnetGroupStatus) (\s :: DBSubnetGroup
s@DBSubnetGroup' {} Maybe Text
a -> DBSubnetGroup
s {$sel:subnetGroupStatus:DBSubnetGroup' :: Maybe Text
subnetGroupStatus = Maybe Text
a} :: DBSubnetGroup)

instance Core.FromXML DBSubnetGroup where
  parseXML :: [Node] -> Either String DBSubnetGroup
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe [Subnet]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> DBSubnetGroup
DBSubnetGroup'
      (Maybe Text
 -> Maybe Text
 -> Maybe [Subnet]
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> DBSubnetGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe [Subnet]
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> DBSubnetGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DBSubnetGroupName")
      Either
  String
  (Maybe Text
   -> Maybe [Subnet]
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> DBSubnetGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [Subnet]
      -> Maybe Text -> Maybe Text -> Maybe Text -> DBSubnetGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"VpcId")
      Either
  String
  (Maybe [Subnet]
   -> Maybe Text -> Maybe Text -> Maybe Text -> DBSubnetGroup)
-> Either String (Maybe [Subnet])
-> Either
     String (Maybe Text -> Maybe Text -> Maybe Text -> DBSubnetGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Subnets" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Subnet]))
-> Either String (Maybe [Subnet])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Subnet])
-> [Node] -> Either String (Maybe [Subnet])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Subnet]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Subnet")
                  )
      Either
  String (Maybe Text -> Maybe Text -> Maybe Text -> DBSubnetGroup)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Text -> DBSubnetGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DBSubnetGroupDescription")
      Either String (Maybe Text -> Maybe Text -> DBSubnetGroup)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> DBSubnetGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DBSubnetGroupArn")
      Either String (Maybe Text -> DBSubnetGroup)
-> Either String (Maybe Text) -> Either String DBSubnetGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SubnetGroupStatus")

instance Prelude.Hashable DBSubnetGroup

instance Prelude.NFData DBSubnetGroup