{-# 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.Inspector.Types.SecurityGroup
-- 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.Inspector.Types.SecurityGroup 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

-- | Contains information about a security group associated with a network
-- interface. This data type is used as one of the elements of the
-- NetworkInterface data type.
--
-- /See:/ 'newSecurityGroup' smart constructor.
data SecurityGroup = SecurityGroup'
  { -- | The ID of the security group.
    SecurityGroup -> Maybe Text
groupId :: Prelude.Maybe Prelude.Text,
    -- | The name of the security group.
    SecurityGroup -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text
  }
  deriving (SecurityGroup -> SecurityGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecurityGroup -> SecurityGroup -> Bool
$c/= :: SecurityGroup -> SecurityGroup -> Bool
== :: SecurityGroup -> SecurityGroup -> Bool
$c== :: SecurityGroup -> SecurityGroup -> Bool
Prelude.Eq, ReadPrec [SecurityGroup]
ReadPrec SecurityGroup
Int -> ReadS SecurityGroup
ReadS [SecurityGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecurityGroup]
$creadListPrec :: ReadPrec [SecurityGroup]
readPrec :: ReadPrec SecurityGroup
$creadPrec :: ReadPrec SecurityGroup
readList :: ReadS [SecurityGroup]
$creadList :: ReadS [SecurityGroup]
readsPrec :: Int -> ReadS SecurityGroup
$creadsPrec :: Int -> ReadS SecurityGroup
Prelude.Read, Int -> SecurityGroup -> ShowS
[SecurityGroup] -> ShowS
SecurityGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecurityGroup] -> ShowS
$cshowList :: [SecurityGroup] -> ShowS
show :: SecurityGroup -> String
$cshow :: SecurityGroup -> String
showsPrec :: Int -> SecurityGroup -> ShowS
$cshowsPrec :: Int -> SecurityGroup -> ShowS
Prelude.Show, forall x. Rep SecurityGroup x -> SecurityGroup
forall x. SecurityGroup -> Rep SecurityGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SecurityGroup x -> SecurityGroup
$cfrom :: forall x. SecurityGroup -> Rep SecurityGroup x
Prelude.Generic)

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

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

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

instance Data.FromJSON SecurityGroup where
  parseJSON :: Value -> Parser SecurityGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SecurityGroup"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SecurityGroup
SecurityGroup'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"groupId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"groupName")
      )

instance Prelude.Hashable SecurityGroup where
  hashWithSalt :: Int -> SecurityGroup -> Int
hashWithSalt Int
_salt SecurityGroup' {Maybe Text
groupName :: Maybe Text
groupId :: Maybe Text
$sel:groupName:SecurityGroup' :: SecurityGroup -> Maybe Text
$sel:groupId:SecurityGroup' :: SecurityGroup -> 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 SecurityGroup where
  rnf :: SecurityGroup -> ()
rnf SecurityGroup' {Maybe Text
groupName :: Maybe Text
groupId :: Maybe Text
$sel:groupName:SecurityGroup' :: SecurityGroup -> Maybe Text
$sel:groupId:SecurityGroup' :: SecurityGroup -> 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