{-# 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.SecurityHub.Types.AwsEc2NetworkInterfaceSecurityGroup
-- 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.SecurityHub.Types.AwsEc2NetworkInterfaceSecurityGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

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

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

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

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

instance
  Core.FromJSON
    AwsEc2NetworkInterfaceSecurityGroup
  where
  parseJSON :: Value -> Parser AwsEc2NetworkInterfaceSecurityGroup
parseJSON =
    String
-> (Object -> Parser AwsEc2NetworkInterfaceSecurityGroup)
-> Value
-> Parser AwsEc2NetworkInterfaceSecurityGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEc2NetworkInterfaceSecurityGroup"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AwsEc2NetworkInterfaceSecurityGroup
AwsEc2NetworkInterfaceSecurityGroup'
            (Maybe Text -> Maybe Text -> AwsEc2NetworkInterfaceSecurityGroup)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AwsEc2NetworkInterfaceSecurityGroup)
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 -> AwsEc2NetworkInterfaceSecurityGroup)
-> Parser (Maybe Text)
-> Parser AwsEc2NetworkInterfaceSecurityGroup
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
    AwsEc2NetworkInterfaceSecurityGroup

instance
  Prelude.NFData
    AwsEc2NetworkInterfaceSecurityGroup

instance
  Core.ToJSON
    AwsEc2NetworkInterfaceSecurityGroup
  where
  toJSON :: AwsEc2NetworkInterfaceSecurityGroup -> Value
toJSON AwsEc2NetworkInterfaceSecurityGroup' {Maybe Text
groupName :: Maybe Text
groupId :: Maybe Text
$sel:groupName:AwsEc2NetworkInterfaceSecurityGroup' :: AwsEc2NetworkInterfaceSecurityGroup -> Maybe Text
$sel:groupId:AwsEc2NetworkInterfaceSecurityGroup' :: AwsEc2NetworkInterfaceSecurityGroup -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"GroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
groupId,
            (Text
"GroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
groupName
          ]
      )