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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(SecurityGroup -> SecurityGroup -> Bool)
-> (SecurityGroup -> SecurityGroup -> Bool) -> Eq SecurityGroup
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]
(Int -> ReadS SecurityGroup)
-> ReadS [SecurityGroup]
-> ReadPrec SecurityGroup
-> ReadPrec [SecurityGroup]
-> Read 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
(Int -> SecurityGroup -> ShowS)
-> (SecurityGroup -> String)
-> ([SecurityGroup] -> ShowS)
-> Show SecurityGroup
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. SecurityGroup -> Rep SecurityGroup x)
-> (forall x. Rep SecurityGroup x -> SecurityGroup)
-> Generic SecurityGroup
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' :: Maybe Text -> Maybe Text -> SecurityGroup
SecurityGroup'
    { $sel:groupId:SecurityGroup' :: Maybe Text
groupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:SecurityGroup' :: Maybe Text
groupName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the security group.
securityGroup_groupId :: Lens.Lens' SecurityGroup (Prelude.Maybe Prelude.Text)
securityGroup_groupId :: (Maybe Text -> f (Maybe Text)) -> SecurityGroup -> f SecurityGroup
securityGroup_groupId = (SecurityGroup -> Maybe Text)
-> (SecurityGroup -> Maybe Text -> SecurityGroup)
-> Lens SecurityGroup SecurityGroup (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> SecurityGroup -> f SecurityGroup
securityGroup_groupName = (SecurityGroup -> Maybe Text)
-> (SecurityGroup -> Maybe Text -> SecurityGroup)
-> Lens SecurityGroup SecurityGroup (Maybe Text) (Maybe Text)
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 Core.FromJSON SecurityGroup where
  parseJSON :: Value -> Parser SecurityGroup
parseJSON =
    String
-> (Object -> Parser SecurityGroup)
-> Value
-> Parser SecurityGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SecurityGroup"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SecurityGroup
SecurityGroup'
            (Maybe Text -> Maybe Text -> SecurityGroup)
-> Parser (Maybe Text) -> Parser (Maybe Text -> SecurityGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"groupId")
            Parser (Maybe Text -> SecurityGroup)
-> Parser (Maybe Text) -> Parser SecurityGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"groupName")
      )

instance Prelude.Hashable SecurityGroup

instance Prelude.NFData SecurityGroup