{-# 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.RDS.Types.DBSecurityGroup
-- 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.RDS.Types.DBSecurityGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDS.Types.EC2SecurityGroup
import Amazonka.RDS.Types.IPRange

-- | Contains the details for an Amazon RDS DB security group.
--
-- This data type is used as a response element in the
-- @DescribeDBSecurityGroups@ action.
--
-- /See:/ 'newDBSecurityGroup' smart constructor.
data DBSecurityGroup = DBSecurityGroup'
  { -- | The Amazon Resource Name (ARN) for the DB security group.
    DBSecurityGroup -> Maybe Text
dbSecurityGroupArn :: Prelude.Maybe Prelude.Text,
    -- | Provides the description of the DB security group.
    DBSecurityGroup -> Maybe Text
dbSecurityGroupDescription :: Prelude.Maybe Prelude.Text,
    -- | Specifies the name of the DB security group.
    DBSecurityGroup -> Maybe Text
dbSecurityGroupName :: Prelude.Maybe Prelude.Text,
    -- | Contains a list of @EC2SecurityGroup@ elements.
    DBSecurityGroup -> Maybe [EC2SecurityGroup]
eC2SecurityGroups :: Prelude.Maybe [EC2SecurityGroup],
    -- | Contains a list of @IPRange@ elements.
    DBSecurityGroup -> Maybe [IPRange]
iPRanges :: Prelude.Maybe [IPRange],
    -- | Provides the Amazon Web Services ID of the owner of a specific DB
    -- security group.
    DBSecurityGroup -> Maybe Text
ownerId :: Prelude.Maybe Prelude.Text,
    -- | Provides the VpcId of the DB security group.
    DBSecurityGroup -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text
  }
  deriving (DBSecurityGroup -> DBSecurityGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBSecurityGroup -> DBSecurityGroup -> Bool
$c/= :: DBSecurityGroup -> DBSecurityGroup -> Bool
== :: DBSecurityGroup -> DBSecurityGroup -> Bool
$c== :: DBSecurityGroup -> DBSecurityGroup -> Bool
Prelude.Eq, ReadPrec [DBSecurityGroup]
ReadPrec DBSecurityGroup
Int -> ReadS DBSecurityGroup
ReadS [DBSecurityGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DBSecurityGroup]
$creadListPrec :: ReadPrec [DBSecurityGroup]
readPrec :: ReadPrec DBSecurityGroup
$creadPrec :: ReadPrec DBSecurityGroup
readList :: ReadS [DBSecurityGroup]
$creadList :: ReadS [DBSecurityGroup]
readsPrec :: Int -> ReadS DBSecurityGroup
$creadsPrec :: Int -> ReadS DBSecurityGroup
Prelude.Read, Int -> DBSecurityGroup -> ShowS
[DBSecurityGroup] -> ShowS
DBSecurityGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DBSecurityGroup] -> ShowS
$cshowList :: [DBSecurityGroup] -> ShowS
show :: DBSecurityGroup -> String
$cshow :: DBSecurityGroup -> String
showsPrec :: Int -> DBSecurityGroup -> ShowS
$cshowsPrec :: Int -> DBSecurityGroup -> ShowS
Prelude.Show, forall x. Rep DBSecurityGroup x -> DBSecurityGroup
forall x. DBSecurityGroup -> Rep DBSecurityGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DBSecurityGroup x -> DBSecurityGroup
$cfrom :: forall x. DBSecurityGroup -> Rep DBSecurityGroup x
Prelude.Generic)

-- |
-- Create a value of 'DBSecurityGroup' 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:
--
-- 'dbSecurityGroupArn', 'dbSecurityGroup_dbSecurityGroupArn' - The Amazon Resource Name (ARN) for the DB security group.
--
-- 'dbSecurityGroupDescription', 'dbSecurityGroup_dbSecurityGroupDescription' - Provides the description of the DB security group.
--
-- 'dbSecurityGroupName', 'dbSecurityGroup_dbSecurityGroupName' - Specifies the name of the DB security group.
--
-- 'eC2SecurityGroups', 'dbSecurityGroup_eC2SecurityGroups' - Contains a list of @EC2SecurityGroup@ elements.
--
-- 'iPRanges', 'dbSecurityGroup_iPRanges' - Contains a list of @IPRange@ elements.
--
-- 'ownerId', 'dbSecurityGroup_ownerId' - Provides the Amazon Web Services ID of the owner of a specific DB
-- security group.
--
-- 'vpcId', 'dbSecurityGroup_vpcId' - Provides the VpcId of the DB security group.
newDBSecurityGroup ::
  DBSecurityGroup
newDBSecurityGroup :: DBSecurityGroup
newDBSecurityGroup =
  DBSecurityGroup'
    { $sel:dbSecurityGroupArn:DBSecurityGroup' :: Maybe Text
dbSecurityGroupArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dbSecurityGroupDescription:DBSecurityGroup' :: Maybe Text
dbSecurityGroupDescription = forall a. Maybe a
Prelude.Nothing,
      $sel:dbSecurityGroupName:DBSecurityGroup' :: Maybe Text
dbSecurityGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:eC2SecurityGroups:DBSecurityGroup' :: Maybe [EC2SecurityGroup]
eC2SecurityGroups = forall a. Maybe a
Prelude.Nothing,
      $sel:iPRanges:DBSecurityGroup' :: Maybe [IPRange]
iPRanges = forall a. Maybe a
Prelude.Nothing,
      $sel:ownerId:DBSecurityGroup' :: Maybe Text
ownerId = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:DBSecurityGroup' :: Maybe Text
vpcId = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) for the DB security group.
dbSecurityGroup_dbSecurityGroupArn :: Lens.Lens' DBSecurityGroup (Prelude.Maybe Prelude.Text)
dbSecurityGroup_dbSecurityGroupArn :: Lens' DBSecurityGroup (Maybe Text)
dbSecurityGroup_dbSecurityGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSecurityGroup' {Maybe Text
dbSecurityGroupArn :: Maybe Text
$sel:dbSecurityGroupArn:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
dbSecurityGroupArn} -> Maybe Text
dbSecurityGroupArn) (\s :: DBSecurityGroup
s@DBSecurityGroup' {} Maybe Text
a -> DBSecurityGroup
s {$sel:dbSecurityGroupArn:DBSecurityGroup' :: Maybe Text
dbSecurityGroupArn = Maybe Text
a} :: DBSecurityGroup)

-- | Provides the description of the DB security group.
dbSecurityGroup_dbSecurityGroupDescription :: Lens.Lens' DBSecurityGroup (Prelude.Maybe Prelude.Text)
dbSecurityGroup_dbSecurityGroupDescription :: Lens' DBSecurityGroup (Maybe Text)
dbSecurityGroup_dbSecurityGroupDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSecurityGroup' {Maybe Text
dbSecurityGroupDescription :: Maybe Text
$sel:dbSecurityGroupDescription:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
dbSecurityGroupDescription} -> Maybe Text
dbSecurityGroupDescription) (\s :: DBSecurityGroup
s@DBSecurityGroup' {} Maybe Text
a -> DBSecurityGroup
s {$sel:dbSecurityGroupDescription:DBSecurityGroup' :: Maybe Text
dbSecurityGroupDescription = Maybe Text
a} :: DBSecurityGroup)

-- | Specifies the name of the DB security group.
dbSecurityGroup_dbSecurityGroupName :: Lens.Lens' DBSecurityGroup (Prelude.Maybe Prelude.Text)
dbSecurityGroup_dbSecurityGroupName :: Lens' DBSecurityGroup (Maybe Text)
dbSecurityGroup_dbSecurityGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSecurityGroup' {Maybe Text
dbSecurityGroupName :: Maybe Text
$sel:dbSecurityGroupName:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
dbSecurityGroupName} -> Maybe Text
dbSecurityGroupName) (\s :: DBSecurityGroup
s@DBSecurityGroup' {} Maybe Text
a -> DBSecurityGroup
s {$sel:dbSecurityGroupName:DBSecurityGroup' :: Maybe Text
dbSecurityGroupName = Maybe Text
a} :: DBSecurityGroup)

-- | Contains a list of @EC2SecurityGroup@ elements.
dbSecurityGroup_eC2SecurityGroups :: Lens.Lens' DBSecurityGroup (Prelude.Maybe [EC2SecurityGroup])
dbSecurityGroup_eC2SecurityGroups :: Lens' DBSecurityGroup (Maybe [EC2SecurityGroup])
dbSecurityGroup_eC2SecurityGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSecurityGroup' {Maybe [EC2SecurityGroup]
eC2SecurityGroups :: Maybe [EC2SecurityGroup]
$sel:eC2SecurityGroups:DBSecurityGroup' :: DBSecurityGroup -> Maybe [EC2SecurityGroup]
eC2SecurityGroups} -> Maybe [EC2SecurityGroup]
eC2SecurityGroups) (\s :: DBSecurityGroup
s@DBSecurityGroup' {} Maybe [EC2SecurityGroup]
a -> DBSecurityGroup
s {$sel:eC2SecurityGroups:DBSecurityGroup' :: Maybe [EC2SecurityGroup]
eC2SecurityGroups = Maybe [EC2SecurityGroup]
a} :: DBSecurityGroup) 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

-- | Contains a list of @IPRange@ elements.
dbSecurityGroup_iPRanges :: Lens.Lens' DBSecurityGroup (Prelude.Maybe [IPRange])
dbSecurityGroup_iPRanges :: Lens' DBSecurityGroup (Maybe [IPRange])
dbSecurityGroup_iPRanges = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSecurityGroup' {Maybe [IPRange]
iPRanges :: Maybe [IPRange]
$sel:iPRanges:DBSecurityGroup' :: DBSecurityGroup -> Maybe [IPRange]
iPRanges} -> Maybe [IPRange]
iPRanges) (\s :: DBSecurityGroup
s@DBSecurityGroup' {} Maybe [IPRange]
a -> DBSecurityGroup
s {$sel:iPRanges:DBSecurityGroup' :: Maybe [IPRange]
iPRanges = Maybe [IPRange]
a} :: DBSecurityGroup) 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

-- | Provides the Amazon Web Services ID of the owner of a specific DB
-- security group.
dbSecurityGroup_ownerId :: Lens.Lens' DBSecurityGroup (Prelude.Maybe Prelude.Text)
dbSecurityGroup_ownerId :: Lens' DBSecurityGroup (Maybe Text)
dbSecurityGroup_ownerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSecurityGroup' {Maybe Text
ownerId :: Maybe Text
$sel:ownerId:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
ownerId} -> Maybe Text
ownerId) (\s :: DBSecurityGroup
s@DBSecurityGroup' {} Maybe Text
a -> DBSecurityGroup
s {$sel:ownerId:DBSecurityGroup' :: Maybe Text
ownerId = Maybe Text
a} :: DBSecurityGroup)

-- | Provides the VpcId of the DB security group.
dbSecurityGroup_vpcId :: Lens.Lens' DBSecurityGroup (Prelude.Maybe Prelude.Text)
dbSecurityGroup_vpcId :: Lens' DBSecurityGroup (Maybe Text)
dbSecurityGroup_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBSecurityGroup' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: DBSecurityGroup
s@DBSecurityGroup' {} Maybe Text
a -> DBSecurityGroup
s {$sel:vpcId:DBSecurityGroup' :: Maybe Text
vpcId = Maybe Text
a} :: DBSecurityGroup)

instance Data.FromXML DBSecurityGroup where
  parseXML :: [Node] -> Either String DBSecurityGroup
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [EC2SecurityGroup]
-> Maybe [IPRange]
-> Maybe Text
-> Maybe Text
-> DBSecurityGroup
DBSecurityGroup'
      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
"DBSecurityGroupArn")
      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
"DBSecurityGroupDescription")
      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
"DBSecurityGroupName")
      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
"EC2SecurityGroups"
                      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
"EC2SecurityGroup")
                  )
      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
"IPRanges"
                      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
"IPRange")
                  )
      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
"OwnerId")
      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 DBSecurityGroup where
  hashWithSalt :: Int -> DBSecurityGroup -> Int
hashWithSalt Int
_salt DBSecurityGroup' {Maybe [EC2SecurityGroup]
Maybe [IPRange]
Maybe Text
vpcId :: Maybe Text
ownerId :: Maybe Text
iPRanges :: Maybe [IPRange]
eC2SecurityGroups :: Maybe [EC2SecurityGroup]
dbSecurityGroupName :: Maybe Text
dbSecurityGroupDescription :: Maybe Text
dbSecurityGroupArn :: Maybe Text
$sel:vpcId:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
$sel:ownerId:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
$sel:iPRanges:DBSecurityGroup' :: DBSecurityGroup -> Maybe [IPRange]
$sel:eC2SecurityGroups:DBSecurityGroup' :: DBSecurityGroup -> Maybe [EC2SecurityGroup]
$sel:dbSecurityGroupName:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
$sel:dbSecurityGroupDescription:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
$sel:dbSecurityGroupArn:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dbSecurityGroupArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dbSecurityGroupDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dbSecurityGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EC2SecurityGroup]
eC2SecurityGroups
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [IPRange]
iPRanges
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ownerId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId

instance Prelude.NFData DBSecurityGroup where
  rnf :: DBSecurityGroup -> ()
rnf DBSecurityGroup' {Maybe [EC2SecurityGroup]
Maybe [IPRange]
Maybe Text
vpcId :: Maybe Text
ownerId :: Maybe Text
iPRanges :: Maybe [IPRange]
eC2SecurityGroups :: Maybe [EC2SecurityGroup]
dbSecurityGroupName :: Maybe Text
dbSecurityGroupDescription :: Maybe Text
dbSecurityGroupArn :: Maybe Text
$sel:vpcId:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
$sel:ownerId:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
$sel:iPRanges:DBSecurityGroup' :: DBSecurityGroup -> Maybe [IPRange]
$sel:eC2SecurityGroups:DBSecurityGroup' :: DBSecurityGroup -> Maybe [EC2SecurityGroup]
$sel:dbSecurityGroupName:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
$sel:dbSecurityGroupDescription:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
$sel:dbSecurityGroupArn:DBSecurityGroup' :: DBSecurityGroup -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dbSecurityGroupArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dbSecurityGroupDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dbSecurityGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [EC2SecurityGroup]
eC2SecurityGroups
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [IPRange]
iPRanges
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ownerId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcId