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

-- | Provides the configuration information for users or groups in your IAM
-- Identity Center identity source to grant access your Amazon Kendra
-- experience.
--
-- /See:/ 'newEntityConfiguration' smart constructor.
data EntityConfiguration = EntityConfiguration'
  { -- | The identifier of a user or group in your IAM Identity Center identity
    -- source. For example, a user ID could be an email.
    EntityConfiguration -> Text
entityId :: Prelude.Text,
    -- | Specifies whether you are configuring a @User@ or a @Group@.
    EntityConfiguration -> EntityType
entityType :: EntityType
  }
  deriving (EntityConfiguration -> EntityConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityConfiguration -> EntityConfiguration -> Bool
$c/= :: EntityConfiguration -> EntityConfiguration -> Bool
== :: EntityConfiguration -> EntityConfiguration -> Bool
$c== :: EntityConfiguration -> EntityConfiguration -> Bool
Prelude.Eq, ReadPrec [EntityConfiguration]
ReadPrec EntityConfiguration
Int -> ReadS EntityConfiguration
ReadS [EntityConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntityConfiguration]
$creadListPrec :: ReadPrec [EntityConfiguration]
readPrec :: ReadPrec EntityConfiguration
$creadPrec :: ReadPrec EntityConfiguration
readList :: ReadS [EntityConfiguration]
$creadList :: ReadS [EntityConfiguration]
readsPrec :: Int -> ReadS EntityConfiguration
$creadsPrec :: Int -> ReadS EntityConfiguration
Prelude.Read, Int -> EntityConfiguration -> ShowS
[EntityConfiguration] -> ShowS
EntityConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntityConfiguration] -> ShowS
$cshowList :: [EntityConfiguration] -> ShowS
show :: EntityConfiguration -> String
$cshow :: EntityConfiguration -> String
showsPrec :: Int -> EntityConfiguration -> ShowS
$cshowsPrec :: Int -> EntityConfiguration -> ShowS
Prelude.Show, forall x. Rep EntityConfiguration x -> EntityConfiguration
forall x. EntityConfiguration -> Rep EntityConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntityConfiguration x -> EntityConfiguration
$cfrom :: forall x. EntityConfiguration -> Rep EntityConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EntityConfiguration' 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', 'entityConfiguration_entityId' - The identifier of a user or group in your IAM Identity Center identity
-- source. For example, a user ID could be an email.
--
-- 'entityType', 'entityConfiguration_entityType' - Specifies whether you are configuring a @User@ or a @Group@.
newEntityConfiguration ::
  -- | 'entityId'
  Prelude.Text ->
  -- | 'entityType'
  EntityType ->
  EntityConfiguration
newEntityConfiguration :: Text -> EntityType -> EntityConfiguration
newEntityConfiguration Text
pEntityId_ EntityType
pEntityType_ =
  EntityConfiguration'
    { $sel:entityId:EntityConfiguration' :: Text
entityId = Text
pEntityId_,
      $sel:entityType:EntityConfiguration' :: EntityType
entityType = EntityType
pEntityType_
    }

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

-- | Specifies whether you are configuring a @User@ or a @Group@.
entityConfiguration_entityType :: Lens.Lens' EntityConfiguration EntityType
entityConfiguration_entityType :: Lens' EntityConfiguration EntityType
entityConfiguration_entityType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityConfiguration' {EntityType
entityType :: EntityType
$sel:entityType:EntityConfiguration' :: EntityConfiguration -> EntityType
entityType} -> EntityType
entityType) (\s :: EntityConfiguration
s@EntityConfiguration' {} EntityType
a -> EntityConfiguration
s {$sel:entityType:EntityConfiguration' :: EntityType
entityType = EntityType
a} :: EntityConfiguration)

instance Prelude.Hashable EntityConfiguration where
  hashWithSalt :: Int -> EntityConfiguration -> Int
hashWithSalt Int
_salt EntityConfiguration' {Text
EntityType
entityType :: EntityType
entityId :: Text
$sel:entityType:EntityConfiguration' :: EntityConfiguration -> EntityType
$sel:entityId:EntityConfiguration' :: EntityConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entityId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EntityType
entityType

instance Prelude.NFData EntityConfiguration where
  rnf :: EntityConfiguration -> ()
rnf EntityConfiguration' {Text
EntityType
entityType :: EntityType
entityId :: Text
$sel:entityType:EntityConfiguration' :: EntityConfiguration -> EntityType
$sel:entityId:EntityConfiguration' :: EntityConfiguration -> 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 EntityType
entityType

instance Data.ToJSON EntityConfiguration where
  toJSON :: EntityConfiguration -> Value
toJSON EntityConfiguration' {Text
EntityType
entityType :: EntityType
entityId :: Text
$sel:entityType:EntityConfiguration' :: EntityConfiguration -> EntityType
$sel:entityId:EntityConfiguration' :: EntityConfiguration -> 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
"EntityType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= EntityType
entityType)
          ]
      )