{-# 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.IAM.Types.PolicyGroup
-- 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.IAM.Types.PolicyGroup where

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

-- | Contains information about a group that a managed policy is attached to.
--
-- This data type is used as a response element in the
-- ListEntitiesForPolicy operation.
--
-- For more information about managed policies, refer to
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html Managed policies and inline policies>
-- in the /IAM User Guide/.
--
-- /See:/ 'newPolicyGroup' smart constructor.
data PolicyGroup = PolicyGroup'
  { -- | The stable and unique string identifying the group. For more information
    -- about IDs, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM identifiers>
    -- in the /IAM User Guide/.
    PolicyGroup -> Maybe Text
groupId :: Prelude.Maybe Prelude.Text,
    -- | The name (friendly name, not ARN) identifying the group.
    PolicyGroup -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyGroup -> PolicyGroup -> Bool
(PolicyGroup -> PolicyGroup -> Bool)
-> (PolicyGroup -> PolicyGroup -> Bool) -> Eq PolicyGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyGroup -> PolicyGroup -> Bool
$c/= :: PolicyGroup -> PolicyGroup -> Bool
== :: PolicyGroup -> PolicyGroup -> Bool
$c== :: PolicyGroup -> PolicyGroup -> Bool
Prelude.Eq, ReadPrec [PolicyGroup]
ReadPrec PolicyGroup
Int -> ReadS PolicyGroup
ReadS [PolicyGroup]
(Int -> ReadS PolicyGroup)
-> ReadS [PolicyGroup]
-> ReadPrec PolicyGroup
-> ReadPrec [PolicyGroup]
-> Read PolicyGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyGroup]
$creadListPrec :: ReadPrec [PolicyGroup]
readPrec :: ReadPrec PolicyGroup
$creadPrec :: ReadPrec PolicyGroup
readList :: ReadS [PolicyGroup]
$creadList :: ReadS [PolicyGroup]
readsPrec :: Int -> ReadS PolicyGroup
$creadsPrec :: Int -> ReadS PolicyGroup
Prelude.Read, Int -> PolicyGroup -> ShowS
[PolicyGroup] -> ShowS
PolicyGroup -> String
(Int -> PolicyGroup -> ShowS)
-> (PolicyGroup -> String)
-> ([PolicyGroup] -> ShowS)
-> Show PolicyGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyGroup] -> ShowS
$cshowList :: [PolicyGroup] -> ShowS
show :: PolicyGroup -> String
$cshow :: PolicyGroup -> String
showsPrec :: Int -> PolicyGroup -> ShowS
$cshowsPrec :: Int -> PolicyGroup -> ShowS
Prelude.Show, (forall x. PolicyGroup -> Rep PolicyGroup x)
-> (forall x. Rep PolicyGroup x -> PolicyGroup)
-> Generic PolicyGroup
forall x. Rep PolicyGroup x -> PolicyGroup
forall x. PolicyGroup -> Rep PolicyGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyGroup x -> PolicyGroup
$cfrom :: forall x. PolicyGroup -> Rep PolicyGroup x
Prelude.Generic)

-- |
-- Create a value of 'PolicyGroup' 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', 'policyGroup_groupId' - The stable and unique string identifying the group. For more information
-- about IDs, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
--
-- 'groupName', 'policyGroup_groupName' - The name (friendly name, not ARN) identifying the group.
newPolicyGroup ::
  PolicyGroup
newPolicyGroup :: PolicyGroup
newPolicyGroup =
  PolicyGroup' :: Maybe Text -> Maybe Text -> PolicyGroup
PolicyGroup'
    { $sel:groupId:PolicyGroup' :: Maybe Text
groupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:PolicyGroup' :: Maybe Text
groupName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The stable and unique string identifying the group. For more information
-- about IDs, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
policyGroup_groupId :: Lens.Lens' PolicyGroup (Prelude.Maybe Prelude.Text)
policyGroup_groupId :: (Maybe Text -> f (Maybe Text)) -> PolicyGroup -> f PolicyGroup
policyGroup_groupId = (PolicyGroup -> Maybe Text)
-> (PolicyGroup -> Maybe Text -> PolicyGroup)
-> Lens PolicyGroup PolicyGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyGroup' {Maybe Text
groupId :: Maybe Text
$sel:groupId:PolicyGroup' :: PolicyGroup -> Maybe Text
groupId} -> Maybe Text
groupId) (\s :: PolicyGroup
s@PolicyGroup' {} Maybe Text
a -> PolicyGroup
s {$sel:groupId:PolicyGroup' :: Maybe Text
groupId = Maybe Text
a} :: PolicyGroup)

-- | The name (friendly name, not ARN) identifying the group.
policyGroup_groupName :: Lens.Lens' PolicyGroup (Prelude.Maybe Prelude.Text)
policyGroup_groupName :: (Maybe Text -> f (Maybe Text)) -> PolicyGroup -> f PolicyGroup
policyGroup_groupName = (PolicyGroup -> Maybe Text)
-> (PolicyGroup -> Maybe Text -> PolicyGroup)
-> Lens PolicyGroup PolicyGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyGroup' {Maybe Text
groupName :: Maybe Text
$sel:groupName:PolicyGroup' :: PolicyGroup -> Maybe Text
groupName} -> Maybe Text
groupName) (\s :: PolicyGroup
s@PolicyGroup' {} Maybe Text
a -> PolicyGroup
s {$sel:groupName:PolicyGroup' :: Maybe Text
groupName = Maybe Text
a} :: PolicyGroup)

instance Core.FromXML PolicyGroup where
  parseXML :: [Node] -> Either String PolicyGroup
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> PolicyGroup
PolicyGroup'
      (Maybe Text -> Maybe Text -> PolicyGroup)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> PolicyGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"GroupId")
      Either String (Maybe Text -> PolicyGroup)
-> Either String (Maybe Text) -> Either String PolicyGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"GroupName")

instance Prelude.Hashable PolicyGroup

instance Prelude.NFData PolicyGroup