{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.OpenSearch.Types.SAMLOptionsInput where

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

-- | The SAML authentication configuration for an Amazon OpenSearch Service
-- domain.
--
-- /See:/ 'newSAMLOptionsInput' smart constructor.
data SAMLOptionsInput = SAMLOptionsInput'
  { -- | True to enable SAML authentication for a domain.
    SAMLOptionsInput -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The SAML Identity Provider\'s information.
    SAMLOptionsInput -> Maybe SAMLIdp
idp :: Prelude.Maybe SAMLIdp,
    -- | The backend role that the SAML master user is mapped to.
    SAMLOptionsInput -> Maybe Text
masterBackendRole :: Prelude.Maybe Prelude.Text,
    -- | The SAML master user name, which is stored in the domain\'s internal
    -- user database.
    SAMLOptionsInput -> Maybe (Sensitive Text)
masterUserName :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | Element of the SAML assertion to use for backend roles. Default is
    -- @roles@.
    SAMLOptionsInput -> Maybe Text
rolesKey :: 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 the user name. Default is
    -- @NameID@.
    SAMLOptionsInput -> Maybe Text
subjectKey :: Prelude.Maybe Prelude.Text
  }
  deriving (SAMLOptionsInput -> SAMLOptionsInput -> Bool
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
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. 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:
--
-- 'enabled', 'sAMLOptionsInput_enabled' - True to enable SAML authentication for a domain.
--
-- 'idp', 'sAMLOptionsInput_idp' - The SAML Identity Provider\'s information.
--
-- 'masterBackendRole', 'sAMLOptionsInput_masterBackendRole' - The backend role that the SAML master user is mapped to.
--
-- 'masterUserName', 'sAMLOptionsInput_masterUserName' - The SAML master user name, which is stored in the domain\'s internal
-- user database.
--
-- 'rolesKey', 'sAMLOptionsInput_rolesKey' - Element of the SAML assertion to use for backend roles. Default is
-- @roles@.
--
-- '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 the user name. Default is
-- @NameID@.
newSAMLOptionsInput ::
  SAMLOptionsInput
newSAMLOptionsInput :: SAMLOptionsInput
newSAMLOptionsInput =
  SAMLOptionsInput'
    { $sel:enabled:SAMLOptionsInput' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:idp:SAMLOptionsInput' :: Maybe SAMLIdp
idp = forall a. Maybe a
Prelude.Nothing,
      $sel:masterBackendRole:SAMLOptionsInput' :: Maybe Text
masterBackendRole = forall a. Maybe a
Prelude.Nothing,
      $sel:masterUserName:SAMLOptionsInput' :: Maybe (Sensitive Text)
masterUserName = forall a. Maybe a
Prelude.Nothing,
      $sel:rolesKey:SAMLOptionsInput' :: Maybe Text
rolesKey = forall a. Maybe a
Prelude.Nothing,
      $sel:sessionTimeoutMinutes:SAMLOptionsInput' :: Maybe Int
sessionTimeoutMinutes = forall a. Maybe a
Prelude.Nothing,
      $sel:subjectKey:SAMLOptionsInput' :: Maybe Text
subjectKey = forall a. Maybe a
Prelude.Nothing
    }

-- | True to enable SAML authentication for a domain.
sAMLOptionsInput_enabled :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Bool)
sAMLOptionsInput_enabled :: Lens' SAMLOptionsInput (Maybe Bool)
sAMLOptionsInput_enabled = 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 :: Lens' SAMLOptionsInput (Maybe SAMLIdp)
sAMLOptionsInput_idp = 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)

-- | The backend role that the SAML master user is mapped to.
sAMLOptionsInput_masterBackendRole :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Text)
sAMLOptionsInput_masterBackendRole :: Lens' SAMLOptionsInput (Maybe Text)
sAMLOptionsInput_masterBackendRole = 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 SAML master user name, which is stored in the domain\'s internal
-- user database.
sAMLOptionsInput_masterUserName :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Text)
sAMLOptionsInput_masterUserName :: Lens' SAMLOptionsInput (Maybe Text)
sAMLOptionsInput_masterUserName = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | Element of the SAML assertion to use for backend roles. Default is
-- @roles@.
sAMLOptionsInput_rolesKey :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Text)
sAMLOptionsInput_rolesKey :: Lens' SAMLOptionsInput (Maybe Text)
sAMLOptionsInput_rolesKey = 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 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 :: Lens' SAMLOptionsInput (Maybe Int)
sAMLOptionsInput_sessionTimeoutMinutes = 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 the user name. Default is
-- @NameID@.
sAMLOptionsInput_subjectKey :: Lens.Lens' SAMLOptionsInput (Prelude.Maybe Prelude.Text)
sAMLOptionsInput_subjectKey :: Lens' SAMLOptionsInput (Maybe Text)
sAMLOptionsInput_subjectKey = 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 where
  hashWithSalt :: Int -> SAMLOptionsInput -> Int
hashWithSalt Int
_salt SAMLOptionsInput' {Maybe Bool
Maybe Int
Maybe Text
Maybe (Sensitive Text)
Maybe SAMLIdp
subjectKey :: Maybe Text
sessionTimeoutMinutes :: Maybe Int
rolesKey :: Maybe Text
masterUserName :: Maybe (Sensitive Text)
masterBackendRole :: Maybe Text
idp :: Maybe SAMLIdp
enabled :: Maybe Bool
$sel:subjectKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:sessionTimeoutMinutes:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Int
$sel:rolesKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:masterUserName:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe (Sensitive Text)
$sel:masterBackendRole:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:idp:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe SAMLIdp
$sel:enabled:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SAMLIdp
idp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
masterBackendRole
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
masterUserName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
rolesKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
sessionTimeoutMinutes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
subjectKey

instance Prelude.NFData SAMLOptionsInput where
  rnf :: SAMLOptionsInput -> ()
rnf SAMLOptionsInput' {Maybe Bool
Maybe Int
Maybe Text
Maybe (Sensitive Text)
Maybe SAMLIdp
subjectKey :: Maybe Text
sessionTimeoutMinutes :: Maybe Int
rolesKey :: Maybe Text
masterUserName :: Maybe (Sensitive Text)
masterBackendRole :: Maybe Text
idp :: Maybe SAMLIdp
enabled :: Maybe Bool
$sel:subjectKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:sessionTimeoutMinutes:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Int
$sel:rolesKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:masterUserName:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe (Sensitive Text)
$sel:masterBackendRole:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:idp:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe SAMLIdp
$sel:enabled:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SAMLIdp
idp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
masterBackendRole
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
masterUserName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
rolesKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
sessionTimeoutMinutes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
subjectKey

instance Data.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
rolesKey :: Maybe Text
masterUserName :: Maybe (Sensitive Text)
masterBackendRole :: Maybe Text
idp :: Maybe SAMLIdp
enabled :: Maybe Bool
$sel:subjectKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:sessionTimeoutMinutes:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Int
$sel:rolesKey:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:masterUserName:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe (Sensitive Text)
$sel:masterBackendRole:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Text
$sel:idp:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe SAMLIdp
$sel:enabled:SAMLOptionsInput' :: SAMLOptionsInput -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Enabled" 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 Bool
enabled,
            (Key
"Idp" 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 SAMLIdp
idp,
            (Key
"MasterBackendRole" 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
masterBackendRole,
            (Key
"MasterUserName" 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 (Sensitive Text)
masterUserName,
            (Key
"RolesKey" 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
rolesKey,
            (Key
"SessionTimeoutMinutes" 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 Int
sessionTimeoutMinutes,
            (Key
"SubjectKey" 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
subjectKey
          ]
      )