{-# 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.AppStream.Types.EntitlementAttribute
-- 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.AppStream.Types.EntitlementAttribute 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

-- | An attribute associated with an entitlement. Application entitlements
-- work by matching a supported SAML 2.0 attribute name to a value when a
-- user identity federates to an Amazon AppStream 2.0 SAML application.
--
-- /See:/ 'newEntitlementAttribute' smart constructor.
data EntitlementAttribute = EntitlementAttribute'
  { -- | A supported AWS IAM SAML @PrincipalTag@ attribute that is matched to the
    -- associated value when a user identity federates into an Amazon AppStream
    -- 2.0 SAML application.
    --
    -- The following are valid values:
    --
    -- -   roles
    --
    -- -   department
    --
    -- -   organization
    --
    -- -   groups
    --
    -- -   title
    --
    -- -   costCenter
    --
    -- -   userType
    EntitlementAttribute -> Text
name :: Prelude.Text,
    -- | A value that is matched to a supported SAML attribute name when a user
    -- identity federates into an Amazon AppStream 2.0 SAML application.
    EntitlementAttribute -> Text
value :: Prelude.Text
  }
  deriving (EntitlementAttribute -> EntitlementAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntitlementAttribute -> EntitlementAttribute -> Bool
$c/= :: EntitlementAttribute -> EntitlementAttribute -> Bool
== :: EntitlementAttribute -> EntitlementAttribute -> Bool
$c== :: EntitlementAttribute -> EntitlementAttribute -> Bool
Prelude.Eq, ReadPrec [EntitlementAttribute]
ReadPrec EntitlementAttribute
Int -> ReadS EntitlementAttribute
ReadS [EntitlementAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntitlementAttribute]
$creadListPrec :: ReadPrec [EntitlementAttribute]
readPrec :: ReadPrec EntitlementAttribute
$creadPrec :: ReadPrec EntitlementAttribute
readList :: ReadS [EntitlementAttribute]
$creadList :: ReadS [EntitlementAttribute]
readsPrec :: Int -> ReadS EntitlementAttribute
$creadsPrec :: Int -> ReadS EntitlementAttribute
Prelude.Read, Int -> EntitlementAttribute -> ShowS
[EntitlementAttribute] -> ShowS
EntitlementAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntitlementAttribute] -> ShowS
$cshowList :: [EntitlementAttribute] -> ShowS
show :: EntitlementAttribute -> String
$cshow :: EntitlementAttribute -> String
showsPrec :: Int -> EntitlementAttribute -> ShowS
$cshowsPrec :: Int -> EntitlementAttribute -> ShowS
Prelude.Show, forall x. Rep EntitlementAttribute x -> EntitlementAttribute
forall x. EntitlementAttribute -> Rep EntitlementAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntitlementAttribute x -> EntitlementAttribute
$cfrom :: forall x. EntitlementAttribute -> Rep EntitlementAttribute x
Prelude.Generic)

-- |
-- Create a value of 'EntitlementAttribute' 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:
--
-- 'name', 'entitlementAttribute_name' - A supported AWS IAM SAML @PrincipalTag@ attribute that is matched to the
-- associated value when a user identity federates into an Amazon AppStream
-- 2.0 SAML application.
--
-- The following are valid values:
--
-- -   roles
--
-- -   department
--
-- -   organization
--
-- -   groups
--
-- -   title
--
-- -   costCenter
--
-- -   userType
--
-- 'value', 'entitlementAttribute_value' - A value that is matched to a supported SAML attribute name when a user
-- identity federates into an Amazon AppStream 2.0 SAML application.
newEntitlementAttribute ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  EntitlementAttribute
newEntitlementAttribute :: Text -> Text -> EntitlementAttribute
newEntitlementAttribute Text
pName_ Text
pValue_ =
  EntitlementAttribute'
    { $sel:name:EntitlementAttribute' :: Text
name = Text
pName_,
      $sel:value:EntitlementAttribute' :: Text
value = Text
pValue_
    }

-- | A supported AWS IAM SAML @PrincipalTag@ attribute that is matched to the
-- associated value when a user identity federates into an Amazon AppStream
-- 2.0 SAML application.
--
-- The following are valid values:
--
-- -   roles
--
-- -   department
--
-- -   organization
--
-- -   groups
--
-- -   title
--
-- -   costCenter
--
-- -   userType
entitlementAttribute_name :: Lens.Lens' EntitlementAttribute Prelude.Text
entitlementAttribute_name :: Lens' EntitlementAttribute Text
entitlementAttribute_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementAttribute' {Text
name :: Text
$sel:name:EntitlementAttribute' :: EntitlementAttribute -> Text
name} -> Text
name) (\s :: EntitlementAttribute
s@EntitlementAttribute' {} Text
a -> EntitlementAttribute
s {$sel:name:EntitlementAttribute' :: Text
name = Text
a} :: EntitlementAttribute)

-- | A value that is matched to a supported SAML attribute name when a user
-- identity federates into an Amazon AppStream 2.0 SAML application.
entitlementAttribute_value :: Lens.Lens' EntitlementAttribute Prelude.Text
entitlementAttribute_value :: Lens' EntitlementAttribute Text
entitlementAttribute_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntitlementAttribute' {Text
value :: Text
$sel:value:EntitlementAttribute' :: EntitlementAttribute -> Text
value} -> Text
value) (\s :: EntitlementAttribute
s@EntitlementAttribute' {} Text
a -> EntitlementAttribute
s {$sel:value:EntitlementAttribute' :: Text
value = Text
a} :: EntitlementAttribute)

instance Data.FromJSON EntitlementAttribute where
  parseJSON :: Value -> Parser EntitlementAttribute
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EntitlementAttribute"
      ( \Object
x ->
          Text -> Text -> EntitlementAttribute
EntitlementAttribute'
            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
"Name")
            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 EntitlementAttribute where
  hashWithSalt :: Int -> EntitlementAttribute -> Int
hashWithSalt Int
_salt EntitlementAttribute' {Text
value :: Text
name :: Text
$sel:value:EntitlementAttribute' :: EntitlementAttribute -> Text
$sel:name:EntitlementAttribute' :: EntitlementAttribute -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

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

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