{-# 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.Redshift.Types.ClusterSecurityGroup
-- 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.Redshift.Types.ClusterSecurityGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Internal
import Amazonka.Redshift.Types.EC2SecurityGroup
import Amazonka.Redshift.Types.IPRange
import Amazonka.Redshift.Types.Tag

-- | Describes a security group.
--
-- /See:/ 'newClusterSecurityGroup' smart constructor.
data ClusterSecurityGroup = ClusterSecurityGroup'
  { -- | The name of the cluster security group to which the operation was
    -- applied.
    ClusterSecurityGroup -> Maybe Text
clusterSecurityGroupName :: Prelude.Maybe Prelude.Text,
    -- | A list of IP ranges (CIDR blocks) that are permitted to access clusters
    -- associated with this cluster security group.
    ClusterSecurityGroup -> Maybe [IPRange]
iPRanges :: Prelude.Maybe [IPRange],
    -- | A list of EC2 security groups that are permitted to access clusters
    -- associated with this cluster security group.
    ClusterSecurityGroup -> Maybe [EC2SecurityGroup]
eC2SecurityGroups :: Prelude.Maybe [EC2SecurityGroup],
    -- | A description of the security group.
    ClusterSecurityGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The list of tags for the cluster security group.
    ClusterSecurityGroup -> Maybe [Tag]
tags :: Prelude.Maybe [Tag]
  }
  deriving (ClusterSecurityGroup -> ClusterSecurityGroup -> Bool
(ClusterSecurityGroup -> ClusterSecurityGroup -> Bool)
-> (ClusterSecurityGroup -> ClusterSecurityGroup -> Bool)
-> Eq ClusterSecurityGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClusterSecurityGroup -> ClusterSecurityGroup -> Bool
$c/= :: ClusterSecurityGroup -> ClusterSecurityGroup -> Bool
== :: ClusterSecurityGroup -> ClusterSecurityGroup -> Bool
$c== :: ClusterSecurityGroup -> ClusterSecurityGroup -> Bool
Prelude.Eq, ReadPrec [ClusterSecurityGroup]
ReadPrec ClusterSecurityGroup
Int -> ReadS ClusterSecurityGroup
ReadS [ClusterSecurityGroup]
(Int -> ReadS ClusterSecurityGroup)
-> ReadS [ClusterSecurityGroup]
-> ReadPrec ClusterSecurityGroup
-> ReadPrec [ClusterSecurityGroup]
-> Read ClusterSecurityGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClusterSecurityGroup]
$creadListPrec :: ReadPrec [ClusterSecurityGroup]
readPrec :: ReadPrec ClusterSecurityGroup
$creadPrec :: ReadPrec ClusterSecurityGroup
readList :: ReadS [ClusterSecurityGroup]
$creadList :: ReadS [ClusterSecurityGroup]
readsPrec :: Int -> ReadS ClusterSecurityGroup
$creadsPrec :: Int -> ReadS ClusterSecurityGroup
Prelude.Read, Int -> ClusterSecurityGroup -> ShowS
[ClusterSecurityGroup] -> ShowS
ClusterSecurityGroup -> String
(Int -> ClusterSecurityGroup -> ShowS)
-> (ClusterSecurityGroup -> String)
-> ([ClusterSecurityGroup] -> ShowS)
-> Show ClusterSecurityGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClusterSecurityGroup] -> ShowS
$cshowList :: [ClusterSecurityGroup] -> ShowS
show :: ClusterSecurityGroup -> String
$cshow :: ClusterSecurityGroup -> String
showsPrec :: Int -> ClusterSecurityGroup -> ShowS
$cshowsPrec :: Int -> ClusterSecurityGroup -> ShowS
Prelude.Show, (forall x. ClusterSecurityGroup -> Rep ClusterSecurityGroup x)
-> (forall x. Rep ClusterSecurityGroup x -> ClusterSecurityGroup)
-> Generic ClusterSecurityGroup
forall x. Rep ClusterSecurityGroup x -> ClusterSecurityGroup
forall x. ClusterSecurityGroup -> Rep ClusterSecurityGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClusterSecurityGroup x -> ClusterSecurityGroup
$cfrom :: forall x. ClusterSecurityGroup -> Rep ClusterSecurityGroup x
Prelude.Generic)

-- |
-- Create a value of 'ClusterSecurityGroup' 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:
--
-- 'clusterSecurityGroupName', 'clusterSecurityGroup_clusterSecurityGroupName' - The name of the cluster security group to which the operation was
-- applied.
--
-- 'iPRanges', 'clusterSecurityGroup_iPRanges' - A list of IP ranges (CIDR blocks) that are permitted to access clusters
-- associated with this cluster security group.
--
-- 'eC2SecurityGroups', 'clusterSecurityGroup_eC2SecurityGroups' - A list of EC2 security groups that are permitted to access clusters
-- associated with this cluster security group.
--
-- 'description', 'clusterSecurityGroup_description' - A description of the security group.
--
-- 'tags', 'clusterSecurityGroup_tags' - The list of tags for the cluster security group.
newClusterSecurityGroup ::
  ClusterSecurityGroup
newClusterSecurityGroup :: ClusterSecurityGroup
newClusterSecurityGroup =
  ClusterSecurityGroup' :: Maybe Text
-> Maybe [IPRange]
-> Maybe [EC2SecurityGroup]
-> Maybe Text
-> Maybe [Tag]
-> ClusterSecurityGroup
ClusterSecurityGroup'
    { $sel:clusterSecurityGroupName:ClusterSecurityGroup' :: Maybe Text
clusterSecurityGroupName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iPRanges:ClusterSecurityGroup' :: Maybe [IPRange]
iPRanges = Maybe [IPRange]
forall a. Maybe a
Prelude.Nothing,
      $sel:eC2SecurityGroups:ClusterSecurityGroup' :: Maybe [EC2SecurityGroup]
eC2SecurityGroups = Maybe [EC2SecurityGroup]
forall a. Maybe a
Prelude.Nothing,
      $sel:description:ClusterSecurityGroup' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ClusterSecurityGroup' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the cluster security group to which the operation was
-- applied.
clusterSecurityGroup_clusterSecurityGroupName :: Lens.Lens' ClusterSecurityGroup (Prelude.Maybe Prelude.Text)
clusterSecurityGroup_clusterSecurityGroupName :: (Maybe Text -> f (Maybe Text))
-> ClusterSecurityGroup -> f ClusterSecurityGroup
clusterSecurityGroup_clusterSecurityGroupName = (ClusterSecurityGroup -> Maybe Text)
-> (ClusterSecurityGroup -> Maybe Text -> ClusterSecurityGroup)
-> Lens
     ClusterSecurityGroup ClusterSecurityGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterSecurityGroup' {Maybe Text
clusterSecurityGroupName :: Maybe Text
$sel:clusterSecurityGroupName:ClusterSecurityGroup' :: ClusterSecurityGroup -> Maybe Text
clusterSecurityGroupName} -> Maybe Text
clusterSecurityGroupName) (\s :: ClusterSecurityGroup
s@ClusterSecurityGroup' {} Maybe Text
a -> ClusterSecurityGroup
s {$sel:clusterSecurityGroupName:ClusterSecurityGroup' :: Maybe Text
clusterSecurityGroupName = Maybe Text
a} :: ClusterSecurityGroup)

-- | A list of IP ranges (CIDR blocks) that are permitted to access clusters
-- associated with this cluster security group.
clusterSecurityGroup_iPRanges :: Lens.Lens' ClusterSecurityGroup (Prelude.Maybe [IPRange])
clusterSecurityGroup_iPRanges :: (Maybe [IPRange] -> f (Maybe [IPRange]))
-> ClusterSecurityGroup -> f ClusterSecurityGroup
clusterSecurityGroup_iPRanges = (ClusterSecurityGroup -> Maybe [IPRange])
-> (ClusterSecurityGroup
    -> Maybe [IPRange] -> ClusterSecurityGroup)
-> Lens
     ClusterSecurityGroup
     ClusterSecurityGroup
     (Maybe [IPRange])
     (Maybe [IPRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterSecurityGroup' {Maybe [IPRange]
iPRanges :: Maybe [IPRange]
$sel:iPRanges:ClusterSecurityGroup' :: ClusterSecurityGroup -> Maybe [IPRange]
iPRanges} -> Maybe [IPRange]
iPRanges) (\s :: ClusterSecurityGroup
s@ClusterSecurityGroup' {} Maybe [IPRange]
a -> ClusterSecurityGroup
s {$sel:iPRanges:ClusterSecurityGroup' :: Maybe [IPRange]
iPRanges = Maybe [IPRange]
a} :: ClusterSecurityGroup) ((Maybe [IPRange] -> f (Maybe [IPRange]))
 -> ClusterSecurityGroup -> f ClusterSecurityGroup)
-> ((Maybe [IPRange] -> f (Maybe [IPRange]))
    -> Maybe [IPRange] -> f (Maybe [IPRange]))
-> (Maybe [IPRange] -> f (Maybe [IPRange]))
-> ClusterSecurityGroup
-> f ClusterSecurityGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [IPRange] [IPRange] [IPRange] [IPRange]
-> Iso
     (Maybe [IPRange])
     (Maybe [IPRange])
     (Maybe [IPRange])
     (Maybe [IPRange])
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 [IPRange] [IPRange] [IPRange] [IPRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of EC2 security groups that are permitted to access clusters
-- associated with this cluster security group.
clusterSecurityGroup_eC2SecurityGroups :: Lens.Lens' ClusterSecurityGroup (Prelude.Maybe [EC2SecurityGroup])
clusterSecurityGroup_eC2SecurityGroups :: (Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
-> ClusterSecurityGroup -> f ClusterSecurityGroup
clusterSecurityGroup_eC2SecurityGroups = (ClusterSecurityGroup -> Maybe [EC2SecurityGroup])
-> (ClusterSecurityGroup
    -> Maybe [EC2SecurityGroup] -> ClusterSecurityGroup)
-> Lens
     ClusterSecurityGroup
     ClusterSecurityGroup
     (Maybe [EC2SecurityGroup])
     (Maybe [EC2SecurityGroup])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterSecurityGroup' {Maybe [EC2SecurityGroup]
eC2SecurityGroups :: Maybe [EC2SecurityGroup]
$sel:eC2SecurityGroups:ClusterSecurityGroup' :: ClusterSecurityGroup -> Maybe [EC2SecurityGroup]
eC2SecurityGroups} -> Maybe [EC2SecurityGroup]
eC2SecurityGroups) (\s :: ClusterSecurityGroup
s@ClusterSecurityGroup' {} Maybe [EC2SecurityGroup]
a -> ClusterSecurityGroup
s {$sel:eC2SecurityGroups:ClusterSecurityGroup' :: Maybe [EC2SecurityGroup]
eC2SecurityGroups = Maybe [EC2SecurityGroup]
a} :: ClusterSecurityGroup) ((Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
 -> ClusterSecurityGroup -> f ClusterSecurityGroup)
-> ((Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
    -> Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
-> (Maybe [EC2SecurityGroup] -> f (Maybe [EC2SecurityGroup]))
-> ClusterSecurityGroup
-> f ClusterSecurityGroup
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

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

-- | The list of tags for the cluster security group.
clusterSecurityGroup_tags :: Lens.Lens' ClusterSecurityGroup (Prelude.Maybe [Tag])
clusterSecurityGroup_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> ClusterSecurityGroup -> f ClusterSecurityGroup
clusterSecurityGroup_tags = (ClusterSecurityGroup -> Maybe [Tag])
-> (ClusterSecurityGroup -> Maybe [Tag] -> ClusterSecurityGroup)
-> Lens
     ClusterSecurityGroup
     ClusterSecurityGroup
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterSecurityGroup' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:ClusterSecurityGroup' :: ClusterSecurityGroup -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: ClusterSecurityGroup
s@ClusterSecurityGroup' {} Maybe [Tag]
a -> ClusterSecurityGroup
s {$sel:tags:ClusterSecurityGroup' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: ClusterSecurityGroup) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> ClusterSecurityGroup -> f ClusterSecurityGroup)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> ClusterSecurityGroup
-> f ClusterSecurityGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML ClusterSecurityGroup where
  parseXML :: [Node] -> Either String ClusterSecurityGroup
parseXML [Node]
x =
    Maybe Text
-> Maybe [IPRange]
-> Maybe [EC2SecurityGroup]
-> Maybe Text
-> Maybe [Tag]
-> ClusterSecurityGroup
ClusterSecurityGroup'
      (Maybe Text
 -> Maybe [IPRange]
 -> Maybe [EC2SecurityGroup]
 -> Maybe Text
 -> Maybe [Tag]
 -> ClusterSecurityGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [IPRange]
      -> Maybe [EC2SecurityGroup]
      -> Maybe Text
      -> Maybe [Tag]
      -> ClusterSecurityGroup)
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
"ClusterSecurityGroupName")
      Either
  String
  (Maybe [IPRange]
   -> Maybe [EC2SecurityGroup]
   -> Maybe Text
   -> Maybe [Tag]
   -> ClusterSecurityGroup)
-> Either String (Maybe [IPRange])
-> Either
     String
     (Maybe [EC2SecurityGroup]
      -> Maybe Text -> Maybe [Tag] -> ClusterSecurityGroup)
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
"IPRanges" 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 [IPRange]))
-> Either String (Maybe [IPRange])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [IPRange])
-> [Node] -> Either String (Maybe [IPRange])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [IPRange]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"IPRange")
                  )
      Either
  String
  (Maybe [EC2SecurityGroup]
   -> Maybe Text -> Maybe [Tag] -> ClusterSecurityGroup)
-> Either String (Maybe [EC2SecurityGroup])
-> Either
     String (Maybe Text -> Maybe [Tag] -> ClusterSecurityGroup)
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 -> Maybe [Tag] -> ClusterSecurityGroup)
-> Either String (Maybe Text)
-> Either String (Maybe [Tag] -> ClusterSecurityGroup)
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")
      Either String (Maybe [Tag] -> ClusterSecurityGroup)
-> Either String (Maybe [Tag])
-> Either String ClusterSecurityGroup
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
"Tags" 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 [Tag]))
-> Either String (Maybe [Tag])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Tag])
-> [Node] -> Either String (Maybe [Tag])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Tag]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Tag")
                  )

instance Prelude.Hashable ClusterSecurityGroup

instance Prelude.NFData ClusterSecurityGroup