{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SSOAdmin.Types.AccessControlAttributeValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The value used for mapping a specified attribute to an identity source.
--
-- /See:/ 'newAccessControlAttributeValue' smart constructor.
data AccessControlAttributeValue = AccessControlAttributeValue'
  { -- | The identity source to use when mapping a specified attribute to Amazon
    -- Web Services SSO.
    AccessControlAttributeValue -> NonEmpty Text
source :: Prelude.NonEmpty Prelude.Text
  }
  deriving (AccessControlAttributeValue -> AccessControlAttributeValue -> Bool
(AccessControlAttributeValue
 -> AccessControlAttributeValue -> Bool)
-> (AccessControlAttributeValue
    -> AccessControlAttributeValue -> Bool)
-> Eq AccessControlAttributeValue
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]
(Int -> ReadS AccessControlAttributeValue)
-> ReadS [AccessControlAttributeValue]
-> ReadPrec AccessControlAttributeValue
-> ReadPrec [AccessControlAttributeValue]
-> Read 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
(Int -> AccessControlAttributeValue -> ShowS)
-> (AccessControlAttributeValue -> String)
-> ([AccessControlAttributeValue] -> ShowS)
-> Show AccessControlAttributeValue
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.
 AccessControlAttributeValue -> Rep AccessControlAttributeValue x)
-> (forall x.
    Rep AccessControlAttributeValue x -> AccessControlAttributeValue)
-> Generic AccessControlAttributeValue
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 Amazon
-- Web Services SSO.
newAccessControlAttributeValue ::
  -- | 'source'
  Prelude.NonEmpty Prelude.Text ->
  AccessControlAttributeValue
newAccessControlAttributeValue :: NonEmpty Text -> AccessControlAttributeValue
newAccessControlAttributeValue NonEmpty Text
pSource_ =
  AccessControlAttributeValue' :: NonEmpty Text -> AccessControlAttributeValue
AccessControlAttributeValue'
    { $sel:source:AccessControlAttributeValue' :: NonEmpty Text
source =
        Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pSource_
    }

-- | The identity source to use when mapping a specified attribute to Amazon
-- Web Services SSO.
accessControlAttributeValue_source :: Lens.Lens' AccessControlAttributeValue (Prelude.NonEmpty Prelude.Text)
accessControlAttributeValue_source :: (NonEmpty Text -> f (NonEmpty Text))
-> AccessControlAttributeValue -> f AccessControlAttributeValue
accessControlAttributeValue_source = (AccessControlAttributeValue -> NonEmpty Text)
-> (AccessControlAttributeValue
    -> NonEmpty Text -> AccessControlAttributeValue)
-> Lens
     AccessControlAttributeValue
     AccessControlAttributeValue
     (NonEmpty Text)
     (NonEmpty Text)
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) ((NonEmpty Text -> f (NonEmpty Text))
 -> AccessControlAttributeValue -> f AccessControlAttributeValue)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> AccessControlAttributeValue
-> f AccessControlAttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AccessControlAttributeValue where
  parseJSON :: Value -> Parser AccessControlAttributeValue
parseJSON =
    String
-> (Object -> Parser AccessControlAttributeValue)
-> Value
-> Parser AccessControlAttributeValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccessControlAttributeValue"
      ( \Object
x ->
          NonEmpty Text -> AccessControlAttributeValue
AccessControlAttributeValue'
            (NonEmpty Text -> AccessControlAttributeValue)
-> Parser (NonEmpty Text) -> Parser AccessControlAttributeValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Source")
      )

instance Prelude.Hashable AccessControlAttributeValue

instance Prelude.NFData AccessControlAttributeValue

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