{-# 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.OpenSearchServerless.Types.SamlConfigOptions
-- 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.OpenSearchServerless.Types.SamlConfigOptions 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

-- | Describes SAML options for an OpenSearch Serverless security
-- configuration in the form of a key-value map.
--
-- /See:/ 'newSamlConfigOptions' smart constructor.
data SamlConfigOptions = SamlConfigOptions'
  { -- | The group attribute for this SAML integration.
    SamlConfigOptions -> Maybe Text
groupAttribute :: Prelude.Maybe Prelude.Text,
    -- | The session timeout, in minutes. Minimum is 15 minutes and maximum is
    -- 1440 minutes (24 hours or 1 day). Default is 60 minutes.
    SamlConfigOptions -> Maybe Natural
sessionTimeout :: Prelude.Maybe Prelude.Natural,
    -- | A user attribute for this SAML integration.
    SamlConfigOptions -> Maybe Text
userAttribute :: Prelude.Maybe Prelude.Text,
    -- | The XML IdP metadata file generated from your identity provider.
    SamlConfigOptions -> Text
metadata :: Prelude.Text
  }
  deriving (SamlConfigOptions -> SamlConfigOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SamlConfigOptions -> SamlConfigOptions -> Bool
$c/= :: SamlConfigOptions -> SamlConfigOptions -> Bool
== :: SamlConfigOptions -> SamlConfigOptions -> Bool
$c== :: SamlConfigOptions -> SamlConfigOptions -> Bool
Prelude.Eq, ReadPrec [SamlConfigOptions]
ReadPrec SamlConfigOptions
Int -> ReadS SamlConfigOptions
ReadS [SamlConfigOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SamlConfigOptions]
$creadListPrec :: ReadPrec [SamlConfigOptions]
readPrec :: ReadPrec SamlConfigOptions
$creadPrec :: ReadPrec SamlConfigOptions
readList :: ReadS [SamlConfigOptions]
$creadList :: ReadS [SamlConfigOptions]
readsPrec :: Int -> ReadS SamlConfigOptions
$creadsPrec :: Int -> ReadS SamlConfigOptions
Prelude.Read, Int -> SamlConfigOptions -> ShowS
[SamlConfigOptions] -> ShowS
SamlConfigOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SamlConfigOptions] -> ShowS
$cshowList :: [SamlConfigOptions] -> ShowS
show :: SamlConfigOptions -> String
$cshow :: SamlConfigOptions -> String
showsPrec :: Int -> SamlConfigOptions -> ShowS
$cshowsPrec :: Int -> SamlConfigOptions -> ShowS
Prelude.Show, forall x. Rep SamlConfigOptions x -> SamlConfigOptions
forall x. SamlConfigOptions -> Rep SamlConfigOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SamlConfigOptions x -> SamlConfigOptions
$cfrom :: forall x. SamlConfigOptions -> Rep SamlConfigOptions x
Prelude.Generic)

-- |
-- Create a value of 'SamlConfigOptions' 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:
--
-- 'groupAttribute', 'samlConfigOptions_groupAttribute' - The group attribute for this SAML integration.
--
-- 'sessionTimeout', 'samlConfigOptions_sessionTimeout' - The session timeout, in minutes. Minimum is 15 minutes and maximum is
-- 1440 minutes (24 hours or 1 day). Default is 60 minutes.
--
-- 'userAttribute', 'samlConfigOptions_userAttribute' - A user attribute for this SAML integration.
--
-- 'metadata', 'samlConfigOptions_metadata' - The XML IdP metadata file generated from your identity provider.
newSamlConfigOptions ::
  -- | 'metadata'
  Prelude.Text ->
  SamlConfigOptions
newSamlConfigOptions :: Text -> SamlConfigOptions
newSamlConfigOptions Text
pMetadata_ =
  SamlConfigOptions'
    { $sel:groupAttribute:SamlConfigOptions' :: Maybe Text
groupAttribute =
        forall a. Maybe a
Prelude.Nothing,
      $sel:sessionTimeout:SamlConfigOptions' :: Maybe Natural
sessionTimeout = forall a. Maybe a
Prelude.Nothing,
      $sel:userAttribute:SamlConfigOptions' :: Maybe Text
userAttribute = forall a. Maybe a
Prelude.Nothing,
      $sel:metadata:SamlConfigOptions' :: Text
metadata = Text
pMetadata_
    }

-- | The group attribute for this SAML integration.
samlConfigOptions_groupAttribute :: Lens.Lens' SamlConfigOptions (Prelude.Maybe Prelude.Text)
samlConfigOptions_groupAttribute :: Lens' SamlConfigOptions (Maybe Text)
samlConfigOptions_groupAttribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamlConfigOptions' {Maybe Text
groupAttribute :: Maybe Text
$sel:groupAttribute:SamlConfigOptions' :: SamlConfigOptions -> Maybe Text
groupAttribute} -> Maybe Text
groupAttribute) (\s :: SamlConfigOptions
s@SamlConfigOptions' {} Maybe Text
a -> SamlConfigOptions
s {$sel:groupAttribute:SamlConfigOptions' :: Maybe Text
groupAttribute = Maybe Text
a} :: SamlConfigOptions)

-- | The session timeout, in minutes. Minimum is 15 minutes and maximum is
-- 1440 minutes (24 hours or 1 day). Default is 60 minutes.
samlConfigOptions_sessionTimeout :: Lens.Lens' SamlConfigOptions (Prelude.Maybe Prelude.Natural)
samlConfigOptions_sessionTimeout :: Lens' SamlConfigOptions (Maybe Natural)
samlConfigOptions_sessionTimeout = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamlConfigOptions' {Maybe Natural
sessionTimeout :: Maybe Natural
$sel:sessionTimeout:SamlConfigOptions' :: SamlConfigOptions -> Maybe Natural
sessionTimeout} -> Maybe Natural
sessionTimeout) (\s :: SamlConfigOptions
s@SamlConfigOptions' {} Maybe Natural
a -> SamlConfigOptions
s {$sel:sessionTimeout:SamlConfigOptions' :: Maybe Natural
sessionTimeout = Maybe Natural
a} :: SamlConfigOptions)

-- | A user attribute for this SAML integration.
samlConfigOptions_userAttribute :: Lens.Lens' SamlConfigOptions (Prelude.Maybe Prelude.Text)
samlConfigOptions_userAttribute :: Lens' SamlConfigOptions (Maybe Text)
samlConfigOptions_userAttribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamlConfigOptions' {Maybe Text
userAttribute :: Maybe Text
$sel:userAttribute:SamlConfigOptions' :: SamlConfigOptions -> Maybe Text
userAttribute} -> Maybe Text
userAttribute) (\s :: SamlConfigOptions
s@SamlConfigOptions' {} Maybe Text
a -> SamlConfigOptions
s {$sel:userAttribute:SamlConfigOptions' :: Maybe Text
userAttribute = Maybe Text
a} :: SamlConfigOptions)

-- | The XML IdP metadata file generated from your identity provider.
samlConfigOptions_metadata :: Lens.Lens' SamlConfigOptions Prelude.Text
samlConfigOptions_metadata :: Lens' SamlConfigOptions Text
samlConfigOptions_metadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamlConfigOptions' {Text
metadata :: Text
$sel:metadata:SamlConfigOptions' :: SamlConfigOptions -> Text
metadata} -> Text
metadata) (\s :: SamlConfigOptions
s@SamlConfigOptions' {} Text
a -> SamlConfigOptions
s {$sel:metadata:SamlConfigOptions' :: Text
metadata = Text
a} :: SamlConfigOptions)

instance Data.FromJSON SamlConfigOptions where
  parseJSON :: Value -> Parser SamlConfigOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SamlConfigOptions"
      ( \Object
x ->
          Maybe Text
-> Maybe Natural -> Maybe Text -> Text -> SamlConfigOptions
SamlConfigOptions'
            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
"groupAttribute")
            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
"sessionTimeout")
            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
"userAttribute")
            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
"metadata")
      )

instance Prelude.Hashable SamlConfigOptions where
  hashWithSalt :: Int -> SamlConfigOptions -> Int
hashWithSalt Int
_salt SamlConfigOptions' {Maybe Natural
Maybe Text
Text
metadata :: Text
userAttribute :: Maybe Text
sessionTimeout :: Maybe Natural
groupAttribute :: Maybe Text
$sel:metadata:SamlConfigOptions' :: SamlConfigOptions -> Text
$sel:userAttribute:SamlConfigOptions' :: SamlConfigOptions -> Maybe Text
$sel:sessionTimeout:SamlConfigOptions' :: SamlConfigOptions -> Maybe Natural
$sel:groupAttribute:SamlConfigOptions' :: SamlConfigOptions -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupAttribute
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
sessionTimeout
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userAttribute
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
metadata

instance Prelude.NFData SamlConfigOptions where
  rnf :: SamlConfigOptions -> ()
rnf SamlConfigOptions' {Maybe Natural
Maybe Text
Text
metadata :: Text
userAttribute :: Maybe Text
sessionTimeout :: Maybe Natural
groupAttribute :: Maybe Text
$sel:metadata:SamlConfigOptions' :: SamlConfigOptions -> Text
$sel:userAttribute:SamlConfigOptions' :: SamlConfigOptions -> Maybe Text
$sel:sessionTimeout:SamlConfigOptions' :: SamlConfigOptions -> Maybe Natural
$sel:groupAttribute:SamlConfigOptions' :: SamlConfigOptions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupAttribute
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
sessionTimeout
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userAttribute
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
metadata

instance Data.ToJSON SamlConfigOptions where
  toJSON :: SamlConfigOptions -> Value
toJSON SamlConfigOptions' {Maybe Natural
Maybe Text
Text
metadata :: Text
userAttribute :: Maybe Text
sessionTimeout :: Maybe Natural
groupAttribute :: Maybe Text
$sel:metadata:SamlConfigOptions' :: SamlConfigOptions -> Text
$sel:userAttribute:SamlConfigOptions' :: SamlConfigOptions -> Maybe Text
$sel:sessionTimeout:SamlConfigOptions' :: SamlConfigOptions -> Maybe Natural
$sel:groupAttribute:SamlConfigOptions' :: SamlConfigOptions -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"groupAttribute" 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
groupAttribute,
            (Key
"sessionTimeout" 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 Natural
sessionTimeout,
            (Key
"userAttribute" 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
userAttribute,
            forall a. a -> Maybe a
Prelude.Just (Key
"metadata" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
metadata)
          ]
      )