{-# 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.SSOAdmin.Types.AccessControlAttribute
-- 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.SSOAdmin.Types.AccessControlAttribute 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
import Amazonka.SSOAdmin.Types.AccessControlAttributeValue

-- | These are IAM Identity Center identity store attributes that you can
-- configure for use in attributes-based access control (ABAC). You can
-- create permissions policies that determine who can access your AWS
-- resources based upon the configured attribute values. When you enable
-- ABAC and specify @AccessControlAttributes@, IAM Identity Center passes
-- the attribute values of the authenticated user into IAM for use in
-- policy evaluation.
--
-- /See:/ 'newAccessControlAttribute' smart constructor.
data AccessControlAttribute = AccessControlAttribute'
  { -- | The name of the attribute associated with your identities in your
    -- identity source. This is used to map a specified attribute in your
    -- identity source with an attribute in IAM Identity Center.
    AccessControlAttribute -> Text
key :: Prelude.Text,
    -- | The value used for mapping a specified attribute to an identity source.
    AccessControlAttribute -> AccessControlAttributeValue
value :: AccessControlAttributeValue
  }
  deriving (AccessControlAttribute -> AccessControlAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessControlAttribute -> AccessControlAttribute -> Bool
$c/= :: AccessControlAttribute -> AccessControlAttribute -> Bool
== :: AccessControlAttribute -> AccessControlAttribute -> Bool
$c== :: AccessControlAttribute -> AccessControlAttribute -> Bool
Prelude.Eq, ReadPrec [AccessControlAttribute]
ReadPrec AccessControlAttribute
Int -> ReadS AccessControlAttribute
ReadS [AccessControlAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccessControlAttribute]
$creadListPrec :: ReadPrec [AccessControlAttribute]
readPrec :: ReadPrec AccessControlAttribute
$creadPrec :: ReadPrec AccessControlAttribute
readList :: ReadS [AccessControlAttribute]
$creadList :: ReadS [AccessControlAttribute]
readsPrec :: Int -> ReadS AccessControlAttribute
$creadsPrec :: Int -> ReadS AccessControlAttribute
Prelude.Read, Int -> AccessControlAttribute -> ShowS
[AccessControlAttribute] -> ShowS
AccessControlAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessControlAttribute] -> ShowS
$cshowList :: [AccessControlAttribute] -> ShowS
show :: AccessControlAttribute -> String
$cshow :: AccessControlAttribute -> String
showsPrec :: Int -> AccessControlAttribute -> ShowS
$cshowsPrec :: Int -> AccessControlAttribute -> ShowS
Prelude.Show, forall x. Rep AccessControlAttribute x -> AccessControlAttribute
forall x. AccessControlAttribute -> Rep AccessControlAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccessControlAttribute x -> AccessControlAttribute
$cfrom :: forall x. AccessControlAttribute -> Rep AccessControlAttribute x
Prelude.Generic)

-- |
-- Create a value of 'AccessControlAttribute' 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:
--
-- 'key', 'accessControlAttribute_key' - The name of the attribute associated with your identities in your
-- identity source. This is used to map a specified attribute in your
-- identity source with an attribute in IAM Identity Center.
--
-- 'value', 'accessControlAttribute_value' - The value used for mapping a specified attribute to an identity source.
newAccessControlAttribute ::
  -- | 'key'
  Prelude.Text ->
  -- | 'value'
  AccessControlAttributeValue ->
  AccessControlAttribute
newAccessControlAttribute :: Text -> AccessControlAttributeValue -> AccessControlAttribute
newAccessControlAttribute Text
pKey_ AccessControlAttributeValue
pValue_ =
  AccessControlAttribute'
    { $sel:key:AccessControlAttribute' :: Text
key = Text
pKey_,
      $sel:value:AccessControlAttribute' :: AccessControlAttributeValue
value = AccessControlAttributeValue
pValue_
    }

-- | The name of the attribute associated with your identities in your
-- identity source. This is used to map a specified attribute in your
-- identity source with an attribute in IAM Identity Center.
accessControlAttribute_key :: Lens.Lens' AccessControlAttribute Prelude.Text
accessControlAttribute_key :: Lens' AccessControlAttribute Text
accessControlAttribute_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessControlAttribute' {Text
key :: Text
$sel:key:AccessControlAttribute' :: AccessControlAttribute -> Text
key} -> Text
key) (\s :: AccessControlAttribute
s@AccessControlAttribute' {} Text
a -> AccessControlAttribute
s {$sel:key:AccessControlAttribute' :: Text
key = Text
a} :: AccessControlAttribute)

-- | The value used for mapping a specified attribute to an identity source.
accessControlAttribute_value :: Lens.Lens' AccessControlAttribute AccessControlAttributeValue
accessControlAttribute_value :: Lens' AccessControlAttribute AccessControlAttributeValue
accessControlAttribute_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessControlAttribute' {AccessControlAttributeValue
value :: AccessControlAttributeValue
$sel:value:AccessControlAttribute' :: AccessControlAttribute -> AccessControlAttributeValue
value} -> AccessControlAttributeValue
value) (\s :: AccessControlAttribute
s@AccessControlAttribute' {} AccessControlAttributeValue
a -> AccessControlAttribute
s {$sel:value:AccessControlAttribute' :: AccessControlAttributeValue
value = AccessControlAttributeValue
a} :: AccessControlAttribute)

instance Data.FromJSON AccessControlAttribute where
  parseJSON :: Value -> Parser AccessControlAttribute
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AccessControlAttribute"
      ( \Object
x ->
          Text -> AccessControlAttributeValue -> AccessControlAttribute
AccessControlAttribute'
            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
"Key")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Value")
      )

instance Prelude.Hashable AccessControlAttribute where
  hashWithSalt :: Int -> AccessControlAttribute -> Int
hashWithSalt Int
_salt AccessControlAttribute' {Text
AccessControlAttributeValue
value :: AccessControlAttributeValue
key :: Text
$sel:value:AccessControlAttribute' :: AccessControlAttribute -> AccessControlAttributeValue
$sel:key:AccessControlAttribute' :: AccessControlAttribute -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AccessControlAttributeValue
value

instance Prelude.NFData AccessControlAttribute where
  rnf :: AccessControlAttribute -> ()
rnf AccessControlAttribute' {Text
AccessControlAttributeValue
value :: AccessControlAttributeValue
key :: Text
$sel:value:AccessControlAttribute' :: AccessControlAttribute -> AccessControlAttributeValue
$sel:key:AccessControlAttribute' :: AccessControlAttribute -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
key seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AccessControlAttributeValue
value

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