{-# 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.WorkSpaces.Types.SamlProperties
-- 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.WorkSpaces.Types.SamlProperties 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
import Amazonka.WorkSpaces.Types.SamlStatusEnum

-- | Describes the enablement status, user access URL, and relay state
-- parameter name that are used for configuring federation with an SAML 2.0
-- identity provider.
--
-- /See:/ 'newSamlProperties' smart constructor.
data SamlProperties = SamlProperties'
  { -- | The relay state parameter name supported by the SAML 2.0 identity
    -- provider (IdP). When the end user is redirected to the user access URL
    -- from the WorkSpaces client application, this relay state parameter name
    -- is appended as a query parameter to the URL along with the relay state
    -- endpoint to return the user to the client application session.
    --
    -- To use SAML 2.0 authentication with WorkSpaces, the IdP must support
    -- IdP-initiated deep linking for the relay state URL. Consult your IdP
    -- documentation for more information.
    SamlProperties -> Maybe Text
relayStateParameterName :: Prelude.Maybe Prelude.Text,
    -- | Indicates the status of SAML 2.0 authentication. These statuses include
    -- the following.
    --
    -- -   If the setting is @DISABLED@, end users will be directed to login
    --     with their directory credentials.
    --
    -- -   If the setting is @ENABLED@, end users will be directed to login via
    --     the user access URL. Users attempting to connect to WorkSpaces from
    --     a client application that does not support SAML 2.0 authentication
    --     will not be able to connect.
    --
    -- -   If the setting is @ENABLED_WITH_DIRECTORY_LOGIN_FALLBACK@, end users
    --     will be directed to login via the user access URL on supported
    --     client applications, but will not prevent clients that do not
    --     support SAML 2.0 authentication from connecting as if SAML 2.0
    --     authentication was disabled.
    SamlProperties -> Maybe SamlStatusEnum
status :: Prelude.Maybe SamlStatusEnum,
    -- | The SAML 2.0 identity provider (IdP) user access URL is the URL a user
    -- would navigate to in their web browser in order to federate from the IdP
    -- and directly access the application, without any SAML 2.0 service
    -- provider (SP) bindings.
    SamlProperties -> Maybe Text
userAccessUrl :: Prelude.Maybe Prelude.Text
  }
  deriving (SamlProperties -> SamlProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SamlProperties -> SamlProperties -> Bool
$c/= :: SamlProperties -> SamlProperties -> Bool
== :: SamlProperties -> SamlProperties -> Bool
$c== :: SamlProperties -> SamlProperties -> Bool
Prelude.Eq, ReadPrec [SamlProperties]
ReadPrec SamlProperties
Int -> ReadS SamlProperties
ReadS [SamlProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SamlProperties]
$creadListPrec :: ReadPrec [SamlProperties]
readPrec :: ReadPrec SamlProperties
$creadPrec :: ReadPrec SamlProperties
readList :: ReadS [SamlProperties]
$creadList :: ReadS [SamlProperties]
readsPrec :: Int -> ReadS SamlProperties
$creadsPrec :: Int -> ReadS SamlProperties
Prelude.Read, Int -> SamlProperties -> ShowS
[SamlProperties] -> ShowS
SamlProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SamlProperties] -> ShowS
$cshowList :: [SamlProperties] -> ShowS
show :: SamlProperties -> String
$cshow :: SamlProperties -> String
showsPrec :: Int -> SamlProperties -> ShowS
$cshowsPrec :: Int -> SamlProperties -> ShowS
Prelude.Show, forall x. Rep SamlProperties x -> SamlProperties
forall x. SamlProperties -> Rep SamlProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SamlProperties x -> SamlProperties
$cfrom :: forall x. SamlProperties -> Rep SamlProperties x
Prelude.Generic)

-- |
-- Create a value of 'SamlProperties' 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:
--
-- 'relayStateParameterName', 'samlProperties_relayStateParameterName' - The relay state parameter name supported by the SAML 2.0 identity
-- provider (IdP). When the end user is redirected to the user access URL
-- from the WorkSpaces client application, this relay state parameter name
-- is appended as a query parameter to the URL along with the relay state
-- endpoint to return the user to the client application session.
--
-- To use SAML 2.0 authentication with WorkSpaces, the IdP must support
-- IdP-initiated deep linking for the relay state URL. Consult your IdP
-- documentation for more information.
--
-- 'status', 'samlProperties_status' - Indicates the status of SAML 2.0 authentication. These statuses include
-- the following.
--
-- -   If the setting is @DISABLED@, end users will be directed to login
--     with their directory credentials.
--
-- -   If the setting is @ENABLED@, end users will be directed to login via
--     the user access URL. Users attempting to connect to WorkSpaces from
--     a client application that does not support SAML 2.0 authentication
--     will not be able to connect.
--
-- -   If the setting is @ENABLED_WITH_DIRECTORY_LOGIN_FALLBACK@, end users
--     will be directed to login via the user access URL on supported
--     client applications, but will not prevent clients that do not
--     support SAML 2.0 authentication from connecting as if SAML 2.0
--     authentication was disabled.
--
-- 'userAccessUrl', 'samlProperties_userAccessUrl' - The SAML 2.0 identity provider (IdP) user access URL is the URL a user
-- would navigate to in their web browser in order to federate from the IdP
-- and directly access the application, without any SAML 2.0 service
-- provider (SP) bindings.
newSamlProperties ::
  SamlProperties
newSamlProperties :: SamlProperties
newSamlProperties =
  SamlProperties'
    { $sel:relayStateParameterName:SamlProperties' :: Maybe Text
relayStateParameterName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:status:SamlProperties' :: Maybe SamlStatusEnum
status = forall a. Maybe a
Prelude.Nothing,
      $sel:userAccessUrl:SamlProperties' :: Maybe Text
userAccessUrl = forall a. Maybe a
Prelude.Nothing
    }

-- | The relay state parameter name supported by the SAML 2.0 identity
-- provider (IdP). When the end user is redirected to the user access URL
-- from the WorkSpaces client application, this relay state parameter name
-- is appended as a query parameter to the URL along with the relay state
-- endpoint to return the user to the client application session.
--
-- To use SAML 2.0 authentication with WorkSpaces, the IdP must support
-- IdP-initiated deep linking for the relay state URL. Consult your IdP
-- documentation for more information.
samlProperties_relayStateParameterName :: Lens.Lens' SamlProperties (Prelude.Maybe Prelude.Text)
samlProperties_relayStateParameterName :: Lens' SamlProperties (Maybe Text)
samlProperties_relayStateParameterName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamlProperties' {Maybe Text
relayStateParameterName :: Maybe Text
$sel:relayStateParameterName:SamlProperties' :: SamlProperties -> Maybe Text
relayStateParameterName} -> Maybe Text
relayStateParameterName) (\s :: SamlProperties
s@SamlProperties' {} Maybe Text
a -> SamlProperties
s {$sel:relayStateParameterName:SamlProperties' :: Maybe Text
relayStateParameterName = Maybe Text
a} :: SamlProperties)

-- | Indicates the status of SAML 2.0 authentication. These statuses include
-- the following.
--
-- -   If the setting is @DISABLED@, end users will be directed to login
--     with their directory credentials.
--
-- -   If the setting is @ENABLED@, end users will be directed to login via
--     the user access URL. Users attempting to connect to WorkSpaces from
--     a client application that does not support SAML 2.0 authentication
--     will not be able to connect.
--
-- -   If the setting is @ENABLED_WITH_DIRECTORY_LOGIN_FALLBACK@, end users
--     will be directed to login via the user access URL on supported
--     client applications, but will not prevent clients that do not
--     support SAML 2.0 authentication from connecting as if SAML 2.0
--     authentication was disabled.
samlProperties_status :: Lens.Lens' SamlProperties (Prelude.Maybe SamlStatusEnum)
samlProperties_status :: Lens' SamlProperties (Maybe SamlStatusEnum)
samlProperties_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamlProperties' {Maybe SamlStatusEnum
status :: Maybe SamlStatusEnum
$sel:status:SamlProperties' :: SamlProperties -> Maybe SamlStatusEnum
status} -> Maybe SamlStatusEnum
status) (\s :: SamlProperties
s@SamlProperties' {} Maybe SamlStatusEnum
a -> SamlProperties
s {$sel:status:SamlProperties' :: Maybe SamlStatusEnum
status = Maybe SamlStatusEnum
a} :: SamlProperties)

-- | The SAML 2.0 identity provider (IdP) user access URL is the URL a user
-- would navigate to in their web browser in order to federate from the IdP
-- and directly access the application, without any SAML 2.0 service
-- provider (SP) bindings.
samlProperties_userAccessUrl :: Lens.Lens' SamlProperties (Prelude.Maybe Prelude.Text)
samlProperties_userAccessUrl :: Lens' SamlProperties (Maybe Text)
samlProperties_userAccessUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamlProperties' {Maybe Text
userAccessUrl :: Maybe Text
$sel:userAccessUrl:SamlProperties' :: SamlProperties -> Maybe Text
userAccessUrl} -> Maybe Text
userAccessUrl) (\s :: SamlProperties
s@SamlProperties' {} Maybe Text
a -> SamlProperties
s {$sel:userAccessUrl:SamlProperties' :: Maybe Text
userAccessUrl = Maybe Text
a} :: SamlProperties)

instance Data.FromJSON SamlProperties where
  parseJSON :: Value -> Parser SamlProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SamlProperties"
      ( \Object
x ->
          Maybe Text -> Maybe SamlStatusEnum -> Maybe Text -> SamlProperties
SamlProperties'
            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
"RelayStateParameterName")
            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
"Status")
            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
"UserAccessUrl")
      )

instance Prelude.Hashable SamlProperties where
  hashWithSalt :: Int -> SamlProperties -> Int
hashWithSalt Int
_salt SamlProperties' {Maybe Text
Maybe SamlStatusEnum
userAccessUrl :: Maybe Text
status :: Maybe SamlStatusEnum
relayStateParameterName :: Maybe Text
$sel:userAccessUrl:SamlProperties' :: SamlProperties -> Maybe Text
$sel:status:SamlProperties' :: SamlProperties -> Maybe SamlStatusEnum
$sel:relayStateParameterName:SamlProperties' :: SamlProperties -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
relayStateParameterName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SamlStatusEnum
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userAccessUrl

instance Prelude.NFData SamlProperties where
  rnf :: SamlProperties -> ()
rnf SamlProperties' {Maybe Text
Maybe SamlStatusEnum
userAccessUrl :: Maybe Text
status :: Maybe SamlStatusEnum
relayStateParameterName :: Maybe Text
$sel:userAccessUrl:SamlProperties' :: SamlProperties -> Maybe Text
$sel:status:SamlProperties' :: SamlProperties -> Maybe SamlStatusEnum
$sel:relayStateParameterName:SamlProperties' :: SamlProperties -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
relayStateParameterName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SamlStatusEnum
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userAccessUrl

instance Data.ToJSON SamlProperties where
  toJSON :: SamlProperties -> Value
toJSON SamlProperties' {Maybe Text
Maybe SamlStatusEnum
userAccessUrl :: Maybe Text
status :: Maybe SamlStatusEnum
relayStateParameterName :: Maybe Text
$sel:userAccessUrl:SamlProperties' :: SamlProperties -> Maybe Text
$sel:status:SamlProperties' :: SamlProperties -> Maybe SamlStatusEnum
$sel:relayStateParameterName:SamlProperties' :: SamlProperties -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RelayStateParameterName" 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
relayStateParameterName,
            (Key
"Status" 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 SamlStatusEnum
status,
            (Key
"UserAccessUrl" 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
userAccessUrl
          ]
      )