{-# 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.Grafana.Types.AssertionAttributes
-- 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.Grafana.Types.AssertionAttributes 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

-- | A structure that defines which attributes in the IdP assertion are to be
-- used to define information about the users authenticated by the IdP to
-- use the workspace.
--
-- /See:/ 'newAssertionAttributes' smart constructor.
data AssertionAttributes = AssertionAttributes'
  { -- | The name of the attribute within the SAML assertion to use as the email
    -- names for SAML users.
    AssertionAttributes -> Maybe Text
email :: Prelude.Maybe Prelude.Text,
    -- | The name of the attribute within the SAML assertion to use as the user
    -- full \"friendly\" names for user groups.
    AssertionAttributes -> Maybe Text
groups :: Prelude.Maybe Prelude.Text,
    -- | The name of the attribute within the SAML assertion to use as the login
    -- names for SAML users.
    AssertionAttributes -> Maybe Text
login :: Prelude.Maybe Prelude.Text,
    -- | The name of the attribute within the SAML assertion to use as the user
    -- full \"friendly\" names for SAML users.
    AssertionAttributes -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The name of the attribute within the SAML assertion to use as the user
    -- full \"friendly\" names for the users\' organizations.
    AssertionAttributes -> Maybe Text
org :: Prelude.Maybe Prelude.Text,
    -- | The name of the attribute within the SAML assertion to use as the user
    -- roles.
    AssertionAttributes -> Maybe Text
role' :: Prelude.Maybe Prelude.Text
  }
  deriving (AssertionAttributes -> AssertionAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssertionAttributes -> AssertionAttributes -> Bool
$c/= :: AssertionAttributes -> AssertionAttributes -> Bool
== :: AssertionAttributes -> AssertionAttributes -> Bool
$c== :: AssertionAttributes -> AssertionAttributes -> Bool
Prelude.Eq, ReadPrec [AssertionAttributes]
ReadPrec AssertionAttributes
Int -> ReadS AssertionAttributes
ReadS [AssertionAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssertionAttributes]
$creadListPrec :: ReadPrec [AssertionAttributes]
readPrec :: ReadPrec AssertionAttributes
$creadPrec :: ReadPrec AssertionAttributes
readList :: ReadS [AssertionAttributes]
$creadList :: ReadS [AssertionAttributes]
readsPrec :: Int -> ReadS AssertionAttributes
$creadsPrec :: Int -> ReadS AssertionAttributes
Prelude.Read, Int -> AssertionAttributes -> ShowS
[AssertionAttributes] -> ShowS
AssertionAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssertionAttributes] -> ShowS
$cshowList :: [AssertionAttributes] -> ShowS
show :: AssertionAttributes -> String
$cshow :: AssertionAttributes -> String
showsPrec :: Int -> AssertionAttributes -> ShowS
$cshowsPrec :: Int -> AssertionAttributes -> ShowS
Prelude.Show, forall x. Rep AssertionAttributes x -> AssertionAttributes
forall x. AssertionAttributes -> Rep AssertionAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssertionAttributes x -> AssertionAttributes
$cfrom :: forall x. AssertionAttributes -> Rep AssertionAttributes x
Prelude.Generic)

-- |
-- Create a value of 'AssertionAttributes' 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:
--
-- 'email', 'assertionAttributes_email' - The name of the attribute within the SAML assertion to use as the email
-- names for SAML users.
--
-- 'groups', 'assertionAttributes_groups' - The name of the attribute within the SAML assertion to use as the user
-- full \"friendly\" names for user groups.
--
-- 'login', 'assertionAttributes_login' - The name of the attribute within the SAML assertion to use as the login
-- names for SAML users.
--
-- 'name', 'assertionAttributes_name' - The name of the attribute within the SAML assertion to use as the user
-- full \"friendly\" names for SAML users.
--
-- 'org', 'assertionAttributes_org' - The name of the attribute within the SAML assertion to use as the user
-- full \"friendly\" names for the users\' organizations.
--
-- 'role'', 'assertionAttributes_role' - The name of the attribute within the SAML assertion to use as the user
-- roles.
newAssertionAttributes ::
  AssertionAttributes
newAssertionAttributes :: AssertionAttributes
newAssertionAttributes =
  AssertionAttributes'
    { $sel:email:AssertionAttributes' :: Maybe Text
email = forall a. Maybe a
Prelude.Nothing,
      $sel:groups:AssertionAttributes' :: Maybe Text
groups = forall a. Maybe a
Prelude.Nothing,
      $sel:login:AssertionAttributes' :: Maybe Text
login = forall a. Maybe a
Prelude.Nothing,
      $sel:name:AssertionAttributes' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:org:AssertionAttributes' :: Maybe Text
org = forall a. Maybe a
Prelude.Nothing,
      $sel:role':AssertionAttributes' :: Maybe Text
role' = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the attribute within the SAML assertion to use as the email
-- names for SAML users.
assertionAttributes_email :: Lens.Lens' AssertionAttributes (Prelude.Maybe Prelude.Text)
assertionAttributes_email :: Lens' AssertionAttributes (Maybe Text)
assertionAttributes_email = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssertionAttributes' {Maybe Text
email :: Maybe Text
$sel:email:AssertionAttributes' :: AssertionAttributes -> Maybe Text
email} -> Maybe Text
email) (\s :: AssertionAttributes
s@AssertionAttributes' {} Maybe Text
a -> AssertionAttributes
s {$sel:email:AssertionAttributes' :: Maybe Text
email = Maybe Text
a} :: AssertionAttributes)

-- | The name of the attribute within the SAML assertion to use as the user
-- full \"friendly\" names for user groups.
assertionAttributes_groups :: Lens.Lens' AssertionAttributes (Prelude.Maybe Prelude.Text)
assertionAttributes_groups :: Lens' AssertionAttributes (Maybe Text)
assertionAttributes_groups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssertionAttributes' {Maybe Text
groups :: Maybe Text
$sel:groups:AssertionAttributes' :: AssertionAttributes -> Maybe Text
groups} -> Maybe Text
groups) (\s :: AssertionAttributes
s@AssertionAttributes' {} Maybe Text
a -> AssertionAttributes
s {$sel:groups:AssertionAttributes' :: Maybe Text
groups = Maybe Text
a} :: AssertionAttributes)

-- | The name of the attribute within the SAML assertion to use as the login
-- names for SAML users.
assertionAttributes_login :: Lens.Lens' AssertionAttributes (Prelude.Maybe Prelude.Text)
assertionAttributes_login :: Lens' AssertionAttributes (Maybe Text)
assertionAttributes_login = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssertionAttributes' {Maybe Text
login :: Maybe Text
$sel:login:AssertionAttributes' :: AssertionAttributes -> Maybe Text
login} -> Maybe Text
login) (\s :: AssertionAttributes
s@AssertionAttributes' {} Maybe Text
a -> AssertionAttributes
s {$sel:login:AssertionAttributes' :: Maybe Text
login = Maybe Text
a} :: AssertionAttributes)

-- | The name of the attribute within the SAML assertion to use as the user
-- full \"friendly\" names for SAML users.
assertionAttributes_name :: Lens.Lens' AssertionAttributes (Prelude.Maybe Prelude.Text)
assertionAttributes_name :: Lens' AssertionAttributes (Maybe Text)
assertionAttributes_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssertionAttributes' {Maybe Text
name :: Maybe Text
$sel:name:AssertionAttributes' :: AssertionAttributes -> Maybe Text
name} -> Maybe Text
name) (\s :: AssertionAttributes
s@AssertionAttributes' {} Maybe Text
a -> AssertionAttributes
s {$sel:name:AssertionAttributes' :: Maybe Text
name = Maybe Text
a} :: AssertionAttributes)

-- | The name of the attribute within the SAML assertion to use as the user
-- full \"friendly\" names for the users\' organizations.
assertionAttributes_org :: Lens.Lens' AssertionAttributes (Prelude.Maybe Prelude.Text)
assertionAttributes_org :: Lens' AssertionAttributes (Maybe Text)
assertionAttributes_org = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssertionAttributes' {Maybe Text
org :: Maybe Text
$sel:org:AssertionAttributes' :: AssertionAttributes -> Maybe Text
org} -> Maybe Text
org) (\s :: AssertionAttributes
s@AssertionAttributes' {} Maybe Text
a -> AssertionAttributes
s {$sel:org:AssertionAttributes' :: Maybe Text
org = Maybe Text
a} :: AssertionAttributes)

-- | The name of the attribute within the SAML assertion to use as the user
-- roles.
assertionAttributes_role :: Lens.Lens' AssertionAttributes (Prelude.Maybe Prelude.Text)
assertionAttributes_role :: Lens' AssertionAttributes (Maybe Text)
assertionAttributes_role = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssertionAttributes' {Maybe Text
role' :: Maybe Text
$sel:role':AssertionAttributes' :: AssertionAttributes -> Maybe Text
role'} -> Maybe Text
role') (\s :: AssertionAttributes
s@AssertionAttributes' {} Maybe Text
a -> AssertionAttributes
s {$sel:role':AssertionAttributes' :: Maybe Text
role' = Maybe Text
a} :: AssertionAttributes)

instance Data.FromJSON AssertionAttributes where
  parseJSON :: Value -> Parser AssertionAttributes
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AssertionAttributes"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AssertionAttributes
AssertionAttributes'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"email")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"groups")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"login")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe 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 (Maybe a)
Data..:? Key
"org")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"role")
      )

instance Prelude.Hashable AssertionAttributes where
  hashWithSalt :: Int -> AssertionAttributes -> Int
hashWithSalt Int
_salt AssertionAttributes' {Maybe Text
role' :: Maybe Text
org :: Maybe Text
name :: Maybe Text
login :: Maybe Text
groups :: Maybe Text
email :: Maybe Text
$sel:role':AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:org:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:name:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:login:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:groups:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:email:AssertionAttributes' :: AssertionAttributes -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
email
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groups
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
login
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
org
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
role'

instance Prelude.NFData AssertionAttributes where
  rnf :: AssertionAttributes -> ()
rnf AssertionAttributes' {Maybe Text
role' :: Maybe Text
org :: Maybe Text
name :: Maybe Text
login :: Maybe Text
groups :: Maybe Text
email :: Maybe Text
$sel:role':AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:org:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:name:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:login:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:groups:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:email:AssertionAttributes' :: AssertionAttributes -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
email
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groups
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
login
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
org
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
role'

instance Data.ToJSON AssertionAttributes where
  toJSON :: AssertionAttributes -> Value
toJSON AssertionAttributes' {Maybe Text
role' :: Maybe Text
org :: Maybe Text
name :: Maybe Text
login :: Maybe Text
groups :: Maybe Text
email :: Maybe Text
$sel:role':AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:org:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:name:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:login:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:groups:AssertionAttributes' :: AssertionAttributes -> Maybe Text
$sel:email:AssertionAttributes' :: AssertionAttributes -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"email" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
email,
            (Key
"groups" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
groups,
            (Key
"login" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
login,
            (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Key
"org" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
org,
            (Key
"role" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
role'
          ]
      )