{-# 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.SecurityGroupReference
-- 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.SecurityGroupReference 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 VPC with a security group that references your security
-- group.
--
-- /See:/ 'newSecurityGroupReference' smart constructor.
data SecurityGroupReference = SecurityGroupReference'
  { -- | The ID of your security group.
    SecurityGroupReference -> Maybe Text
groupId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the VPC with the referencing security group.
    SecurityGroupReference -> Maybe Text
referencingVpcId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the VPC peering connection.
    SecurityGroupReference -> Maybe Text
vpcPeeringConnectionId :: Prelude.Maybe Prelude.Text
  }
  deriving (SecurityGroupReference -> SecurityGroupReference -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecurityGroupReference -> SecurityGroupReference -> Bool
$c/= :: SecurityGroupReference -> SecurityGroupReference -> Bool
== :: SecurityGroupReference -> SecurityGroupReference -> Bool
$c== :: SecurityGroupReference -> SecurityGroupReference -> Bool
Prelude.Eq, ReadPrec [SecurityGroupReference]
ReadPrec SecurityGroupReference
Int -> ReadS SecurityGroupReference
ReadS [SecurityGroupReference]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecurityGroupReference]
$creadListPrec :: ReadPrec [SecurityGroupReference]
readPrec :: ReadPrec SecurityGroupReference
$creadPrec :: ReadPrec SecurityGroupReference
readList :: ReadS [SecurityGroupReference]
$creadList :: ReadS [SecurityGroupReference]
readsPrec :: Int -> ReadS SecurityGroupReference
$creadsPrec :: Int -> ReadS SecurityGroupReference
Prelude.Read, Int -> SecurityGroupReference -> ShowS
[SecurityGroupReference] -> ShowS
SecurityGroupReference -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecurityGroupReference] -> ShowS
$cshowList :: [SecurityGroupReference] -> ShowS
show :: SecurityGroupReference -> String
$cshow :: SecurityGroupReference -> String
showsPrec :: Int -> SecurityGroupReference -> ShowS
$cshowsPrec :: Int -> SecurityGroupReference -> ShowS
Prelude.Show, forall x. Rep SecurityGroupReference x -> SecurityGroupReference
forall x. SecurityGroupReference -> Rep SecurityGroupReference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SecurityGroupReference x -> SecurityGroupReference
$cfrom :: forall x. SecurityGroupReference -> Rep SecurityGroupReference x
Prelude.Generic)

-- |
-- Create a value of 'SecurityGroupReference' 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', 'securityGroupReference_groupId' - The ID of your security group.
--
-- 'referencingVpcId', 'securityGroupReference_referencingVpcId' - The ID of the VPC with the referencing security group.
--
-- 'vpcPeeringConnectionId', 'securityGroupReference_vpcPeeringConnectionId' - The ID of the VPC peering connection.
newSecurityGroupReference ::
  SecurityGroupReference
newSecurityGroupReference :: SecurityGroupReference
newSecurityGroupReference =
  SecurityGroupReference'
    { $sel:groupId:SecurityGroupReference' :: Maybe Text
groupId = forall a. Maybe a
Prelude.Nothing,
      $sel:referencingVpcId:SecurityGroupReference' :: Maybe Text
referencingVpcId = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcPeeringConnectionId:SecurityGroupReference' :: Maybe Text
vpcPeeringConnectionId = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The ID of the VPC with the referencing security group.
securityGroupReference_referencingVpcId :: Lens.Lens' SecurityGroupReference (Prelude.Maybe Prelude.Text)
securityGroupReference_referencingVpcId :: Lens' SecurityGroupReference (Maybe Text)
securityGroupReference_referencingVpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupReference' {Maybe Text
referencingVpcId :: Maybe Text
$sel:referencingVpcId:SecurityGroupReference' :: SecurityGroupReference -> Maybe Text
referencingVpcId} -> Maybe Text
referencingVpcId) (\s :: SecurityGroupReference
s@SecurityGroupReference' {} Maybe Text
a -> SecurityGroupReference
s {$sel:referencingVpcId:SecurityGroupReference' :: Maybe Text
referencingVpcId = Maybe Text
a} :: SecurityGroupReference)

-- | The ID of the VPC peering connection.
securityGroupReference_vpcPeeringConnectionId :: Lens.Lens' SecurityGroupReference (Prelude.Maybe Prelude.Text)
securityGroupReference_vpcPeeringConnectionId :: Lens' SecurityGroupReference (Maybe Text)
securityGroupReference_vpcPeeringConnectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupReference' {Maybe Text
vpcPeeringConnectionId :: Maybe Text
$sel:vpcPeeringConnectionId:SecurityGroupReference' :: SecurityGroupReference -> Maybe Text
vpcPeeringConnectionId} -> Maybe Text
vpcPeeringConnectionId) (\s :: SecurityGroupReference
s@SecurityGroupReference' {} Maybe Text
a -> SecurityGroupReference
s {$sel:vpcPeeringConnectionId:SecurityGroupReference' :: Maybe Text
vpcPeeringConnectionId = Maybe Text
a} :: SecurityGroupReference)

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

instance Prelude.Hashable SecurityGroupReference where
  hashWithSalt :: Int -> SecurityGroupReference -> Int
hashWithSalt Int
_salt SecurityGroupReference' {Maybe Text
vpcPeeringConnectionId :: Maybe Text
referencingVpcId :: Maybe Text
groupId :: Maybe Text
$sel:vpcPeeringConnectionId:SecurityGroupReference' :: SecurityGroupReference -> Maybe Text
$sel:referencingVpcId:SecurityGroupReference' :: SecurityGroupReference -> Maybe Text
$sel:groupId:SecurityGroupReference' :: SecurityGroupReference -> 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
referencingVpcId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcPeeringConnectionId

instance Prelude.NFData SecurityGroupReference where
  rnf :: SecurityGroupReference -> ()
rnf SecurityGroupReference' {Maybe Text
vpcPeeringConnectionId :: Maybe Text
referencingVpcId :: Maybe Text
groupId :: Maybe Text
$sel:vpcPeeringConnectionId:SecurityGroupReference' :: SecurityGroupReference -> Maybe Text
$sel:referencingVpcId:SecurityGroupReference' :: SecurityGroupReference -> Maybe Text
$sel:groupId:SecurityGroupReference' :: SecurityGroupReference -> 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
referencingVpcId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcPeeringConnectionId