{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ElastiCache.Types.CacheSubnetGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElastiCache.Types.NetworkType
import Amazonka.ElastiCache.Types.Subnet
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 description of the cache subnet group.
    CacheSubnetGroup -> Maybe Text
cacheSubnetGroupDescription :: Prelude.Maybe Prelude.Text,
    -- | The name of the cache subnet group.
    CacheSubnetGroup -> Maybe Text
cacheSubnetGroupName :: Prelude.Maybe Prelude.Text,
    -- | A list of subnets associated with the cache subnet group.
    CacheSubnetGroup -> Maybe [Subnet]
subnets :: Prelude.Maybe [Subnet],
    -- | Either @ipv4@ | @ipv6@ | @dual_stack@. IPv6 is supported for workloads
    -- using Redis engine version 6.2 onward or Memcached engine version 1.6.6
    -- on all instances built on the
    -- <https://aws.amazon.com/ec2/nitro/ Nitro system>.
    CacheSubnetGroup -> Maybe [NetworkType]
supportedNetworkTypes :: Prelude.Maybe [NetworkType],
    -- | The Amazon Virtual Private Cloud identifier (VPC ID) of the cache subnet
    -- group.
    CacheSubnetGroup -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text
  }
  deriving (CacheSubnetGroup -> CacheSubnetGroup -> Bool
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]
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
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. 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.
--
-- 'cacheSubnetGroupDescription', 'cacheSubnetGroup_cacheSubnetGroupDescription' - The description of the cache subnet group.
--
-- 'cacheSubnetGroupName', 'cacheSubnetGroup_cacheSubnetGroupName' - The name of the cache subnet group.
--
-- 'subnets', 'cacheSubnetGroup_subnets' - A list of subnets associated with the cache subnet group.
--
-- 'supportedNetworkTypes', 'cacheSubnetGroup_supportedNetworkTypes' - Either @ipv4@ | @ipv6@ | @dual_stack@. IPv6 is supported for workloads
-- using Redis engine version 6.2 onward or Memcached engine version 1.6.6
-- on all instances built on the
-- <https://aws.amazon.com/ec2/nitro/ Nitro system>.
--
-- 'vpcId', 'cacheSubnetGroup_vpcId' - The Amazon Virtual Private Cloud identifier (VPC ID) of the cache subnet
-- group.
newCacheSubnetGroup ::
  CacheSubnetGroup
newCacheSubnetGroup :: CacheSubnetGroup
newCacheSubnetGroup =
  CacheSubnetGroup'
    { $sel:arn:CacheSubnetGroup' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:cacheSubnetGroupDescription:CacheSubnetGroup' :: Maybe Text
cacheSubnetGroupDescription = forall a. Maybe a
Prelude.Nothing,
      $sel:cacheSubnetGroupName:CacheSubnetGroup' :: Maybe Text
cacheSubnetGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:CacheSubnetGroup' :: Maybe [Subnet]
subnets = forall a. Maybe a
Prelude.Nothing,
      $sel:supportedNetworkTypes:CacheSubnetGroup' :: Maybe [NetworkType]
supportedNetworkTypes = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:CacheSubnetGroup' :: Maybe Text
vpcId = 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 :: Lens' CacheSubnetGroup (Maybe Text)
cacheSubnetGroup_arn = 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 description of the cache subnet group.
cacheSubnetGroup_cacheSubnetGroupDescription :: Lens.Lens' CacheSubnetGroup (Prelude.Maybe Prelude.Text)
cacheSubnetGroup_cacheSubnetGroupDescription :: Lens' CacheSubnetGroup (Maybe Text)
cacheSubnetGroup_cacheSubnetGroupDescription = 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)

-- | The name of the cache subnet group.
cacheSubnetGroup_cacheSubnetGroupName :: Lens.Lens' CacheSubnetGroup (Prelude.Maybe Prelude.Text)
cacheSubnetGroup_cacheSubnetGroupName :: Lens' CacheSubnetGroup (Maybe Text)
cacheSubnetGroup_cacheSubnetGroupName = 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)

-- | A list of subnets associated with the cache subnet group.
cacheSubnetGroup_subnets :: Lens.Lens' CacheSubnetGroup (Prelude.Maybe [Subnet])
cacheSubnetGroup_subnets :: Lens' CacheSubnetGroup (Maybe [Subnet])
cacheSubnetGroup_subnets = 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) 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

-- | Either @ipv4@ | @ipv6@ | @dual_stack@. IPv6 is supported for workloads
-- using Redis engine version 6.2 onward or Memcached engine version 1.6.6
-- on all instances built on the
-- <https://aws.amazon.com/ec2/nitro/ Nitro system>.
cacheSubnetGroup_supportedNetworkTypes :: Lens.Lens' CacheSubnetGroup (Prelude.Maybe [NetworkType])
cacheSubnetGroup_supportedNetworkTypes :: Lens' CacheSubnetGroup (Maybe [NetworkType])
cacheSubnetGroup_supportedNetworkTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSubnetGroup' {Maybe [NetworkType]
supportedNetworkTypes :: Maybe [NetworkType]
$sel:supportedNetworkTypes:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe [NetworkType]
supportedNetworkTypes} -> Maybe [NetworkType]
supportedNetworkTypes) (\s :: CacheSubnetGroup
s@CacheSubnetGroup' {} Maybe [NetworkType]
a -> CacheSubnetGroup
s {$sel:supportedNetworkTypes:CacheSubnetGroup' :: Maybe [NetworkType]
supportedNetworkTypes = Maybe [NetworkType]
a} :: CacheSubnetGroup) 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 cache subnet
-- group.
cacheSubnetGroup_vpcId :: Lens.Lens' CacheSubnetGroup (Prelude.Maybe Prelude.Text)
cacheSubnetGroup_vpcId :: Lens' CacheSubnetGroup (Maybe Text)
cacheSubnetGroup_vpcId = 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)

instance Data.FromXML CacheSubnetGroup where
  parseXML :: [Node] -> Either String CacheSubnetGroup
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Subnet]
-> Maybe [NetworkType]
-> Maybe Text
-> CacheSubnetGroup
CacheSubnetGroup'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ARN")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CacheSubnetGroupDescription")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CacheSubnetGroupName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Subnets"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"Subnet")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"SupportedNetworkTypes"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"VpcId")

instance Prelude.Hashable CacheSubnetGroup where
  hashWithSalt :: Int -> CacheSubnetGroup -> Int
hashWithSalt Int
_salt CacheSubnetGroup' {Maybe [NetworkType]
Maybe [Subnet]
Maybe Text
vpcId :: Maybe Text
supportedNetworkTypes :: Maybe [NetworkType]
subnets :: Maybe [Subnet]
cacheSubnetGroupName :: Maybe Text
cacheSubnetGroupDescription :: Maybe Text
arn :: Maybe Text
$sel:vpcId:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe Text
$sel:supportedNetworkTypes:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe [NetworkType]
$sel:subnets:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe [Subnet]
$sel:cacheSubnetGroupName:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe Text
$sel:cacheSubnetGroupDescription:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe Text
$sel:arn:CacheSubnetGroup' :: CacheSubnetGroup -> 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
cacheSubnetGroupDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
cacheSubnetGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Subnet]
subnets
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [NetworkType]
supportedNetworkTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId

instance Prelude.NFData CacheSubnetGroup where
  rnf :: CacheSubnetGroup -> ()
rnf CacheSubnetGroup' {Maybe [NetworkType]
Maybe [Subnet]
Maybe Text
vpcId :: Maybe Text
supportedNetworkTypes :: Maybe [NetworkType]
subnets :: Maybe [Subnet]
cacheSubnetGroupName :: Maybe Text
cacheSubnetGroupDescription :: Maybe Text
arn :: Maybe Text
$sel:vpcId:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe Text
$sel:supportedNetworkTypes:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe [NetworkType]
$sel:subnets:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe [Subnet]
$sel:cacheSubnetGroupName:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe Text
$sel:cacheSubnetGroupDescription:CacheSubnetGroup' :: CacheSubnetGroup -> Maybe Text
$sel:arn:CacheSubnetGroup' :: CacheSubnetGroup -> 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
cacheSubnetGroupDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
cacheSubnetGroupName
      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 [NetworkType]
supportedNetworkTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcId