{-# 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.CacheSecurityGroup
-- 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.CacheSecurityGroup where

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

-- | Represents the output of one of the following operations:
--
-- -   @AuthorizeCacheSecurityGroupIngress@
--
-- -   @CreateCacheSecurityGroup@
--
-- -   @RevokeCacheSecurityGroupIngress@
--
-- /See:/ 'newCacheSecurityGroup' smart constructor.
data CacheSecurityGroup = CacheSecurityGroup'
  { -- | The name of the cache security group.
    CacheSecurityGroup -> Maybe Text
cacheSecurityGroupName :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the cache security group,
    CacheSecurityGroup -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon account ID of the cache security group owner.
    CacheSecurityGroup -> Maybe Text
ownerId :: Prelude.Maybe Prelude.Text,
    -- | A list of Amazon EC2 security groups that are associated with this cache
    -- security group.
    CacheSecurityGroup -> Maybe [EC2SecurityGroup]
eC2SecurityGroups :: Prelude.Maybe [EC2SecurityGroup],
    -- | The description of the cache security group.
    CacheSecurityGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (CacheSecurityGroup -> CacheSecurityGroup -> Bool
(CacheSecurityGroup -> CacheSecurityGroup -> Bool)
-> (CacheSecurityGroup -> CacheSecurityGroup -> Bool)
-> Eq CacheSecurityGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CacheSecurityGroup -> CacheSecurityGroup -> Bool
$c/= :: CacheSecurityGroup -> CacheSecurityGroup -> Bool
== :: CacheSecurityGroup -> CacheSecurityGroup -> Bool
$c== :: CacheSecurityGroup -> CacheSecurityGroup -> Bool
Prelude.Eq, ReadPrec [CacheSecurityGroup]
ReadPrec CacheSecurityGroup
Int -> ReadS CacheSecurityGroup
ReadS [CacheSecurityGroup]
(Int -> ReadS CacheSecurityGroup)
-> ReadS [CacheSecurityGroup]
-> ReadPrec CacheSecurityGroup
-> ReadPrec [CacheSecurityGroup]
-> Read CacheSecurityGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CacheSecurityGroup]
$creadListPrec :: ReadPrec [CacheSecurityGroup]
readPrec :: ReadPrec CacheSecurityGroup
$creadPrec :: ReadPrec CacheSecurityGroup
readList :: ReadS [CacheSecurityGroup]
$creadList :: ReadS [CacheSecurityGroup]
readsPrec :: Int -> ReadS CacheSecurityGroup
$creadsPrec :: Int -> ReadS CacheSecurityGroup
Prelude.Read, Int -> CacheSecurityGroup -> ShowS
[CacheSecurityGroup] -> ShowS
CacheSecurityGroup -> String
(Int -> CacheSecurityGroup -> ShowS)
-> (CacheSecurityGroup -> String)
-> ([CacheSecurityGroup] -> ShowS)
-> Show CacheSecurityGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CacheSecurityGroup] -> ShowS
$cshowList :: [CacheSecurityGroup] -> ShowS
show :: CacheSecurityGroup -> String
$cshow :: CacheSecurityGroup -> String
showsPrec :: Int -> CacheSecurityGroup -> ShowS
$cshowsPrec :: Int -> CacheSecurityGroup -> ShowS
Prelude.Show, (forall x. CacheSecurityGroup -> Rep CacheSecurityGroup x)
-> (forall x. Rep CacheSecurityGroup x -> CacheSecurityGroup)
-> Generic CacheSecurityGroup
forall x. Rep CacheSecurityGroup x -> CacheSecurityGroup
forall x. CacheSecurityGroup -> Rep CacheSecurityGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CacheSecurityGroup x -> CacheSecurityGroup
$cfrom :: forall x. CacheSecurityGroup -> Rep CacheSecurityGroup x
Prelude.Generic)

-- |
-- Create a value of 'CacheSecurityGroup' 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:
--
-- 'cacheSecurityGroupName', 'cacheSecurityGroup_cacheSecurityGroupName' - The name of the cache security group.
--
-- 'arn', 'cacheSecurityGroup_arn' - The ARN of the cache security group,
--
-- 'ownerId', 'cacheSecurityGroup_ownerId' - The Amazon account ID of the cache security group owner.
--
-- 'eC2SecurityGroups', 'cacheSecurityGroup_eC2SecurityGroups' - A list of Amazon EC2 security groups that are associated with this cache
-- security group.
--
-- 'description', 'cacheSecurityGroup_description' - The description of the cache security group.
newCacheSecurityGroup ::
  CacheSecurityGroup
newCacheSecurityGroup :: CacheSecurityGroup
newCacheSecurityGroup =
  CacheSecurityGroup' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [EC2SecurityGroup]
-> Maybe Text
-> CacheSecurityGroup
CacheSecurityGroup'
    { $sel:cacheSecurityGroupName:CacheSecurityGroup' :: Maybe Text
cacheSecurityGroupName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:CacheSecurityGroup' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ownerId:CacheSecurityGroup' :: Maybe Text
ownerId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eC2SecurityGroups:CacheSecurityGroup' :: Maybe [EC2SecurityGroup]
eC2SecurityGroups = Maybe [EC2SecurityGroup]
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CacheSecurityGroup' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the cache security group.
cacheSecurityGroup_cacheSecurityGroupName :: Lens.Lens' CacheSecurityGroup (Prelude.Maybe Prelude.Text)
cacheSecurityGroup_cacheSecurityGroupName :: (Maybe Text -> f (Maybe Text))
-> CacheSecurityGroup -> f CacheSecurityGroup
cacheSecurityGroup_cacheSecurityGroupName = (CacheSecurityGroup -> Maybe Text)
-> (CacheSecurityGroup -> Maybe Text -> CacheSecurityGroup)
-> Lens
     CacheSecurityGroup CacheSecurityGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSecurityGroup' {Maybe Text
cacheSecurityGroupName :: Maybe Text
$sel:cacheSecurityGroupName:CacheSecurityGroup' :: CacheSecurityGroup -> Maybe Text
cacheSecurityGroupName} -> Maybe Text
cacheSecurityGroupName) (\s :: CacheSecurityGroup
s@CacheSecurityGroup' {} Maybe Text
a -> CacheSecurityGroup
s {$sel:cacheSecurityGroupName:CacheSecurityGroup' :: Maybe Text
cacheSecurityGroupName = Maybe Text
a} :: CacheSecurityGroup)

-- | The ARN of the cache security group,
cacheSecurityGroup_arn :: Lens.Lens' CacheSecurityGroup (Prelude.Maybe Prelude.Text)
cacheSecurityGroup_arn :: (Maybe Text -> f (Maybe Text))
-> CacheSecurityGroup -> f CacheSecurityGroup
cacheSecurityGroup_arn = (CacheSecurityGroup -> Maybe Text)
-> (CacheSecurityGroup -> Maybe Text -> CacheSecurityGroup)
-> Lens
     CacheSecurityGroup CacheSecurityGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSecurityGroup' {Maybe Text
arn :: Maybe Text
$sel:arn:CacheSecurityGroup' :: CacheSecurityGroup -> Maybe Text
arn} -> Maybe Text
arn) (\s :: CacheSecurityGroup
s@CacheSecurityGroup' {} Maybe Text
a -> CacheSecurityGroup
s {$sel:arn:CacheSecurityGroup' :: Maybe Text
arn = Maybe Text
a} :: CacheSecurityGroup)

-- | The Amazon account ID of the cache security group owner.
cacheSecurityGroup_ownerId :: Lens.Lens' CacheSecurityGroup (Prelude.Maybe Prelude.Text)
cacheSecurityGroup_ownerId :: (Maybe Text -> f (Maybe Text))
-> CacheSecurityGroup -> f CacheSecurityGroup
cacheSecurityGroup_ownerId = (CacheSecurityGroup -> Maybe Text)
-> (CacheSecurityGroup -> Maybe Text -> CacheSecurityGroup)
-> Lens
     CacheSecurityGroup CacheSecurityGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSecurityGroup' {Maybe Text
ownerId :: Maybe Text
$sel:ownerId:CacheSecurityGroup' :: CacheSecurityGroup -> Maybe Text
ownerId} -> Maybe Text
ownerId) (\s :: CacheSecurityGroup
s@CacheSecurityGroup' {} Maybe Text
a -> CacheSecurityGroup
s {$sel:ownerId:CacheSecurityGroup' :: Maybe Text
ownerId = Maybe Text
a} :: CacheSecurityGroup)

-- | A list of Amazon EC2 security groups that are associated with this cache
-- security group.
cacheSecurityGroup_eC2SecurityGroups :: Lens.Lens' CacheSecurityGroup (Prelude.Maybe [EC2SecurityGroup])
cacheSecurityGroup_eC2SecurityGroups :: (Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
-> CacheSecurityGroup -> f CacheSecurityGroup
cacheSecurityGroup_eC2SecurityGroups = (CacheSecurityGroup -> Maybe [EC2SecurityGroup])
-> (CacheSecurityGroup
    -> Maybe [EC2SecurityGroup] -> CacheSecurityGroup)
-> Lens
     CacheSecurityGroup
     CacheSecurityGroup
     (Maybe [EC2SecurityGroup])
     (Maybe [EC2SecurityGroup])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheSecurityGroup' {Maybe [EC2SecurityGroup]
eC2SecurityGroups :: Maybe [EC2SecurityGroup]
$sel:eC2SecurityGroups:CacheSecurityGroup' :: CacheSecurityGroup -> Maybe [EC2SecurityGroup]
eC2SecurityGroups} -> Maybe [EC2SecurityGroup]
eC2SecurityGroups) (\s :: CacheSecurityGroup
s@CacheSecurityGroup' {} Maybe [EC2SecurityGroup]
a -> CacheSecurityGroup
s {$sel:eC2SecurityGroups:CacheSecurityGroup' :: Maybe [EC2SecurityGroup]
eC2SecurityGroups = Maybe [EC2SecurityGroup]
a} :: CacheSecurityGroup) ((Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
 -> CacheSecurityGroup -> f CacheSecurityGroup)
-> ((Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
    -> Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
-> (Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
-> CacheSecurityGroup
-> f CacheSecurityGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EC2SecurityGroup]
  [EC2SecurityGroup]
  [EC2SecurityGroup]
  [EC2SecurityGroup]
-> Iso
     (Maybe [EC2SecurityGroup])
     (Maybe [EC2SecurityGroup])
     (Maybe [EC2SecurityGroup])
     (Maybe [EC2SecurityGroup])
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
  [EC2SecurityGroup]
  [EC2SecurityGroup]
  [EC2SecurityGroup]
  [EC2SecurityGroup]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Core.FromXML CacheSecurityGroup where
  parseXML :: [Node] -> Either String CacheSecurityGroup
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [EC2SecurityGroup]
-> Maybe Text
-> CacheSecurityGroup
CacheSecurityGroup'
      (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe [EC2SecurityGroup]
 -> Maybe Text
 -> CacheSecurityGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe [EC2SecurityGroup]
      -> Maybe Text
      -> CacheSecurityGroup)
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
"CacheSecurityGroupName")
      Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe [EC2SecurityGroup]
   -> Maybe Text
   -> CacheSecurityGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe [EC2SecurityGroup] -> Maybe Text -> CacheSecurityGroup)
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
"ARN")
      Either
  String
  (Maybe Text
   -> Maybe [EC2SecurityGroup] -> Maybe Text -> CacheSecurityGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [EC2SecurityGroup] -> Maybe Text -> CacheSecurityGroup)
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
"OwnerId")
      Either
  String
  (Maybe [EC2SecurityGroup] -> Maybe Text -> CacheSecurityGroup)
-> Either String (Maybe [EC2SecurityGroup])
-> Either String (Maybe Text -> CacheSecurityGroup)
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
"EC2SecurityGroups"
                      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 [EC2SecurityGroup]))
-> Either String (Maybe [EC2SecurityGroup])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [EC2SecurityGroup])
-> [Node] -> Either String (Maybe [EC2SecurityGroup])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [EC2SecurityGroup]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"EC2SecurityGroup")
                  )
      Either String (Maybe Text -> CacheSecurityGroup)
-> Either String (Maybe Text) -> Either String CacheSecurityGroup
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
"Description")

instance Prelude.Hashable CacheSecurityGroup

instance Prelude.NFData CacheSecurityGroup