{-# 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.EC2.Types.SecurityGroupIdentifier
-- 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.EC2.Types.SecurityGroupIdentifier where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | Describes a security group.
--
-- /See:/ 'newSecurityGroupIdentifier' smart constructor.
data SecurityGroupIdentifier = SecurityGroupIdentifier'
  { -- | The ID of the security group.
    SecurityGroupIdentifier -> Maybe Text
groupId :: Prelude.Maybe Prelude.Text,
    -- | The name of the security group.
    SecurityGroupIdentifier -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text
  }
  deriving (SecurityGroupIdentifier -> SecurityGroupIdentifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecurityGroupIdentifier -> SecurityGroupIdentifier -> Bool
$c/= :: SecurityGroupIdentifier -> SecurityGroupIdentifier -> Bool
== :: SecurityGroupIdentifier -> SecurityGroupIdentifier -> Bool
$c== :: SecurityGroupIdentifier -> SecurityGroupIdentifier -> Bool
Prelude.Eq, ReadPrec [SecurityGroupIdentifier]
ReadPrec SecurityGroupIdentifier
Int -> ReadS SecurityGroupIdentifier
ReadS [SecurityGroupIdentifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecurityGroupIdentifier]
$creadListPrec :: ReadPrec [SecurityGroupIdentifier]
readPrec :: ReadPrec SecurityGroupIdentifier
$creadPrec :: ReadPrec SecurityGroupIdentifier
readList :: ReadS [SecurityGroupIdentifier]
$creadList :: ReadS [SecurityGroupIdentifier]
readsPrec :: Int -> ReadS SecurityGroupIdentifier
$creadsPrec :: Int -> ReadS SecurityGroupIdentifier
Prelude.Read, Int -> SecurityGroupIdentifier -> ShowS
[SecurityGroupIdentifier] -> ShowS
SecurityGroupIdentifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecurityGroupIdentifier] -> ShowS
$cshowList :: [SecurityGroupIdentifier] -> ShowS
show :: SecurityGroupIdentifier -> String
$cshow :: SecurityGroupIdentifier -> String
showsPrec :: Int -> SecurityGroupIdentifier -> ShowS
$cshowsPrec :: Int -> SecurityGroupIdentifier -> ShowS
Prelude.Show, forall x. Rep SecurityGroupIdentifier x -> SecurityGroupIdentifier
forall x. SecurityGroupIdentifier -> Rep SecurityGroupIdentifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SecurityGroupIdentifier x -> SecurityGroupIdentifier
$cfrom :: forall x. SecurityGroupIdentifier -> Rep SecurityGroupIdentifier x
Prelude.Generic)

-- |
-- Create a value of 'SecurityGroupIdentifier' 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:
--
-- 'groupId', 'securityGroupIdentifier_groupId' - The ID of the security group.
--
-- 'groupName', 'securityGroupIdentifier_groupName' - The name of the security group.
newSecurityGroupIdentifier ::
  SecurityGroupIdentifier
newSecurityGroupIdentifier :: SecurityGroupIdentifier
newSecurityGroupIdentifier =
  SecurityGroupIdentifier'
    { $sel:groupId:SecurityGroupIdentifier' :: Maybe Text
groupId = forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:SecurityGroupIdentifier' :: Maybe Text
groupName = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the security group.
securityGroupIdentifier_groupId :: Lens.Lens' SecurityGroupIdentifier (Prelude.Maybe Prelude.Text)
securityGroupIdentifier_groupId :: Lens' SecurityGroupIdentifier (Maybe Text)
securityGroupIdentifier_groupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupIdentifier' {Maybe Text
groupId :: Maybe Text
$sel:groupId:SecurityGroupIdentifier' :: SecurityGroupIdentifier -> Maybe Text
groupId} -> Maybe Text
groupId) (\s :: SecurityGroupIdentifier
s@SecurityGroupIdentifier' {} Maybe Text
a -> SecurityGroupIdentifier
s {$sel:groupId:SecurityGroupIdentifier' :: Maybe Text
groupId = Maybe Text
a} :: SecurityGroupIdentifier)

-- | The name of the security group.
securityGroupIdentifier_groupName :: Lens.Lens' SecurityGroupIdentifier (Prelude.Maybe Prelude.Text)
securityGroupIdentifier_groupName :: Lens' SecurityGroupIdentifier (Maybe Text)
securityGroupIdentifier_groupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupIdentifier' {Maybe Text
groupName :: Maybe Text
$sel:groupName:SecurityGroupIdentifier' :: SecurityGroupIdentifier -> Maybe Text
groupName} -> Maybe Text
groupName) (\s :: SecurityGroupIdentifier
s@SecurityGroupIdentifier' {} Maybe Text
a -> SecurityGroupIdentifier
s {$sel:groupName:SecurityGroupIdentifier' :: Maybe Text
groupName = Maybe Text
a} :: SecurityGroupIdentifier)

instance Data.FromXML SecurityGroupIdentifier where
  parseXML :: [Node] -> Either String SecurityGroupIdentifier
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> SecurityGroupIdentifier
SecurityGroupIdentifier'
      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
"groupId")
      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
"groupName")

instance Prelude.Hashable SecurityGroupIdentifier where
  hashWithSalt :: Int -> SecurityGroupIdentifier -> Int
hashWithSalt Int
_salt SecurityGroupIdentifier' {Maybe Text
groupName :: Maybe Text
groupId :: Maybe Text
$sel:groupName:SecurityGroupIdentifier' :: SecurityGroupIdentifier -> Maybe Text
$sel:groupId:SecurityGroupIdentifier' :: SecurityGroupIdentifier -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupName

instance Prelude.NFData SecurityGroupIdentifier where
  rnf :: SecurityGroupIdentifier -> ()
rnf SecurityGroupIdentifier' {Maybe Text
groupName :: Maybe Text
groupId :: Maybe Text
$sel:groupName:SecurityGroupIdentifier' :: SecurityGroupIdentifier -> Maybe Text
$sel:groupId:SecurityGroupIdentifier' :: SecurityGroupIdentifier -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupName