{-# 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.EntityPersonaConfiguration
-- 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.EntityPersonaConfiguration 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.Persona
import qualified Amazonka.Prelude as Prelude

-- | Provides the configuration information for users or groups in your IAM
-- Identity Center identity source for access to your Amazon Kendra
-- experience. Specific permissions are defined for each user or group once
-- they are granted access to your Amazon Kendra experience.
--
-- /See:/ 'newEntityPersonaConfiguration' smart constructor.
data EntityPersonaConfiguration = EntityPersonaConfiguration'
  { -- | The identifier of a user or group in your IAM Identity Center identity
    -- source. For example, a user ID could be an email.
    EntityPersonaConfiguration -> Text
entityId :: Prelude.Text,
    -- | The persona that defines the specific permissions of the user or group
    -- in your IAM Identity Center identity source. The available personas or
    -- access roles are @Owner@ and @Viewer@. For more information on these
    -- personas, see
    -- <https://docs.aws.amazon.com/kendra/latest/dg/deploying-search-experience-no-code.html#access-search-experience Providing access to your search page>.
    EntityPersonaConfiguration -> Persona
persona :: Persona
  }
  deriving (EntityPersonaConfiguration -> EntityPersonaConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityPersonaConfiguration -> EntityPersonaConfiguration -> Bool
$c/= :: EntityPersonaConfiguration -> EntityPersonaConfiguration -> Bool
== :: EntityPersonaConfiguration -> EntityPersonaConfiguration -> Bool
$c== :: EntityPersonaConfiguration -> EntityPersonaConfiguration -> Bool
Prelude.Eq, ReadPrec [EntityPersonaConfiguration]
ReadPrec EntityPersonaConfiguration
Int -> ReadS EntityPersonaConfiguration
ReadS [EntityPersonaConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntityPersonaConfiguration]
$creadListPrec :: ReadPrec [EntityPersonaConfiguration]
readPrec :: ReadPrec EntityPersonaConfiguration
$creadPrec :: ReadPrec EntityPersonaConfiguration
readList :: ReadS [EntityPersonaConfiguration]
$creadList :: ReadS [EntityPersonaConfiguration]
readsPrec :: Int -> ReadS EntityPersonaConfiguration
$creadsPrec :: Int -> ReadS EntityPersonaConfiguration
Prelude.Read, Int -> EntityPersonaConfiguration -> ShowS
[EntityPersonaConfiguration] -> ShowS
EntityPersonaConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntityPersonaConfiguration] -> ShowS
$cshowList :: [EntityPersonaConfiguration] -> ShowS
show :: EntityPersonaConfiguration -> String
$cshow :: EntityPersonaConfiguration -> String
showsPrec :: Int -> EntityPersonaConfiguration -> ShowS
$cshowsPrec :: Int -> EntityPersonaConfiguration -> ShowS
Prelude.Show, forall x.
Rep EntityPersonaConfiguration x -> EntityPersonaConfiguration
forall x.
EntityPersonaConfiguration -> Rep EntityPersonaConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EntityPersonaConfiguration x -> EntityPersonaConfiguration
$cfrom :: forall x.
EntityPersonaConfiguration -> Rep EntityPersonaConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EntityPersonaConfiguration' 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:
--
-- 'entityId', 'entityPersonaConfiguration_entityId' - The identifier of a user or group in your IAM Identity Center identity
-- source. For example, a user ID could be an email.
--
-- 'persona', 'entityPersonaConfiguration_persona' - The persona that defines the specific permissions of the user or group
-- in your IAM Identity Center identity source. The available personas or
-- access roles are @Owner@ and @Viewer@. For more information on these
-- personas, see
-- <https://docs.aws.amazon.com/kendra/latest/dg/deploying-search-experience-no-code.html#access-search-experience Providing access to your search page>.
newEntityPersonaConfiguration ::
  -- | 'entityId'
  Prelude.Text ->
  -- | 'persona'
  Persona ->
  EntityPersonaConfiguration
newEntityPersonaConfiguration :: Text -> Persona -> EntityPersonaConfiguration
newEntityPersonaConfiguration Text
pEntityId_ Persona
pPersona_ =
  EntityPersonaConfiguration'
    { $sel:entityId:EntityPersonaConfiguration' :: Text
entityId = Text
pEntityId_,
      $sel:persona:EntityPersonaConfiguration' :: Persona
persona = Persona
pPersona_
    }

-- | The identifier of a user or group in your IAM Identity Center identity
-- source. For example, a user ID could be an email.
entityPersonaConfiguration_entityId :: Lens.Lens' EntityPersonaConfiguration Prelude.Text
entityPersonaConfiguration_entityId :: Lens' EntityPersonaConfiguration Text
entityPersonaConfiguration_entityId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityPersonaConfiguration' {Text
entityId :: Text
$sel:entityId:EntityPersonaConfiguration' :: EntityPersonaConfiguration -> Text
entityId} -> Text
entityId) (\s :: EntityPersonaConfiguration
s@EntityPersonaConfiguration' {} Text
a -> EntityPersonaConfiguration
s {$sel:entityId:EntityPersonaConfiguration' :: Text
entityId = Text
a} :: EntityPersonaConfiguration)

-- | The persona that defines the specific permissions of the user or group
-- in your IAM Identity Center identity source. The available personas or
-- access roles are @Owner@ and @Viewer@. For more information on these
-- personas, see
-- <https://docs.aws.amazon.com/kendra/latest/dg/deploying-search-experience-no-code.html#access-search-experience Providing access to your search page>.
entityPersonaConfiguration_persona :: Lens.Lens' EntityPersonaConfiguration Persona
entityPersonaConfiguration_persona :: Lens' EntityPersonaConfiguration Persona
entityPersonaConfiguration_persona = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityPersonaConfiguration' {Persona
persona :: Persona
$sel:persona:EntityPersonaConfiguration' :: EntityPersonaConfiguration -> Persona
persona} -> Persona
persona) (\s :: EntityPersonaConfiguration
s@EntityPersonaConfiguration' {} Persona
a -> EntityPersonaConfiguration
s {$sel:persona:EntityPersonaConfiguration' :: Persona
persona = Persona
a} :: EntityPersonaConfiguration)

instance Prelude.Hashable EntityPersonaConfiguration where
  hashWithSalt :: Int -> EntityPersonaConfiguration -> Int
hashWithSalt Int
_salt EntityPersonaConfiguration' {Text
Persona
persona :: Persona
entityId :: Text
$sel:persona:EntityPersonaConfiguration' :: EntityPersonaConfiguration -> Persona
$sel:entityId:EntityPersonaConfiguration' :: EntityPersonaConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entityId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Persona
persona

instance Prelude.NFData EntityPersonaConfiguration where
  rnf :: EntityPersonaConfiguration -> ()
rnf EntityPersonaConfiguration' {Text
Persona
persona :: Persona
entityId :: Text
$sel:persona:EntityPersonaConfiguration' :: EntityPersonaConfiguration -> Persona
$sel:entityId:EntityPersonaConfiguration' :: EntityPersonaConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
entityId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Persona
persona

instance Data.ToJSON EntityPersonaConfiguration where
  toJSON :: EntityPersonaConfiguration -> Value
toJSON EntityPersonaConfiguration' {Text
Persona
persona :: Persona
entityId :: Text
$sel:persona:EntityPersonaConfiguration' :: EntityPersonaConfiguration -> Persona
$sel:entityId:EntityPersonaConfiguration' :: EntityPersonaConfiguration -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"EntityId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
entityId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Persona" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Persona
persona)
          ]
      )