{-# 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.Kendra.Types.UserGroupResolutionConfiguration
-- 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.Kendra.Types.UserGroupResolutionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kendra.Types.UserGroupResolutionMode
import qualified Amazonka.Prelude as Prelude

-- | Provides the configuration information to fetch access levels of groups
-- and users from an IAM Identity Center (successor to Single Sign-On)
-- identity source. This is useful for user context filtering, where search
-- results are filtered based on the user or their group access to
-- documents. You can also use the
-- <https://docs.aws.amazon.com/kendra/latest/dg/API_PutPrincipalMapping.html PutPrincipalMapping>
-- API to map users to their groups so that you only need to provide the
-- user ID when you issue the query.
--
-- To set up an IAM Identity Center identity source in the console to use
-- with Amazon Kendra, see
-- <https://docs.aws.amazon.com/kendra/latest/dg/getting-started-aws-sso.html Getting started with an IAM Identity Center identity source>.
-- You must also grant the required permissions to use IAM Identity Center
-- with Amazon Kendra. For more information, see
-- <https://docs.aws.amazon.com/kendra/latest/dg/iam-roles.html#iam-roles-aws-sso IAM roles for IAM Identity Center>.
--
-- Amazon Kendra currently does not support using
-- @UserGroupResolutionConfiguration@ with an Amazon Web Services
-- organization member account for your IAM Identity Center identify
-- source. You must create your index in the management account for the
-- organization in order to use @UserGroupResolutionConfiguration@.
--
-- /See:/ 'newUserGroupResolutionConfiguration' smart constructor.
data UserGroupResolutionConfiguration = UserGroupResolutionConfiguration'
  { -- | The identity store provider (mode) you want to use to fetch access
    -- levels of groups and users. IAM Identity Center (successor to Single
    -- Sign-On) is currently the only available mode. Your users and groups
    -- must exist in an IAM Identity Center identity source in order to use
    -- this mode.
    UserGroupResolutionConfiguration -> UserGroupResolutionMode
userGroupResolutionMode :: UserGroupResolutionMode
  }
  deriving (UserGroupResolutionConfiguration
-> UserGroupResolutionConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserGroupResolutionConfiguration
-> UserGroupResolutionConfiguration -> Bool
$c/= :: UserGroupResolutionConfiguration
-> UserGroupResolutionConfiguration -> Bool
== :: UserGroupResolutionConfiguration
-> UserGroupResolutionConfiguration -> Bool
$c== :: UserGroupResolutionConfiguration
-> UserGroupResolutionConfiguration -> Bool
Prelude.Eq, ReadPrec [UserGroupResolutionConfiguration]
ReadPrec UserGroupResolutionConfiguration
Int -> ReadS UserGroupResolutionConfiguration
ReadS [UserGroupResolutionConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserGroupResolutionConfiguration]
$creadListPrec :: ReadPrec [UserGroupResolutionConfiguration]
readPrec :: ReadPrec UserGroupResolutionConfiguration
$creadPrec :: ReadPrec UserGroupResolutionConfiguration
readList :: ReadS [UserGroupResolutionConfiguration]
$creadList :: ReadS [UserGroupResolutionConfiguration]
readsPrec :: Int -> ReadS UserGroupResolutionConfiguration
$creadsPrec :: Int -> ReadS UserGroupResolutionConfiguration
Prelude.Read, Int -> UserGroupResolutionConfiguration -> ShowS
[UserGroupResolutionConfiguration] -> ShowS
UserGroupResolutionConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserGroupResolutionConfiguration] -> ShowS
$cshowList :: [UserGroupResolutionConfiguration] -> ShowS
show :: UserGroupResolutionConfiguration -> String
$cshow :: UserGroupResolutionConfiguration -> String
showsPrec :: Int -> UserGroupResolutionConfiguration -> ShowS
$cshowsPrec :: Int -> UserGroupResolutionConfiguration -> ShowS
Prelude.Show, forall x.
Rep UserGroupResolutionConfiguration x
-> UserGroupResolutionConfiguration
forall x.
UserGroupResolutionConfiguration
-> Rep UserGroupResolutionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UserGroupResolutionConfiguration x
-> UserGroupResolutionConfiguration
$cfrom :: forall x.
UserGroupResolutionConfiguration
-> Rep UserGroupResolutionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'UserGroupResolutionConfiguration' 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:
--
-- 'userGroupResolutionMode', 'userGroupResolutionConfiguration_userGroupResolutionMode' - The identity store provider (mode) you want to use to fetch access
-- levels of groups and users. IAM Identity Center (successor to Single
-- Sign-On) is currently the only available mode. Your users and groups
-- must exist in an IAM Identity Center identity source in order to use
-- this mode.
newUserGroupResolutionConfiguration ::
  -- | 'userGroupResolutionMode'
  UserGroupResolutionMode ->
  UserGroupResolutionConfiguration
newUserGroupResolutionConfiguration :: UserGroupResolutionMode -> UserGroupResolutionConfiguration
newUserGroupResolutionConfiguration
  UserGroupResolutionMode
pUserGroupResolutionMode_ =
    UserGroupResolutionConfiguration'
      { $sel:userGroupResolutionMode:UserGroupResolutionConfiguration' :: UserGroupResolutionMode
userGroupResolutionMode =
          UserGroupResolutionMode
pUserGroupResolutionMode_
      }

-- | The identity store provider (mode) you want to use to fetch access
-- levels of groups and users. IAM Identity Center (successor to Single
-- Sign-On) is currently the only available mode. Your users and groups
-- must exist in an IAM Identity Center identity source in order to use
-- this mode.
userGroupResolutionConfiguration_userGroupResolutionMode :: Lens.Lens' UserGroupResolutionConfiguration UserGroupResolutionMode
userGroupResolutionConfiguration_userGroupResolutionMode :: Lens' UserGroupResolutionConfiguration UserGroupResolutionMode
userGroupResolutionConfiguration_userGroupResolutionMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserGroupResolutionConfiguration' {UserGroupResolutionMode
userGroupResolutionMode :: UserGroupResolutionMode
$sel:userGroupResolutionMode:UserGroupResolutionConfiguration' :: UserGroupResolutionConfiguration -> UserGroupResolutionMode
userGroupResolutionMode} -> UserGroupResolutionMode
userGroupResolutionMode) (\s :: UserGroupResolutionConfiguration
s@UserGroupResolutionConfiguration' {} UserGroupResolutionMode
a -> UserGroupResolutionConfiguration
s {$sel:userGroupResolutionMode:UserGroupResolutionConfiguration' :: UserGroupResolutionMode
userGroupResolutionMode = UserGroupResolutionMode
a} :: UserGroupResolutionConfiguration)

instance
  Data.FromJSON
    UserGroupResolutionConfiguration
  where
  parseJSON :: Value -> Parser UserGroupResolutionConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UserGroupResolutionConfiguration"
      ( \Object
x ->
          UserGroupResolutionMode -> UserGroupResolutionConfiguration
UserGroupResolutionConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"UserGroupResolutionMode")
      )

instance
  Prelude.Hashable
    UserGroupResolutionConfiguration
  where
  hashWithSalt :: Int -> UserGroupResolutionConfiguration -> Int
hashWithSalt
    Int
_salt
    UserGroupResolutionConfiguration' {UserGroupResolutionMode
userGroupResolutionMode :: UserGroupResolutionMode
$sel:userGroupResolutionMode:UserGroupResolutionConfiguration' :: UserGroupResolutionConfiguration -> UserGroupResolutionMode
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` UserGroupResolutionMode
userGroupResolutionMode

instance
  Prelude.NFData
    UserGroupResolutionConfiguration
  where
  rnf :: UserGroupResolutionConfiguration -> ()
rnf UserGroupResolutionConfiguration' {UserGroupResolutionMode
userGroupResolutionMode :: UserGroupResolutionMode
$sel:userGroupResolutionMode:UserGroupResolutionConfiguration' :: UserGroupResolutionConfiguration -> UserGroupResolutionMode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf UserGroupResolutionMode
userGroupResolutionMode

instance Data.ToJSON UserGroupResolutionConfiguration where
  toJSON :: UserGroupResolutionConfiguration -> Value
toJSON UserGroupResolutionConfiguration' {UserGroupResolutionMode
userGroupResolutionMode :: UserGroupResolutionMode
$sel:userGroupResolutionMode:UserGroupResolutionConfiguration' :: UserGroupResolutionConfiguration -> UserGroupResolutionMode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"UserGroupResolutionMode"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= UserGroupResolutionMode
userGroupResolutionMode
              )
          ]
      )