{-# 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.ElastiCache.Types.CacheSubnetGroup
-- 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.ElastiCache.Types.CacheSubnetGroup where

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

-- | Represents the output of one of the following operations:
--
-- -   @CreateCacheSubnetGroup@
--
-- -   @ModifyCacheSubnetGroup@
--
-- /See:/ 'newCacheSubnetGroup' smart constructor.
data CacheSubnetGroup = CacheSubnetGroup'
  { -- | The ARN (Amazon Resource Name) of the cache subnet group.
    CacheSubnetGroup -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Virtual Private Cloud identifier (VPC ID) of the cache subnet
    -- group.
    CacheSubnetGroup -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text,
    -- | A list of subnets associated with the cache subnet group.
    CacheSubnetGroup -> Maybe [Subnet]
subnets :: Prelude.Maybe [Subnet],
    -- | The name of the cache subnet group.
    CacheSubnetGroup -> Maybe Text
cacheSubnetGroupName :: Prelude.Maybe Prelude.Text,
    -- | The description of the cache subnet group.
    CacheSubnetGroup -> Maybe Text
cacheSubnetGroupDescription :: Prelude.Maybe Prelude.Text
  }
  deriving (CacheSubnetGroup -> CacheSubnetGroup -> Bool
(CacheSubnetGroup -> CacheSubnetGroup -> Bool)
-> (CacheSubnetGroup -> CacheSubnetGroup -> Bool)
-> Eq CacheSubnetGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CacheSubnetGroup -> CacheSubnetGroup -> Bool
$c/= :: CacheSubnetGroup -> CacheSubnetGroup -> Bool
== :: CacheSubnetGroup -> CacheSubnetGroup -> Bool
$c== :: CacheSubnetGroup -> CacheSubnetGroup -> Bool
Prelude.Eq, ReadPrec [CacheSubnetGroup]
ReadPrec CacheSubnetGroup
Int -> ReadS CacheSubnetGroup
ReadS [CacheSubnetGroup]
(Int -> ReadS CacheSubnetGroup)
-> ReadS [CacheSubnetGroup]
-> ReadPrec CacheSubnetGroup
-> ReadPrec [CacheSubnetGroup]
-> Read CacheSubnetGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CacheSubnetGroup]
$creadListPrec :: ReadPrec [CacheSubnetGroup]
readPrec :: ReadPrec CacheSubnetGroup
$creadPrec :: ReadPrec CacheSubnetGroup
readList :: ReadS [CacheSubnetGroup]
$creadList :: ReadS [CacheSubnetGroup]
readsPrec :: Int -> ReadS CacheSubnetGroup
$creadsPrec :: Int -> ReadS CacheSubnetGroup
Prelude.Read, Int -> CacheSubnetGroup -> ShowS
[CacheSubnetGroup] -> ShowS
CacheSubnetGroup -> String
(Int -> CacheSubnetGroup -> ShowS)
-> (CacheSubnetGroup -> String)
-> ([CacheSubnetGroup] -> ShowS)
-> Show CacheSubnetGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CacheSubnetGroup] -> ShowS
$cshowList :: [CacheSubnetGroup] -> ShowS
show :: CacheSubnetGroup -> String
$cshow :: CacheSubnetGroup -> String
showsPrec :: Int -> CacheSubnetGroup -> ShowS
$cshowsPrec :: Int -> CacheSubnetGroup -> ShowS
Prelude.Show, (forall x. CacheSubnetGroup -> Rep CacheSubnetGroup x)
-> (forall x. Rep CacheSubnetGroup x -> CacheSubnetGroup)
-> Generic CacheSubnetGroup
forall x. Rep CacheSubnetGroup x -> CacheSubnetGroup
forall x. CacheSubnetGroup -> Rep CacheSubnetGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CacheSubnetGroup x -> CacheSubnetGroup
$cfrom :: forall x. CacheSubnetGroup -> Rep CacheSubnetGroup x
Prelude.Generic)

-- |
-- Create a value of 'CacheSubnetGroup' 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', 'cacheSubnetGroup_arn' - The ARN (Amazon Resource Name) of the cache subnet group.
--
-- 'vpcId', 'cacheSubnetGroup_vpcId' - The Amazon Virtual Private Cloud identifier (VPC ID) of the cache subnet
-- group.
--
-- 'subnets', 'cacheSubnetGroup_subnets' - A list of subnets associated with the cache subnet group.
--
-- 'cacheSubnetGroupName', 'cacheSubnetGroup_cacheSubnetGroupName' - The name of the cache subnet group.
--
-- 'cacheSubnetGroupDescription', 'cacheSubnetGroup_cacheSubnetGroupDescription' - The description of the cache subnet group.
newCacheSubnetGroup ::
  CacheSubnetGroup
newCacheSubnetGroup :: CacheSubnetGroup
newCacheSubnetGroup =
  CacheSubnetGroup' :: Maybe Text
-> Maybe Text
-> Maybe [Subnet]
-> Maybe Text
-> Maybe Text
-> CacheSubnetGroup
CacheSubnetGroup'
    { $sel:arn:CacheSubnetGroup' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:CacheSubnetGroup' :: Maybe Text
vpcId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:CacheSubnetGroup' :: Maybe [Subnet]
subnets = Maybe [Subnet]
forall a. Maybe a
Prelude.Nothing,
      $sel:cacheSubnetGroupName:CacheSubnetGroup' :: Maybe Text
cacheSubnetGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:cacheSubnetGroupDescription:CacheSubnetGroup' :: Maybe Text
cacheSubnetGroupDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The Amazon Virtual Private Cloud identifier (VPC ID) of the cache subnet
-- group.
cacheSubnetGroup_vpcId :: Lens.Lens' CacheSubnetGroup (Prelude.Maybe Prelude.Text)
cacheSubnetGroup_vpcId :: (Maybe Text -> f (Maybe Text))
-> CacheSubnetGroup -> f CacheSubnetGroup
cacheSubnetGroup_vpcId = (CacheSubnetGroup -> Maybe Text)
-> (CacheSubnetGroup -> Maybe Text -> CacheSubnetGroup)
-> Lens CacheSubnetGroup CacheSubnetGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSubnetGroup' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: CacheSubnetGroup
s@CacheSubnetGroup' {} Maybe Text
a -> CacheSubnetGroup
s {$sel:vpcId:CacheSubnetGroup' :: Maybe Text
vpcId = Maybe Text
a} :: CacheSubnetGroup)

-- | A list of subnets associated with the cache subnet group.
cacheSubnetGroup_subnets :: Lens.Lens' CacheSubnetGroup (Prelude.Maybe [Subnet])
cacheSubnetGroup_subnets :: (Maybe [Subnet] -> f (Maybe [Subnet]))
-> CacheSubnetGroup -> f CacheSubnetGroup
cacheSubnetGroup_subnets = (CacheSubnetGroup -> Maybe [Subnet])
-> (CacheSubnetGroup -> Maybe [Subnet] -> CacheSubnetGroup)
-> Lens
     CacheSubnetGroup CacheSubnetGroup (Maybe [Subnet]) (Maybe [Subnet])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSubnetGroup' {Maybe [Subnet]
subnets :: Maybe [Subnet]
$sel:subnets:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe [Subnet]
subnets} -> Maybe [Subnet]
subnets) (\s :: CacheSubnetGroup
s@CacheSubnetGroup' {} Maybe [Subnet]
a -> CacheSubnetGroup
s {$sel:subnets:CacheSubnetGroup' :: Maybe [Subnet]
subnets = Maybe [Subnet]
a} :: CacheSubnetGroup) ((Maybe [Subnet] -> f (Maybe [Subnet]))
 -> CacheSubnetGroup -> f CacheSubnetGroup)
-> ((Maybe [Subnet] -> f (Maybe [Subnet]))
    -> Maybe [Subnet] -> f (Maybe [Subnet]))
-> (Maybe [Subnet] -> f (Maybe [Subnet]))
-> CacheSubnetGroup
-> f CacheSubnetGroup
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 cache subnet group.
cacheSubnetGroup_cacheSubnetGroupName :: Lens.Lens' CacheSubnetGroup (Prelude.Maybe Prelude.Text)
cacheSubnetGroup_cacheSubnetGroupName :: (Maybe Text -> f (Maybe Text))
-> CacheSubnetGroup -> f CacheSubnetGroup
cacheSubnetGroup_cacheSubnetGroupName = (CacheSubnetGroup -> Maybe Text)
-> (CacheSubnetGroup -> Maybe Text -> CacheSubnetGroup)
-> Lens CacheSubnetGroup CacheSubnetGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSubnetGroup' {Maybe Text
cacheSubnetGroupName :: Maybe Text
$sel:cacheSubnetGroupName:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe Text
cacheSubnetGroupName} -> Maybe Text
cacheSubnetGroupName) (\s :: CacheSubnetGroup
s@CacheSubnetGroup' {} Maybe Text
a -> CacheSubnetGroup
s {$sel:cacheSubnetGroupName:CacheSubnetGroup' :: Maybe Text
cacheSubnetGroupName = Maybe Text
a} :: CacheSubnetGroup)

-- | The description of the cache subnet group.
cacheSubnetGroup_cacheSubnetGroupDescription :: Lens.Lens' CacheSubnetGroup (Prelude.Maybe Prelude.Text)
cacheSubnetGroup_cacheSubnetGroupDescription :: (Maybe Text -> f (Maybe Text))
-> CacheSubnetGroup -> f CacheSubnetGroup
cacheSubnetGroup_cacheSubnetGroupDescription = (CacheSubnetGroup -> Maybe Text)
-> (CacheSubnetGroup -> Maybe Text -> CacheSubnetGroup)
-> Lens CacheSubnetGroup CacheSubnetGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSubnetGroup' {Maybe Text
cacheSubnetGroupDescription :: Maybe Text
$sel:cacheSubnetGroupDescription:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe Text
cacheSubnetGroupDescription} -> Maybe Text
cacheSubnetGroupDescription) (\s :: CacheSubnetGroup
s@CacheSubnetGroup' {} Maybe Text
a -> CacheSubnetGroup
s {$sel:cacheSubnetGroupDescription:CacheSubnetGroup' :: Maybe Text
cacheSubnetGroupDescription = Maybe Text
a} :: CacheSubnetGroup)

instance Core.FromXML CacheSubnetGroup where
  parseXML :: [Node] -> Either String CacheSubnetGroup
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe [Subnet]
-> Maybe Text
-> Maybe Text
-> CacheSubnetGroup
CacheSubnetGroup'
      (Maybe Text
 -> Maybe Text
 -> Maybe [Subnet]
 -> Maybe Text
 -> Maybe Text
 -> CacheSubnetGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe [Subnet] -> Maybe Text -> Maybe Text -> CacheSubnetGroup)
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
"ARN")
      Either
  String
  (Maybe Text
   -> Maybe [Subnet] -> Maybe Text -> Maybe Text -> CacheSubnetGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [Subnet] -> Maybe Text -> Maybe Text -> CacheSubnetGroup)
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 -> CacheSubnetGroup)
-> Either String (Maybe [Subnet])
-> Either String (Maybe Text -> Maybe Text -> CacheSubnetGroup)
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 -> CacheSubnetGroup)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> CacheSubnetGroup)
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
"CacheSubnetGroupName")
      Either String (Maybe Text -> CacheSubnetGroup)
-> Either String (Maybe Text) -> Either String CacheSubnetGroup
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
"CacheSubnetGroupDescription")

instance Prelude.Hashable CacheSubnetGroup

instance Prelude.NFData CacheSubnetGroup