{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CognitoIdentityProvider.Types.GroupType where

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

-- | The group type.
--
-- /See:/ 'newGroupType' smart constructor.
data GroupType = GroupType'
  { -- | The date the group was created.
    GroupType -> Maybe POSIX
creationDate :: Prelude.Maybe Data.POSIX,
    -- | A string containing the description of the group.
    GroupType -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the group.
    GroupType -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text,
    -- | The date the group was last modified.
    GroupType -> Maybe POSIX
lastModifiedDate :: Prelude.Maybe Data.POSIX,
    -- | A non-negative integer value that specifies the precedence of this group
    -- relative to the other groups that a user can belong to in the user pool.
    -- Zero is the highest precedence value. Groups with lower @Precedence@
    -- values take precedence over groups with higher ornull @Precedence@
    -- values. If a user belongs to two or more groups, it is the group with
    -- the lowest precedence value whose role ARN is given in the user\'s
    -- tokens for the @cognito:roles@ and @cognito:preferred_role@ claims.
    --
    -- 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
    -- isn\'t set in users\' tokens.
    --
    -- The default @Precedence@ value is null.
    GroupType -> Maybe Natural
precedence :: Prelude.Maybe Prelude.Natural,
    -- | The role Amazon Resource Name (ARN) for the group.
    GroupType -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The user pool ID for the user pool.
    GroupType -> Maybe Text
userPoolId :: Prelude.Maybe Prelude.Text
  }
  deriving (GroupType -> GroupType -> Bool
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]
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
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. 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:
--
-- 'creationDate', 'groupType_creationDate' - The date the group was created.
--
-- 'description', 'groupType_description' - A string containing the description of the group.
--
-- 'groupName', 'groupType_groupName' - The name of the group.
--
-- 'lastModifiedDate', 'groupType_lastModifiedDate' - The date the group was last modified.
--
-- 'precedence', 'groupType_precedence' - A non-negative integer value that specifies the precedence of this group
-- relative to the other groups that a user can belong to in the user pool.
-- Zero is the highest precedence value. Groups with lower @Precedence@
-- values take precedence over groups with higher ornull @Precedence@
-- values. If a user belongs to two or more groups, it is the group with
-- the lowest precedence value whose role ARN is given in the user\'s
-- tokens for the @cognito:roles@ and @cognito:preferred_role@ claims.
--
-- 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
-- isn\'t set in users\' tokens.
--
-- The default @Precedence@ value is null.
--
-- 'roleArn', 'groupType_roleArn' - The role Amazon Resource Name (ARN) for the group.
--
-- 'userPoolId', 'groupType_userPoolId' - The user pool ID for the user pool.
newGroupType ::
  GroupType
newGroupType :: GroupType
newGroupType =
  GroupType'
    { $sel:creationDate:GroupType' :: Maybe POSIX
creationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:description:GroupType' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:GroupType' :: Maybe Text
groupName = forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedDate:GroupType' :: Maybe POSIX
lastModifiedDate = forall a. Maybe a
Prelude.Nothing,
      $sel:precedence:GroupType' :: Maybe Natural
precedence = forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:GroupType' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:userPoolId:GroupType' :: Maybe Text
userPoolId = forall a. Maybe a
Prelude.Nothing
    }

-- | The date the group was created.
groupType_creationDate :: Lens.Lens' GroupType (Prelude.Maybe Prelude.UTCTime)
groupType_creationDate :: Lens' GroupType (Maybe UTCTime)
groupType_creationDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A string containing the description of the group.
groupType_description :: Lens.Lens' GroupType (Prelude.Maybe Prelude.Text)
groupType_description :: Lens' GroupType (Maybe Text)
groupType_description = 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 name of the group.
groupType_groupName :: Lens.Lens' GroupType (Prelude.Maybe Prelude.Text)
groupType_groupName :: Lens' GroupType (Maybe Text)
groupType_groupName = 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)

-- | The date the group was last modified.
groupType_lastModifiedDate :: Lens.Lens' GroupType (Prelude.Maybe Prelude.UTCTime)
groupType_lastModifiedDate :: Lens' GroupType (Maybe UTCTime)
groupType_lastModifiedDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A non-negative integer value that specifies the precedence of this group
-- relative to the other groups that a user can belong to in the user pool.
-- Zero is the highest precedence value. Groups with lower @Precedence@
-- values take precedence over groups with higher ornull @Precedence@
-- values. If a user belongs to two or more groups, it is the group with
-- the lowest precedence value whose role ARN is given in the user\'s
-- tokens for the @cognito:roles@ and @cognito:preferred_role@ claims.
--
-- 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
-- isn\'t set in users\' tokens.
--
-- The default @Precedence@ value is null.
groupType_precedence :: Lens.Lens' GroupType (Prelude.Maybe Prelude.Natural)
groupType_precedence :: Lens' GroupType (Maybe Natural)
groupType_precedence = 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 role Amazon Resource Name (ARN) for the group.
groupType_roleArn :: Lens.Lens' GroupType (Prelude.Maybe Prelude.Text)
groupType_roleArn :: Lens' GroupType (Maybe Text)
groupType_roleArn = 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)

-- | The user pool ID for the user pool.
groupType_userPoolId :: Lens.Lens' GroupType (Prelude.Maybe Prelude.Text)
groupType_userPoolId :: Lens' GroupType (Maybe Text)
groupType_userPoolId = 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)

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

instance Prelude.Hashable GroupType where
  hashWithSalt :: Int -> GroupType -> Int
hashWithSalt Int
_salt GroupType' {Maybe Natural
Maybe Text
Maybe POSIX
userPoolId :: Maybe Text
roleArn :: Maybe Text
precedence :: Maybe Natural
lastModifiedDate :: Maybe POSIX
groupName :: Maybe Text
description :: Maybe Text
creationDate :: Maybe POSIX
$sel:userPoolId:GroupType' :: GroupType -> Maybe Text
$sel:roleArn:GroupType' :: GroupType -> Maybe Text
$sel:precedence:GroupType' :: GroupType -> Maybe Natural
$sel:lastModifiedDate:GroupType' :: GroupType -> Maybe POSIX
$sel:groupName:GroupType' :: GroupType -> Maybe Text
$sel:description:GroupType' :: GroupType -> Maybe Text
$sel:creationDate:GroupType' :: GroupType -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastModifiedDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
precedence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userPoolId

instance Prelude.NFData GroupType where
  rnf :: GroupType -> ()
rnf GroupType' {Maybe Natural
Maybe Text
Maybe POSIX
userPoolId :: Maybe Text
roleArn :: Maybe Text
precedence :: Maybe Natural
lastModifiedDate :: Maybe POSIX
groupName :: Maybe Text
description :: Maybe Text
creationDate :: Maybe POSIX
$sel:userPoolId:GroupType' :: GroupType -> Maybe Text
$sel:roleArn:GroupType' :: GroupType -> Maybe Text
$sel:precedence:GroupType' :: GroupType -> Maybe Natural
$sel:lastModifiedDate:GroupType' :: GroupType -> Maybe POSIX
$sel:groupName:GroupType' :: GroupType -> Maybe Text
$sel:description:GroupType' :: GroupType -> Maybe Text
$sel:creationDate:GroupType' :: GroupType -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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
groupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastModifiedDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
precedence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userPoolId