{-# 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.CognitoIdentityProvider.Types.GroupType
-- 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.CognitoIdentityProvider.Types.GroupType where

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

-- | The group type.
--
-- /See:/ 'newGroupType' smart constructor.
data GroupType = GroupType'
  { -- | The date the group was last modified.
    GroupType -> Maybe POSIX
lastModifiedDate :: Prelude.Maybe Core.POSIX,
    -- | The user pool ID for the user pool.
    GroupType -> Maybe Text
userPoolId :: Prelude.Maybe Prelude.Text,
    -- | The date the group was created.
    GroupType -> Maybe POSIX
creationDate :: Prelude.Maybe Core.POSIX,
    -- | A nonnegative integer value that specifies the precedence of this group
    -- relative to the other groups that a user can belong to in the user pool.
    -- If a user belongs to two or more groups, it is the group with the
    -- highest precedence whose role ARN will be used in the @cognito:roles@
    -- and @cognito:preferred_role@ claims in the user\'s tokens. Groups with
    -- higher @Precedence@ values take precedence over groups with lower
    -- @Precedence@ values or with null @Precedence@ values.
    --
    -- Two groups can have the same @Precedence@ value. If this happens,
    -- neither group takes precedence over the other. If two groups with the
    -- same @Precedence@ have the same role ARN, that role is used in the
    -- @cognito:preferred_role@ claim in tokens for users in each group. If the
    -- two groups have different role ARNs, the @cognito:preferred_role@ claim
    -- is not set in users\' tokens.
    --
    -- The default @Precedence@ value is null.
    GroupType -> Maybe Natural
precedence :: Prelude.Maybe Prelude.Natural,
    -- | The name of the group.
    GroupType -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text,
    -- | A string containing the description of the group.
    GroupType -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The role ARN for the group.
    GroupType -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (GroupType -> GroupType -> Bool
(GroupType -> GroupType -> Bool)
-> (GroupType -> GroupType -> Bool) -> Eq GroupType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupType -> GroupType -> Bool
$c/= :: GroupType -> GroupType -> Bool
== :: GroupType -> GroupType -> Bool
$c== :: GroupType -> GroupType -> Bool
Prelude.Eq, ReadPrec [GroupType]
ReadPrec GroupType
Int -> ReadS GroupType
ReadS [GroupType]
(Int -> ReadS GroupType)
-> ReadS [GroupType]
-> ReadPrec GroupType
-> ReadPrec [GroupType]
-> Read GroupType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupType]
$creadListPrec :: ReadPrec [GroupType]
readPrec :: ReadPrec GroupType
$creadPrec :: ReadPrec GroupType
readList :: ReadS [GroupType]
$creadList :: ReadS [GroupType]
readsPrec :: Int -> ReadS GroupType
$creadsPrec :: Int -> ReadS GroupType
Prelude.Read, Int -> GroupType -> ShowS
[GroupType] -> ShowS
GroupType -> String
(Int -> GroupType -> ShowS)
-> (GroupType -> String)
-> ([GroupType] -> ShowS)
-> Show GroupType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupType] -> ShowS
$cshowList :: [GroupType] -> ShowS
show :: GroupType -> String
$cshow :: GroupType -> String
showsPrec :: Int -> GroupType -> ShowS
$cshowsPrec :: Int -> GroupType -> ShowS
Prelude.Show, (forall x. GroupType -> Rep GroupType x)
-> (forall x. Rep GroupType x -> GroupType) -> Generic GroupType
forall x. Rep GroupType x -> GroupType
forall x. GroupType -> Rep GroupType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GroupType x -> GroupType
$cfrom :: forall x. GroupType -> Rep GroupType x
Prelude.Generic)

-- |
-- Create a value of 'GroupType' 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:
--
-- 'lastModifiedDate', 'groupType_lastModifiedDate' - The date the group was last modified.
--
-- 'userPoolId', 'groupType_userPoolId' - The user pool ID for the user pool.
--
-- 'creationDate', 'groupType_creationDate' - The date the group was created.
--
-- 'precedence', 'groupType_precedence' - A nonnegative integer value that specifies the precedence of this group
-- relative to the other groups that a user can belong to in the user pool.
-- If a user belongs to two or more groups, it is the group with the
-- highest precedence whose role ARN will be used in the @cognito:roles@
-- and @cognito:preferred_role@ claims in the user\'s tokens. Groups with
-- higher @Precedence@ values take precedence over groups with lower
-- @Precedence@ values or with null @Precedence@ values.
--
-- Two groups can have the same @Precedence@ value. If this happens,
-- neither group takes precedence over the other. If two groups with the
-- same @Precedence@ have the same role ARN, that role is used in the
-- @cognito:preferred_role@ claim in tokens for users in each group. If the
-- two groups have different role ARNs, the @cognito:preferred_role@ claim
-- is not set in users\' tokens.
--
-- The default @Precedence@ value is null.
--
-- 'groupName', 'groupType_groupName' - The name of the group.
--
-- 'description', 'groupType_description' - A string containing the description of the group.
--
-- 'roleArn', 'groupType_roleArn' - The role ARN for the group.
newGroupType ::
  GroupType
newGroupType :: GroupType
newGroupType =
  GroupType' :: Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GroupType
GroupType'
    { $sel:lastModifiedDate:GroupType' :: Maybe POSIX
lastModifiedDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:userPoolId:GroupType' :: Maybe Text
userPoolId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:GroupType' :: Maybe POSIX
creationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:precedence:GroupType' :: Maybe Natural
precedence = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:GroupType' :: Maybe Text
groupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:GroupType' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:GroupType' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The date the group was last modified.
groupType_lastModifiedDate :: Lens.Lens' GroupType (Prelude.Maybe Prelude.UTCTime)
groupType_lastModifiedDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> GroupType -> f GroupType
groupType_lastModifiedDate = (GroupType -> Maybe POSIX)
-> (GroupType -> Maybe POSIX -> GroupType)
-> Lens GroupType GroupType (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupType' {Maybe POSIX
lastModifiedDate :: Maybe POSIX
$sel:lastModifiedDate:GroupType' :: GroupType -> Maybe POSIX
lastModifiedDate} -> Maybe POSIX
lastModifiedDate) (\s :: GroupType
s@GroupType' {} Maybe POSIX
a -> GroupType
s {$sel:lastModifiedDate:GroupType' :: Maybe POSIX
lastModifiedDate = Maybe POSIX
a} :: GroupType) ((Maybe POSIX -> f (Maybe POSIX)) -> GroupType -> f GroupType)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GroupType
-> f GroupType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The user pool ID for the user pool.
groupType_userPoolId :: Lens.Lens' GroupType (Prelude.Maybe Prelude.Text)
groupType_userPoolId :: (Maybe Text -> f (Maybe Text)) -> GroupType -> f GroupType
groupType_userPoolId = (GroupType -> Maybe Text)
-> (GroupType -> Maybe Text -> GroupType)
-> Lens GroupType GroupType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupType' {Maybe Text
userPoolId :: Maybe Text
$sel:userPoolId:GroupType' :: GroupType -> Maybe Text
userPoolId} -> Maybe Text
userPoolId) (\s :: GroupType
s@GroupType' {} Maybe Text
a -> GroupType
s {$sel:userPoolId:GroupType' :: Maybe Text
userPoolId = Maybe Text
a} :: GroupType)

-- | The date the group was created.
groupType_creationDate :: Lens.Lens' GroupType (Prelude.Maybe Prelude.UTCTime)
groupType_creationDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> GroupType -> f GroupType
groupType_creationDate = (GroupType -> Maybe POSIX)
-> (GroupType -> Maybe POSIX -> GroupType)
-> Lens GroupType GroupType (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupType' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:GroupType' :: GroupType -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: GroupType
s@GroupType' {} Maybe POSIX
a -> GroupType
s {$sel:creationDate:GroupType' :: Maybe POSIX
creationDate = Maybe POSIX
a} :: GroupType) ((Maybe POSIX -> f (Maybe POSIX)) -> GroupType -> f GroupType)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GroupType
-> f GroupType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A nonnegative integer value that specifies the precedence of this group
-- relative to the other groups that a user can belong to in the user pool.
-- If a user belongs to two or more groups, it is the group with the
-- highest precedence whose role ARN will be used in the @cognito:roles@
-- and @cognito:preferred_role@ claims in the user\'s tokens. Groups with
-- higher @Precedence@ values take precedence over groups with lower
-- @Precedence@ values or with null @Precedence@ values.
--
-- Two groups can have the same @Precedence@ value. If this happens,
-- neither group takes precedence over the other. If two groups with the
-- same @Precedence@ have the same role ARN, that role is used in the
-- @cognito:preferred_role@ claim in tokens for users in each group. If the
-- two groups have different role ARNs, the @cognito:preferred_role@ claim
-- is not set in users\' tokens.
--
-- The default @Precedence@ value is null.
groupType_precedence :: Lens.Lens' GroupType (Prelude.Maybe Prelude.Natural)
groupType_precedence :: (Maybe Natural -> f (Maybe Natural)) -> GroupType -> f GroupType
groupType_precedence = (GroupType -> Maybe Natural)
-> (GroupType -> Maybe Natural -> GroupType)
-> Lens GroupType GroupType (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupType' {Maybe Natural
precedence :: Maybe Natural
$sel:precedence:GroupType' :: GroupType -> Maybe Natural
precedence} -> Maybe Natural
precedence) (\s :: GroupType
s@GroupType' {} Maybe Natural
a -> GroupType
s {$sel:precedence:GroupType' :: Maybe Natural
precedence = Maybe Natural
a} :: GroupType)

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

-- | A string containing the description of the group.
groupType_description :: Lens.Lens' GroupType (Prelude.Maybe Prelude.Text)
groupType_description :: (Maybe Text -> f (Maybe Text)) -> GroupType -> f GroupType
groupType_description = (GroupType -> Maybe Text)
-> (GroupType -> Maybe Text -> GroupType)
-> Lens GroupType GroupType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupType' {Maybe Text
description :: Maybe Text
$sel:description:GroupType' :: GroupType -> Maybe Text
description} -> Maybe Text
description) (\s :: GroupType
s@GroupType' {} Maybe Text
a -> GroupType
s {$sel:description:GroupType' :: Maybe Text
description = Maybe Text
a} :: GroupType)

-- | The role ARN for the group.
groupType_roleArn :: Lens.Lens' GroupType (Prelude.Maybe Prelude.Text)
groupType_roleArn :: (Maybe Text -> f (Maybe Text)) -> GroupType -> f GroupType
groupType_roleArn = (GroupType -> Maybe Text)
-> (GroupType -> Maybe Text -> GroupType)
-> Lens GroupType GroupType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupType' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:GroupType' :: GroupType -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: GroupType
s@GroupType' {} Maybe Text
a -> GroupType
s {$sel:roleArn:GroupType' :: Maybe Text
roleArn = Maybe Text
a} :: GroupType)

instance Core.FromJSON GroupType where
  parseJSON :: Value -> Parser GroupType
parseJSON =
    String -> (Object -> Parser GroupType) -> Value -> Parser GroupType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GroupType"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GroupType
GroupType'
            (Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Natural
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> GroupType)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Natural
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> GroupType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastModifiedDate")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Natural
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> GroupType)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Natural
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> GroupType)
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
"UserPoolId")
            Parser
  (Maybe POSIX
   -> Maybe Natural
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> GroupType)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Natural
      -> Maybe Text -> Maybe Text -> Maybe Text -> GroupType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationDate")
            Parser
  (Maybe Natural
   -> Maybe Text -> Maybe Text -> Maybe Text -> GroupType)
-> Parser (Maybe Natural)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> GroupType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Precedence")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> GroupType)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> GroupType)
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")
            Parser (Maybe Text -> Maybe Text -> GroupType)
-> Parser (Maybe Text) -> Parser (Maybe Text -> GroupType)
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
"Description")
            Parser (Maybe Text -> GroupType)
-> Parser (Maybe Text) -> Parser GroupType
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
"RoleArn")
      )

instance Prelude.Hashable GroupType

instance Prelude.NFData GroupType