{-# 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.UserIdGroupPair
-- 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.UserIdGroupPair 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 and Amazon Web Services account ID pair.
--
-- We are retiring EC2-Classic. We recommend that you migrate from
-- EC2-Classic to a VPC. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/vpc-migrate.html Migrate from EC2-Classic to a VPC>
-- in the /Amazon Elastic Compute Cloud User Guide/.
--
-- /See:/ 'newUserIdGroupPair' smart constructor.
data UserIdGroupPair = UserIdGroupPair'
  { -- | A description for the security group rule that references this user ID
    -- group pair.
    --
    -- Constraints: Up to 255 characters in length. Allowed characters are a-z,
    -- A-Z, 0-9, spaces, and ._-:\/()#,\@[]+=;{}!$*
    UserIdGroupPair -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ID of the security group.
    UserIdGroupPair -> Maybe Text
groupId :: Prelude.Maybe Prelude.Text,
    -- | The name of the security group. In a request, use this parameter for a
    -- security group in EC2-Classic or a default VPC only. For a security
    -- group in a nondefault VPC, use the security group ID.
    --
    -- For a referenced security group in another VPC, this value is not
    -- returned if the referenced security group is deleted.
    UserIdGroupPair -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text,
    -- | The status of a VPC peering connection, if applicable.
    UserIdGroupPair -> Maybe Text
peeringStatus :: Prelude.Maybe Prelude.Text,
    -- | The ID of an Amazon Web Services account.
    --
    -- For a referenced security group in another VPC, the account ID of the
    -- referenced security group is returned in the response. If the referenced
    -- security group is deleted, this value is not returned.
    --
    -- [EC2-Classic] Required when adding or removing rules that reference a
    -- security group in another Amazon Web Services account.
    UserIdGroupPair -> Maybe Text
userId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the VPC for the referenced security group, if applicable.
    UserIdGroupPair -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the VPC peering connection, if applicable.
    UserIdGroupPair -> Maybe Text
vpcPeeringConnectionId :: Prelude.Maybe Prelude.Text
  }
  deriving (UserIdGroupPair -> UserIdGroupPair -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserIdGroupPair -> UserIdGroupPair -> Bool
$c/= :: UserIdGroupPair -> UserIdGroupPair -> Bool
== :: UserIdGroupPair -> UserIdGroupPair -> Bool
$c== :: UserIdGroupPair -> UserIdGroupPair -> Bool
Prelude.Eq, ReadPrec [UserIdGroupPair]
ReadPrec UserIdGroupPair
Int -> ReadS UserIdGroupPair
ReadS [UserIdGroupPair]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserIdGroupPair]
$creadListPrec :: ReadPrec [UserIdGroupPair]
readPrec :: ReadPrec UserIdGroupPair
$creadPrec :: ReadPrec UserIdGroupPair
readList :: ReadS [UserIdGroupPair]
$creadList :: ReadS [UserIdGroupPair]
readsPrec :: Int -> ReadS UserIdGroupPair
$creadsPrec :: Int -> ReadS UserIdGroupPair
Prelude.Read, Int -> UserIdGroupPair -> ShowS
[UserIdGroupPair] -> ShowS
UserIdGroupPair -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserIdGroupPair] -> ShowS
$cshowList :: [UserIdGroupPair] -> ShowS
show :: UserIdGroupPair -> String
$cshow :: UserIdGroupPair -> String
showsPrec :: Int -> UserIdGroupPair -> ShowS
$cshowsPrec :: Int -> UserIdGroupPair -> ShowS
Prelude.Show, forall x. Rep UserIdGroupPair x -> UserIdGroupPair
forall x. UserIdGroupPair -> Rep UserIdGroupPair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserIdGroupPair x -> UserIdGroupPair
$cfrom :: forall x. UserIdGroupPair -> Rep UserIdGroupPair x
Prelude.Generic)

-- |
-- Create a value of 'UserIdGroupPair' 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:
--
-- 'description', 'userIdGroupPair_description' - A description for the security group rule that references this user ID
-- group pair.
--
-- Constraints: Up to 255 characters in length. Allowed characters are a-z,
-- A-Z, 0-9, spaces, and ._-:\/()#,\@[]+=;{}!$*
--
-- 'groupId', 'userIdGroupPair_groupId' - The ID of the security group.
--
-- 'groupName', 'userIdGroupPair_groupName' - The name of the security group. In a request, use this parameter for a
-- security group in EC2-Classic or a default VPC only. For a security
-- group in a nondefault VPC, use the security group ID.
--
-- For a referenced security group in another VPC, this value is not
-- returned if the referenced security group is deleted.
--
-- 'peeringStatus', 'userIdGroupPair_peeringStatus' - The status of a VPC peering connection, if applicable.
--
-- 'userId', 'userIdGroupPair_userId' - The ID of an Amazon Web Services account.
--
-- For a referenced security group in another VPC, the account ID of the
-- referenced security group is returned in the response. If the referenced
-- security group is deleted, this value is not returned.
--
-- [EC2-Classic] Required when adding or removing rules that reference a
-- security group in another Amazon Web Services account.
--
-- 'vpcId', 'userIdGroupPair_vpcId' - The ID of the VPC for the referenced security group, if applicable.
--
-- 'vpcPeeringConnectionId', 'userIdGroupPair_vpcPeeringConnectionId' - The ID of the VPC peering connection, if applicable.
newUserIdGroupPair ::
  UserIdGroupPair
newUserIdGroupPair :: UserIdGroupPair
newUserIdGroupPair =
  UserIdGroupPair'
    { $sel:description:UserIdGroupPair' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:groupId:UserIdGroupPair' :: Maybe Text
groupId = forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:UserIdGroupPair' :: Maybe Text
groupName = forall a. Maybe a
Prelude.Nothing,
      $sel:peeringStatus:UserIdGroupPair' :: Maybe Text
peeringStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:userId:UserIdGroupPair' :: Maybe Text
userId = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:UserIdGroupPair' :: Maybe Text
vpcId = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcPeeringConnectionId:UserIdGroupPair' :: Maybe Text
vpcPeeringConnectionId = forall a. Maybe a
Prelude.Nothing
    }

-- | A description for the security group rule that references this user ID
-- group pair.
--
-- Constraints: Up to 255 characters in length. Allowed characters are a-z,
-- A-Z, 0-9, spaces, and ._-:\/()#,\@[]+=;{}!$*
userIdGroupPair_description :: Lens.Lens' UserIdGroupPair (Prelude.Maybe Prelude.Text)
userIdGroupPair_description :: Lens' UserIdGroupPair (Maybe Text)
userIdGroupPair_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdGroupPair' {Maybe Text
description :: Maybe Text
$sel:description:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
description} -> Maybe Text
description) (\s :: UserIdGroupPair
s@UserIdGroupPair' {} Maybe Text
a -> UserIdGroupPair
s {$sel:description:UserIdGroupPair' :: Maybe Text
description = Maybe Text
a} :: UserIdGroupPair)

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

-- | The name of the security group. In a request, use this parameter for a
-- security group in EC2-Classic or a default VPC only. For a security
-- group in a nondefault VPC, use the security group ID.
--
-- For a referenced security group in another VPC, this value is not
-- returned if the referenced security group is deleted.
userIdGroupPair_groupName :: Lens.Lens' UserIdGroupPair (Prelude.Maybe Prelude.Text)
userIdGroupPair_groupName :: Lens' UserIdGroupPair (Maybe Text)
userIdGroupPair_groupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdGroupPair' {Maybe Text
groupName :: Maybe Text
$sel:groupName:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
groupName} -> Maybe Text
groupName) (\s :: UserIdGroupPair
s@UserIdGroupPair' {} Maybe Text
a -> UserIdGroupPair
s {$sel:groupName:UserIdGroupPair' :: Maybe Text
groupName = Maybe Text
a} :: UserIdGroupPair)

-- | The status of a VPC peering connection, if applicable.
userIdGroupPair_peeringStatus :: Lens.Lens' UserIdGroupPair (Prelude.Maybe Prelude.Text)
userIdGroupPair_peeringStatus :: Lens' UserIdGroupPair (Maybe Text)
userIdGroupPair_peeringStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdGroupPair' {Maybe Text
peeringStatus :: Maybe Text
$sel:peeringStatus:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
peeringStatus} -> Maybe Text
peeringStatus) (\s :: UserIdGroupPair
s@UserIdGroupPair' {} Maybe Text
a -> UserIdGroupPair
s {$sel:peeringStatus:UserIdGroupPair' :: Maybe Text
peeringStatus = Maybe Text
a} :: UserIdGroupPair)

-- | The ID of an Amazon Web Services account.
--
-- For a referenced security group in another VPC, the account ID of the
-- referenced security group is returned in the response. If the referenced
-- security group is deleted, this value is not returned.
--
-- [EC2-Classic] Required when adding or removing rules that reference a
-- security group in another Amazon Web Services account.
userIdGroupPair_userId :: Lens.Lens' UserIdGroupPair (Prelude.Maybe Prelude.Text)
userIdGroupPair_userId :: Lens' UserIdGroupPair (Maybe Text)
userIdGroupPair_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdGroupPair' {Maybe Text
userId :: Maybe Text
$sel:userId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
userId} -> Maybe Text
userId) (\s :: UserIdGroupPair
s@UserIdGroupPair' {} Maybe Text
a -> UserIdGroupPair
s {$sel:userId:UserIdGroupPair' :: Maybe Text
userId = Maybe Text
a} :: UserIdGroupPair)

-- | The ID of the VPC for the referenced security group, if applicable.
userIdGroupPair_vpcId :: Lens.Lens' UserIdGroupPair (Prelude.Maybe Prelude.Text)
userIdGroupPair_vpcId :: Lens' UserIdGroupPair (Maybe Text)
userIdGroupPair_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdGroupPair' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: UserIdGroupPair
s@UserIdGroupPair' {} Maybe Text
a -> UserIdGroupPair
s {$sel:vpcId:UserIdGroupPair' :: Maybe Text
vpcId = Maybe Text
a} :: UserIdGroupPair)

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

instance Data.FromXML UserIdGroupPair where
  parseXML :: [Node] -> Either String UserIdGroupPair
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> UserIdGroupPair
UserIdGroupPair'
      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
"description")
      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
"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")
      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
"peeringStatus")
      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
"userId")
      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
"vpcId")
      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 UserIdGroupPair where
  hashWithSalt :: Int -> UserIdGroupPair -> Int
hashWithSalt Int
_salt UserIdGroupPair' {Maybe Text
vpcPeeringConnectionId :: Maybe Text
vpcId :: Maybe Text
userId :: Maybe Text
peeringStatus :: Maybe Text
groupName :: Maybe Text
groupId :: Maybe Text
description :: Maybe Text
$sel:vpcPeeringConnectionId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:vpcId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:userId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:peeringStatus:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:groupName:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:groupId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:description:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
peeringStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcPeeringConnectionId

instance Prelude.NFData UserIdGroupPair where
  rnf :: UserIdGroupPair -> ()
rnf UserIdGroupPair' {Maybe Text
vpcPeeringConnectionId :: Maybe Text
vpcId :: Maybe Text
userId :: Maybe Text
peeringStatus :: Maybe Text
groupName :: Maybe Text
groupId :: Maybe Text
description :: Maybe Text
$sel:vpcPeeringConnectionId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:vpcId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:userId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:peeringStatus:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:groupName:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:groupId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:description:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
peeringStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcPeeringConnectionId

instance Data.ToQuery UserIdGroupPair where
  toQuery :: UserIdGroupPair -> QueryString
toQuery UserIdGroupPair' {Maybe Text
vpcPeeringConnectionId :: Maybe Text
vpcId :: Maybe Text
userId :: Maybe Text
peeringStatus :: Maybe Text
groupName :: Maybe Text
groupId :: Maybe Text
description :: Maybe Text
$sel:vpcPeeringConnectionId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:vpcId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:userId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:peeringStatus:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:groupName:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:groupId:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
$sel:description:UserIdGroupPair' :: UserIdGroupPair -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Description" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
description,
        ByteString
"GroupId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
groupId,
        ByteString
"GroupName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
groupName,
        ByteString
"PeeringStatus" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
peeringStatus,
        ByteString
"UserId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
userId,
        ByteString
"VpcId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
vpcId,
        ByteString
"VpcPeeringConnectionId"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
vpcPeeringConnectionId
      ]