{-# 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.OpenSearch.Types.SAMLOptionsInput
-- 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.OpenSearch.Types.SAMLOptionsInput where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpenSearch.Types.SAMLIdp
import qualified Amazonka.Prelude as Prelude

-- | The SAML application configuration for the domain.
--
-- /See:/ 'newSAMLOptionsInput' smart constructor.
data SAMLOptionsInput = SAMLOptionsInput'
  { -- | The SAML master username, which is stored in the Amazon OpenSearch
    -- Service domain\'s internal database.
    SAMLOptionsInput -> Maybe (Sensitive Text)
masterUserName :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | True if SAML is enabled.
    SAMLOptionsInput -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The SAML Identity Provider\'s information.
    SAMLOptionsInput -> Maybe SAMLIdp
idp :: Prelude.Maybe SAMLIdp,
    -- | Element of the SAML assertion to use for backend roles. Default is
    -- roles.
    SAMLOptionsInput -> Maybe Text
rolesKey :: Prelude.Maybe Prelude.Text,
    -- | The backend role that the SAML master user is mapped to.
    SAMLOptionsInput -> Maybe Text
masterBackendRole :: Prelude.Maybe Prelude.Text,
    -- | The duration, in minutes, after which a user session becomes inactive.
    -- Acceptable values are between 1 and 1440, and the default value is 60.
    SAMLOptionsInput -> Maybe Int
sessionTimeoutMinutes :: Prelude.Maybe Prelude.Int,
    -- | Element of the SAML assertion to use for username. Default is NameID.
    SAMLOptionsInput -> Maybe Text
subjectKey :: Prelude.Maybe Prelude.Text
  }
  deriving (SAMLOptionsInput -> SAMLOptionsInput -> Bool
(SAMLOptionsInput -> SAMLOptionsInput -> Bool)
-> (SAMLOptionsInput -> SAMLOptionsInput -> Bool)
-> Eq SAMLOptionsInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SAMLOptionsInput -> SAMLOptionsInput -> Bool
$c/= :: SAMLOptionsInput -> SAMLOptionsInput -> Bool
== :: SAMLOptionsInput -> SAMLOptionsInput -> Bool
$c== :: SAMLOptionsInput -> SAMLOptionsInput -> Bool
Prelude.Eq, Int -> SAMLOptionsInput -> ShowS
[SAMLOptionsInput] -> ShowS
SAMLOptionsInput -> String
(Int -> SAMLOptionsInput -> ShowS)
-> (SAMLOptionsInput -> String)
-> ([SAMLOptionsInput] -> ShowS)
-> Show SAMLOptionsInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SAMLOptionsInput] -> ShowS
$cshowList :: [SAMLOptionsInput] -> ShowS
show :: SAMLOptionsInput -> String
$cshow :: SAMLOptionsInput -> String
showsPrec :: Int -> SAMLOptionsInput -> ShowS
$cshowsPrec :: Int -> SAMLOptionsInput -> ShowS
Prelude.Show, (forall x. SAMLOptionsInput -> Rep SAMLOptionsInput x)
-> (forall x. Rep SAMLOptionsInput x -> SAMLOptionsInput)
-> Generic SAMLOptionsInput
forall x. Rep SAMLOptionsInput x -> SAMLOptionsInput
forall x. SAMLOptionsInput -> Rep SAMLOptionsInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SAMLOptionsInput x -> SAMLOptionsInput
$cfrom :: forall x. SAMLOptionsInput -> Rep SAMLOptionsInput x
Prelude.Generic)

-- |
-- Create a value of 'SAMLOptionsInput' 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:
--
-- 'masterUserName', 'sAMLOptionsInput_masterUserName' - The SAML master username, which is stored in the Amazon OpenSearch
-- Service domain\'s internal database.
--
-- 'enabled', 'sAMLOptionsInput_enabled' - True if SAML is enabled.
--
-- 'idp', 'sAMLOptionsInput_idp' - The SAML Identity Provider\'s information.
--
-- 'rolesKey', 'sAMLOptionsInput_rolesKey' - Element of the SAML assertion to use for backend roles. Default is
-- roles.
--
-- 'masterBackendRole', 'sAMLOptionsInput_masterBackendRole' - The backend role that the SAML master user is mapped to.
--
-- 'sessionTimeoutMinutes', 'sAMLOptionsInput_sessionTimeoutMinutes' - The duration, in minutes, after which a user session becomes inactive.
-- Acceptable values are between 1 and 1440, and the default value is 60.
--
-- 'subjectKey', 'sAMLOptionsInput_subjectKey' - Element of the SAML assertion to use for username. Default is NameID.
newSAMLOptionsInput ::
  SAMLOptionsInput
newSAMLOptionsInput :: SAMLOptionsInput
newSAMLOptionsInput =
  SAMLOptionsInput' :: Maybe (Sensitive Text)
-> Maybe Bool
-> Maybe SAMLIdp
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> SAMLOptionsInput
SAMLOptionsInput'
    { $sel:masterUserName:SAMLOptionsInput' :: Maybe (Sensitive Text)
masterUserName = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:SAMLOptionsInput' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:idp:SAMLOptionsInput' :: Maybe SAMLIdp
idp = Maybe SAMLIdp
forall a. Maybe a
Prelude.Nothing,
      $sel:rolesKey:SAMLOptionsInput' :: Maybe Text
rolesKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:masterBackendRole:SAMLOptionsInput' :: Maybe Text
masterBackendRole = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionTimeoutMinutes:SAMLOptionsInput' :: Maybe Int
sessionTimeoutMinutes = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:subjectKey:SAMLOptionsInput' :: Maybe Text
subjectKey = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The SAML master username, which is stored in the Amazon OpenSearch
-- Service domain\'s internal database.
sAMLOptionsInput_masterUserName :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Text)
sAMLOptionsInput_masterUserName :: (Maybe Text -> f (Maybe Text))
-> SAMLOptionsInput -> f SAMLOptionsInput
sAMLOptionsInput_masterUserName = (SAMLOptionsInput -> Maybe (Sensitive Text))
-> (SAMLOptionsInput -> Maybe (Sensitive Text) -> SAMLOptionsInput)
-> Lens
     SAMLOptionsInput
     SAMLOptionsInput
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SAMLOptionsInput' {Maybe (Sensitive Text)
masterUserName :: Maybe (Sensitive Text)
$sel:masterUserName:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe (Sensitive Text)
masterUserName} -> Maybe (Sensitive Text)
masterUserName) (\s :: SAMLOptionsInput
s@SAMLOptionsInput' {} Maybe (Sensitive Text)
a -> SAMLOptionsInput
s {$sel:masterUserName:SAMLOptionsInput' :: Maybe (Sensitive Text)
masterUserName = Maybe (Sensitive Text)
a} :: SAMLOptionsInput) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> SAMLOptionsInput -> f SAMLOptionsInput)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> SAMLOptionsInput
-> f SAMLOptionsInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | True if SAML is enabled.
sAMLOptionsInput_enabled :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Bool)
sAMLOptionsInput_enabled :: (Maybe Bool -> f (Maybe Bool))
-> SAMLOptionsInput -> f SAMLOptionsInput
sAMLOptionsInput_enabled = (SAMLOptionsInput -> Maybe Bool)
-> (SAMLOptionsInput -> Maybe Bool -> SAMLOptionsInput)
-> Lens SAMLOptionsInput SAMLOptionsInput (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SAMLOptionsInput' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: SAMLOptionsInput
s@SAMLOptionsInput' {} Maybe Bool
a -> SAMLOptionsInput
s {$sel:enabled:SAMLOptionsInput' :: Maybe Bool
enabled = Maybe Bool
a} :: SAMLOptionsInput)

-- | The SAML Identity Provider\'s information.
sAMLOptionsInput_idp :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe SAMLIdp)
sAMLOptionsInput_idp :: (Maybe SAMLIdp -> f (Maybe SAMLIdp))
-> SAMLOptionsInput -> f SAMLOptionsInput
sAMLOptionsInput_idp = (SAMLOptionsInput -> Maybe SAMLIdp)
-> (SAMLOptionsInput -> Maybe SAMLIdp -> SAMLOptionsInput)
-> Lens
     SAMLOptionsInput SAMLOptionsInput (Maybe SAMLIdp) (Maybe SAMLIdp)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SAMLOptionsInput' {Maybe SAMLIdp
idp :: Maybe SAMLIdp
$sel:idp:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe SAMLIdp
idp} -> Maybe SAMLIdp
idp) (\s :: SAMLOptionsInput
s@SAMLOptionsInput' {} Maybe SAMLIdp
a -> SAMLOptionsInput
s {$sel:idp:SAMLOptionsInput' :: Maybe SAMLIdp
idp = Maybe SAMLIdp
a} :: SAMLOptionsInput)

-- | Element of the SAML assertion to use for backend roles. Default is
-- roles.
sAMLOptionsInput_rolesKey :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Text)
sAMLOptionsInput_rolesKey :: (Maybe Text -> f (Maybe Text))
-> SAMLOptionsInput -> f SAMLOptionsInput
sAMLOptionsInput_rolesKey = (SAMLOptionsInput -> Maybe Text)
-> (SAMLOptionsInput -> Maybe Text -> SAMLOptionsInput)
-> Lens SAMLOptionsInput SAMLOptionsInput (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SAMLOptionsInput' {Maybe Text
rolesKey :: Maybe Text
$sel:rolesKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
rolesKey} -> Maybe Text
rolesKey) (\s :: SAMLOptionsInput
s@SAMLOptionsInput' {} Maybe Text
a -> SAMLOptionsInput
s {$sel:rolesKey:SAMLOptionsInput' :: Maybe Text
rolesKey = Maybe Text
a} :: SAMLOptionsInput)

-- | The backend role that the SAML master user is mapped to.
sAMLOptionsInput_masterBackendRole :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Text)
sAMLOptionsInput_masterBackendRole :: (Maybe Text -> f (Maybe Text))
-> SAMLOptionsInput -> f SAMLOptionsInput
sAMLOptionsInput_masterBackendRole = (SAMLOptionsInput -> Maybe Text)
-> (SAMLOptionsInput -> Maybe Text -> SAMLOptionsInput)
-> Lens SAMLOptionsInput SAMLOptionsInput (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SAMLOptionsInput' {Maybe Text
masterBackendRole :: Maybe Text
$sel:masterBackendRole:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
masterBackendRole} -> Maybe Text
masterBackendRole) (\s :: SAMLOptionsInput
s@SAMLOptionsInput' {} Maybe Text
a -> SAMLOptionsInput
s {$sel:masterBackendRole:SAMLOptionsInput' :: Maybe Text
masterBackendRole = Maybe Text
a} :: SAMLOptionsInput)

-- | The duration, in minutes, after which a user session becomes inactive.
-- Acceptable values are between 1 and 1440, and the default value is 60.
sAMLOptionsInput_sessionTimeoutMinutes :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Int)
sAMLOptionsInput_sessionTimeoutMinutes :: (Maybe Int -> f (Maybe Int))
-> SAMLOptionsInput -> f SAMLOptionsInput
sAMLOptionsInput_sessionTimeoutMinutes = (SAMLOptionsInput -> Maybe Int)
-> (SAMLOptionsInput -> Maybe Int -> SAMLOptionsInput)
-> Lens SAMLOptionsInput SAMLOptionsInput (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SAMLOptionsInput' {Maybe Int
sessionTimeoutMinutes :: Maybe Int
$sel:sessionTimeoutMinutes:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Int
sessionTimeoutMinutes} -> Maybe Int
sessionTimeoutMinutes) (\s :: SAMLOptionsInput
s@SAMLOptionsInput' {} Maybe Int
a -> SAMLOptionsInput
s {$sel:sessionTimeoutMinutes:SAMLOptionsInput' :: Maybe Int
sessionTimeoutMinutes = Maybe Int
a} :: SAMLOptionsInput)

-- | Element of the SAML assertion to use for username. Default is NameID.
sAMLOptionsInput_subjectKey :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Text)
sAMLOptionsInput_subjectKey :: (Maybe Text -> f (Maybe Text))
-> SAMLOptionsInput -> f SAMLOptionsInput
sAMLOptionsInput_subjectKey = (SAMLOptionsInput -> Maybe Text)
-> (SAMLOptionsInput -> Maybe Text -> SAMLOptionsInput)
-> Lens SAMLOptionsInput SAMLOptionsInput (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SAMLOptionsInput' {Maybe Text
subjectKey :: Maybe Text
$sel:subjectKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
subjectKey} -> Maybe Text
subjectKey) (\s :: SAMLOptionsInput
s@SAMLOptionsInput' {} Maybe Text
a -> SAMLOptionsInput
s {$sel:subjectKey:SAMLOptionsInput' :: Maybe Text
subjectKey = Maybe Text
a} :: SAMLOptionsInput)

instance Prelude.Hashable SAMLOptionsInput

instance Prelude.NFData SAMLOptionsInput

instance Core.ToJSON SAMLOptionsInput where
  toJSON :: SAMLOptionsInput -> Value
toJSON SAMLOptionsInput' {Maybe Bool
Maybe Int
Maybe Text
Maybe (Sensitive Text)
Maybe SAMLIdp
subjectKey :: Maybe Text
sessionTimeoutMinutes :: Maybe Int
masterBackendRole :: Maybe Text
rolesKey :: Maybe Text
idp :: Maybe SAMLIdp
enabled :: Maybe Bool
masterUserName :: Maybe (Sensitive Text)
$sel:subjectKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:sessionTimeoutMinutes:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Int
$sel:masterBackendRole:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:rolesKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:idp:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe SAMLIdp
$sel:enabled:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Bool
$sel:masterUserName:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MasterUserName" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
masterUserName,
            (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Text
"Idp" Text -> SAMLIdp -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SAMLIdp -> Pair) -> Maybe SAMLIdp -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SAMLIdp
idp,
            (Text
"RolesKey" 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
rolesKey,
            (Text
"MasterBackendRole" 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
masterBackendRole,
            (Text
"SessionTimeoutMinutes" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
sessionTimeoutMinutes,
            (Text
"SubjectKey" 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
subjectKey
          ]
      )