{-# 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.AccessControlAttributeValue
-- 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.AccessControlAttributeValue 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 value used for mapping a specified attribute to an identity source.
-- For more information, see
-- <https://docs.aws.amazon.com/singlesignon/latest/userguide/attributemappingsconcept.html Attribute mappings>
-- in the /IAM Identity Center User Guide/.
--
-- /See:/ 'newAccessControlAttributeValue' smart constructor.
data AccessControlAttributeValue = AccessControlAttributeValue'
  { -- | The identity source to use when mapping a specified attribute to IAM
    -- Identity Center.
    AccessControlAttributeValue -> NonEmpty Text
source :: Prelude.NonEmpty Prelude.Text
  }
  deriving (AccessControlAttributeValue -> AccessControlAttributeValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessControlAttributeValue -> AccessControlAttributeValue -> Bool
$c/= :: AccessControlAttributeValue -> AccessControlAttributeValue -> Bool
== :: AccessControlAttributeValue -> AccessControlAttributeValue -> Bool
$c== :: AccessControlAttributeValue -> AccessControlAttributeValue -> Bool
Prelude.Eq, ReadPrec [AccessControlAttributeValue]
ReadPrec AccessControlAttributeValue
Int -> ReadS AccessControlAttributeValue
ReadS [AccessControlAttributeValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccessControlAttributeValue]
$creadListPrec :: ReadPrec [AccessControlAttributeValue]
readPrec :: ReadPrec AccessControlAttributeValue
$creadPrec :: ReadPrec AccessControlAttributeValue
readList :: ReadS [AccessControlAttributeValue]
$creadList :: ReadS [AccessControlAttributeValue]
readsPrec :: Int -> ReadS AccessControlAttributeValue
$creadsPrec :: Int -> ReadS AccessControlAttributeValue
Prelude.Read, Int -> AccessControlAttributeValue -> ShowS
[AccessControlAttributeValue] -> ShowS
AccessControlAttributeValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessControlAttributeValue] -> ShowS
$cshowList :: [AccessControlAttributeValue] -> ShowS
show :: AccessControlAttributeValue -> String
$cshow :: AccessControlAttributeValue -> String
showsPrec :: Int -> AccessControlAttributeValue -> ShowS
$cshowsPrec :: Int -> AccessControlAttributeValue -> ShowS
Prelude.Show, forall x.
Rep AccessControlAttributeValue x -> AccessControlAttributeValue
forall x.
AccessControlAttributeValue -> Rep AccessControlAttributeValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AccessControlAttributeValue x -> AccessControlAttributeValue
$cfrom :: forall x.
AccessControlAttributeValue -> Rep AccessControlAttributeValue x
Prelude.Generic)

-- |
-- Create a value of 'AccessControlAttributeValue' 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:
--
-- 'source', 'accessControlAttributeValue_source' - The identity source to use when mapping a specified attribute to IAM
-- Identity Center.
newAccessControlAttributeValue ::
  -- | 'source'
  Prelude.NonEmpty Prelude.Text ->
  AccessControlAttributeValue
newAccessControlAttributeValue :: NonEmpty Text -> AccessControlAttributeValue
newAccessControlAttributeValue NonEmpty Text
pSource_ =
  AccessControlAttributeValue'
    { $sel:source:AccessControlAttributeValue' :: NonEmpty Text
source =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pSource_
    }

-- | The identity source to use when mapping a specified attribute to IAM
-- Identity Center.
accessControlAttributeValue_source :: Lens.Lens' AccessControlAttributeValue (Prelude.NonEmpty Prelude.Text)
accessControlAttributeValue_source :: Lens' AccessControlAttributeValue (NonEmpty Text)
accessControlAttributeValue_source = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessControlAttributeValue' {NonEmpty Text
source :: NonEmpty Text
$sel:source:AccessControlAttributeValue' :: AccessControlAttributeValue -> NonEmpty Text
source} -> NonEmpty Text
source) (\s :: AccessControlAttributeValue
s@AccessControlAttributeValue' {} NonEmpty Text
a -> AccessControlAttributeValue
s {$sel:source:AccessControlAttributeValue' :: NonEmpty Text
source = NonEmpty Text
a} :: AccessControlAttributeValue) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON AccessControlAttributeValue where
  parseJSON :: Value -> Parser AccessControlAttributeValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AccessControlAttributeValue"
      ( \Object
x ->
          NonEmpty Text -> AccessControlAttributeValue
AccessControlAttributeValue'
            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
"Source")
      )

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

instance Prelude.NFData AccessControlAttributeValue where
  rnf :: AccessControlAttributeValue -> ()
rnf AccessControlAttributeValue' {NonEmpty Text
source :: NonEmpty Text
$sel:source:AccessControlAttributeValue' :: AccessControlAttributeValue -> NonEmpty Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
source

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