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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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 login
    -- names for SAML users.
    AssertionAttributes -> Maybe Text
login :: Prelude.Maybe Prelude.Text
  }
  deriving (AssertionAttributes -> AssertionAttributes -> Bool
(AssertionAttributes -> AssertionAttributes -> Bool)
-> (AssertionAttributes -> AssertionAttributes -> Bool)
-> Eq AssertionAttributes
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]
(Int -> ReadS AssertionAttributes)
-> ReadS [AssertionAttributes]
-> ReadPrec AssertionAttributes
-> ReadPrec [AssertionAttributes]
-> Read 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
(Int -> AssertionAttributes -> ShowS)
-> (AssertionAttributes -> String)
-> ([AssertionAttributes] -> ShowS)
-> Show AssertionAttributes
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. AssertionAttributes -> Rep AssertionAttributes x)
-> (forall x. Rep AssertionAttributes x -> AssertionAttributes)
-> Generic AssertionAttributes
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.
--
-- '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.
--
-- 'name', 'assertionAttributes_name' - The name of the attribute within the SAML assertion to use as the user
-- full \"friendly\" names for SAML users.
--
-- 'login', 'assertionAttributes_login' - The name of the attribute within the SAML assertion to use as the login
-- names for SAML users.
newAssertionAttributes ::
  AssertionAttributes
newAssertionAttributes :: AssertionAttributes
newAssertionAttributes =
  AssertionAttributes' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AssertionAttributes
AssertionAttributes'
    { $sel:email:AssertionAttributes' :: Maybe Text
email = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groups:AssertionAttributes' :: Maybe Text
groups = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:org:AssertionAttributes' :: Maybe Text
org = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:role':AssertionAttributes' :: Maybe Text
role' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AssertionAttributes' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:login:AssertionAttributes' :: Maybe Text
login = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> AssertionAttributes -> f AssertionAttributes
assertionAttributes_email = (AssertionAttributes -> Maybe Text)
-> (AssertionAttributes -> Maybe Text -> AssertionAttributes)
-> Lens
     AssertionAttributes AssertionAttributes (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> AssertionAttributes -> f AssertionAttributes
assertionAttributes_groups = (AssertionAttributes -> Maybe Text)
-> (AssertionAttributes -> Maybe Text -> AssertionAttributes)
-> Lens
     AssertionAttributes AssertionAttributes (Maybe Text) (Maybe Text)
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 user
-- full \"friendly\" names for the users\' organizations.
assertionAttributes_org :: Lens.Lens' AssertionAttributes (Prelude.Maybe Prelude.Text)
assertionAttributes_org :: (Maybe Text -> f (Maybe Text))
-> AssertionAttributes -> f AssertionAttributes
assertionAttributes_org = (AssertionAttributes -> Maybe Text)
-> (AssertionAttributes -> Maybe Text -> AssertionAttributes)
-> Lens
     AssertionAttributes AssertionAttributes (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> AssertionAttributes -> f AssertionAttributes
assertionAttributes_role = (AssertionAttributes -> Maybe Text)
-> (AssertionAttributes -> Maybe Text -> AssertionAttributes)
-> Lens
     AssertionAttributes AssertionAttributes (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> AssertionAttributes -> f AssertionAttributes
assertionAttributes_name = (AssertionAttributes -> Maybe Text)
-> (AssertionAttributes -> Maybe Text -> AssertionAttributes)
-> Lens
     AssertionAttributes AssertionAttributes (Maybe Text) (Maybe Text)
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 login
-- names for SAML users.
assertionAttributes_login :: Lens.Lens' AssertionAttributes (Prelude.Maybe Prelude.Text)
assertionAttributes_login :: (Maybe Text -> f (Maybe Text))
-> AssertionAttributes -> f AssertionAttributes
assertionAttributes_login = (AssertionAttributes -> Maybe Text)
-> (AssertionAttributes -> Maybe Text -> AssertionAttributes)
-> Lens
     AssertionAttributes AssertionAttributes (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable AssertionAttributes

instance Prelude.NFData AssertionAttributes

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