{-# 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.FinSpace.Types.FederationParameters
-- 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.FinSpace.Types.FederationParameters where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration information when authentication mode is FEDERATED.
--
-- /See:/ 'newFederationParameters' smart constructor.
data FederationParameters = FederationParameters'
  { -- | Provide the metadata URL from your SAML 2.0 compliant identity provider
    -- (IdP).
    FederationParameters -> Maybe Text
samlMetadataURL :: Prelude.Maybe Prelude.Text,
    -- | The redirect or sign-in URL that should be entered into the SAML 2.0
    -- compliant identity provider configuration (IdP).
    FederationParameters -> Maybe Text
applicationCallBackURL :: Prelude.Maybe Prelude.Text,
    -- | The Uniform Resource Name (URN). Also referred as Service Provider URN
    -- or Audience URI or Service Provider Entity ID.
    FederationParameters -> Maybe Text
federationURN :: Prelude.Maybe Prelude.Text,
    -- | SAML attribute name and value. The name must always be @Email@ and the
    -- value should be set to the attribute definition in which user email is
    -- set. For example, name would be @Email@ and value
    -- @http:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/emailaddress@.
    -- Please check your SAML 2.0 compliant identity provider (IdP)
    -- documentation for details.
    FederationParameters -> Maybe (HashMap Text Text)
attributeMap :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Name of the identity provider (IdP).
    FederationParameters -> Maybe Text
federationProviderName :: Prelude.Maybe Prelude.Text,
    -- | SAML 2.0 Metadata document from identity provider (IdP).
    FederationParameters -> Maybe Text
samlMetadataDocument :: Prelude.Maybe Prelude.Text
  }
  deriving (FederationParameters -> FederationParameters -> Bool
(FederationParameters -> FederationParameters -> Bool)
-> (FederationParameters -> FederationParameters -> Bool)
-> Eq FederationParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FederationParameters -> FederationParameters -> Bool
$c/= :: FederationParameters -> FederationParameters -> Bool
== :: FederationParameters -> FederationParameters -> Bool
$c== :: FederationParameters -> FederationParameters -> Bool
Prelude.Eq, ReadPrec [FederationParameters]
ReadPrec FederationParameters
Int -> ReadS FederationParameters
ReadS [FederationParameters]
(Int -> ReadS FederationParameters)
-> ReadS [FederationParameters]
-> ReadPrec FederationParameters
-> ReadPrec [FederationParameters]
-> Read FederationParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FederationParameters]
$creadListPrec :: ReadPrec [FederationParameters]
readPrec :: ReadPrec FederationParameters
$creadPrec :: ReadPrec FederationParameters
readList :: ReadS [FederationParameters]
$creadList :: ReadS [FederationParameters]
readsPrec :: Int -> ReadS FederationParameters
$creadsPrec :: Int -> ReadS FederationParameters
Prelude.Read, Int -> FederationParameters -> ShowS
[FederationParameters] -> ShowS
FederationParameters -> String
(Int -> FederationParameters -> ShowS)
-> (FederationParameters -> String)
-> ([FederationParameters] -> ShowS)
-> Show FederationParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FederationParameters] -> ShowS
$cshowList :: [FederationParameters] -> ShowS
show :: FederationParameters -> String
$cshow :: FederationParameters -> String
showsPrec :: Int -> FederationParameters -> ShowS
$cshowsPrec :: Int -> FederationParameters -> ShowS
Prelude.Show, (forall x. FederationParameters -> Rep FederationParameters x)
-> (forall x. Rep FederationParameters x -> FederationParameters)
-> Generic FederationParameters
forall x. Rep FederationParameters x -> FederationParameters
forall x. FederationParameters -> Rep FederationParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FederationParameters x -> FederationParameters
$cfrom :: forall x. FederationParameters -> Rep FederationParameters x
Prelude.Generic)

-- |
-- Create a value of 'FederationParameters' 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:
--
-- 'samlMetadataURL', 'federationParameters_samlMetadataURL' - Provide the metadata URL from your SAML 2.0 compliant identity provider
-- (IdP).
--
-- 'applicationCallBackURL', 'federationParameters_applicationCallBackURL' - The redirect or sign-in URL that should be entered into the SAML 2.0
-- compliant identity provider configuration (IdP).
--
-- 'federationURN', 'federationParameters_federationURN' - The Uniform Resource Name (URN). Also referred as Service Provider URN
-- or Audience URI or Service Provider Entity ID.
--
-- 'attributeMap', 'federationParameters_attributeMap' - SAML attribute name and value. The name must always be @Email@ and the
-- value should be set to the attribute definition in which user email is
-- set. For example, name would be @Email@ and value
-- @http:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/emailaddress@.
-- Please check your SAML 2.0 compliant identity provider (IdP)
-- documentation for details.
--
-- 'federationProviderName', 'federationParameters_federationProviderName' - Name of the identity provider (IdP).
--
-- 'samlMetadataDocument', 'federationParameters_samlMetadataDocument' - SAML 2.0 Metadata document from identity provider (IdP).
newFederationParameters ::
  FederationParameters
newFederationParameters :: FederationParameters
newFederationParameters =
  FederationParameters' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> FederationParameters
FederationParameters'
    { $sel:samlMetadataURL:FederationParameters' :: Maybe Text
samlMetadataURL =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationCallBackURL:FederationParameters' :: Maybe Text
applicationCallBackURL = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:federationURN:FederationParameters' :: Maybe Text
federationURN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeMap:FederationParameters' :: Maybe (HashMap Text Text)
attributeMap = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:federationProviderName:FederationParameters' :: Maybe Text
federationProviderName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:samlMetadataDocument:FederationParameters' :: Maybe Text
samlMetadataDocument = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Provide the metadata URL from your SAML 2.0 compliant identity provider
-- (IdP).
federationParameters_samlMetadataURL :: Lens.Lens' FederationParameters (Prelude.Maybe Prelude.Text)
federationParameters_samlMetadataURL :: (Maybe Text -> f (Maybe Text))
-> FederationParameters -> f FederationParameters
federationParameters_samlMetadataURL = (FederationParameters -> Maybe Text)
-> (FederationParameters -> Maybe Text -> FederationParameters)
-> Lens
     FederationParameters FederationParameters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederationParameters' {Maybe Text
samlMetadataURL :: Maybe Text
$sel:samlMetadataURL:FederationParameters' :: FederationParameters -> Maybe Text
samlMetadataURL} -> Maybe Text
samlMetadataURL) (\s :: FederationParameters
s@FederationParameters' {} Maybe Text
a -> FederationParameters
s {$sel:samlMetadataURL:FederationParameters' :: Maybe Text
samlMetadataURL = Maybe Text
a} :: FederationParameters)

-- | The redirect or sign-in URL that should be entered into the SAML 2.0
-- compliant identity provider configuration (IdP).
federationParameters_applicationCallBackURL :: Lens.Lens' FederationParameters (Prelude.Maybe Prelude.Text)
federationParameters_applicationCallBackURL :: (Maybe Text -> f (Maybe Text))
-> FederationParameters -> f FederationParameters
federationParameters_applicationCallBackURL = (FederationParameters -> Maybe Text)
-> (FederationParameters -> Maybe Text -> FederationParameters)
-> Lens
     FederationParameters FederationParameters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederationParameters' {Maybe Text
applicationCallBackURL :: Maybe Text
$sel:applicationCallBackURL:FederationParameters' :: FederationParameters -> Maybe Text
applicationCallBackURL} -> Maybe Text
applicationCallBackURL) (\s :: FederationParameters
s@FederationParameters' {} Maybe Text
a -> FederationParameters
s {$sel:applicationCallBackURL:FederationParameters' :: Maybe Text
applicationCallBackURL = Maybe Text
a} :: FederationParameters)

-- | The Uniform Resource Name (URN). Also referred as Service Provider URN
-- or Audience URI or Service Provider Entity ID.
federationParameters_federationURN :: Lens.Lens' FederationParameters (Prelude.Maybe Prelude.Text)
federationParameters_federationURN :: (Maybe Text -> f (Maybe Text))
-> FederationParameters -> f FederationParameters
federationParameters_federationURN = (FederationParameters -> Maybe Text)
-> (FederationParameters -> Maybe Text -> FederationParameters)
-> Lens
     FederationParameters FederationParameters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederationParameters' {Maybe Text
federationURN :: Maybe Text
$sel:federationURN:FederationParameters' :: FederationParameters -> Maybe Text
federationURN} -> Maybe Text
federationURN) (\s :: FederationParameters
s@FederationParameters' {} Maybe Text
a -> FederationParameters
s {$sel:federationURN:FederationParameters' :: Maybe Text
federationURN = Maybe Text
a} :: FederationParameters)

-- | SAML attribute name and value. The name must always be @Email@ and the
-- value should be set to the attribute definition in which user email is
-- set. For example, name would be @Email@ and value
-- @http:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/emailaddress@.
-- Please check your SAML 2.0 compliant identity provider (IdP)
-- documentation for details.
federationParameters_attributeMap :: Lens.Lens' FederationParameters (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
federationParameters_attributeMap :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> FederationParameters -> f FederationParameters
federationParameters_attributeMap = (FederationParameters -> Maybe (HashMap Text Text))
-> (FederationParameters
    -> Maybe (HashMap Text Text) -> FederationParameters)
-> Lens
     FederationParameters
     FederationParameters
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederationParameters' {Maybe (HashMap Text Text)
attributeMap :: Maybe (HashMap Text Text)
$sel:attributeMap:FederationParameters' :: FederationParameters -> Maybe (HashMap Text Text)
attributeMap} -> Maybe (HashMap Text Text)
attributeMap) (\s :: FederationParameters
s@FederationParameters' {} Maybe (HashMap Text Text)
a -> FederationParameters
s {$sel:attributeMap:FederationParameters' :: Maybe (HashMap Text Text)
attributeMap = Maybe (HashMap Text Text)
a} :: FederationParameters) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> FederationParameters -> f FederationParameters)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> FederationParameters
-> f FederationParameters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Name of the identity provider (IdP).
federationParameters_federationProviderName :: Lens.Lens' FederationParameters (Prelude.Maybe Prelude.Text)
federationParameters_federationProviderName :: (Maybe Text -> f (Maybe Text))
-> FederationParameters -> f FederationParameters
federationParameters_federationProviderName = (FederationParameters -> Maybe Text)
-> (FederationParameters -> Maybe Text -> FederationParameters)
-> Lens
     FederationParameters FederationParameters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederationParameters' {Maybe Text
federationProviderName :: Maybe Text
$sel:federationProviderName:FederationParameters' :: FederationParameters -> Maybe Text
federationProviderName} -> Maybe Text
federationProviderName) (\s :: FederationParameters
s@FederationParameters' {} Maybe Text
a -> FederationParameters
s {$sel:federationProviderName:FederationParameters' :: Maybe Text
federationProviderName = Maybe Text
a} :: FederationParameters)

-- | SAML 2.0 Metadata document from identity provider (IdP).
federationParameters_samlMetadataDocument :: Lens.Lens' FederationParameters (Prelude.Maybe Prelude.Text)
federationParameters_samlMetadataDocument :: (Maybe Text -> f (Maybe Text))
-> FederationParameters -> f FederationParameters
federationParameters_samlMetadataDocument = (FederationParameters -> Maybe Text)
-> (FederationParameters -> Maybe Text -> FederationParameters)
-> Lens
     FederationParameters FederationParameters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FederationParameters' {Maybe Text
samlMetadataDocument :: Maybe Text
$sel:samlMetadataDocument:FederationParameters' :: FederationParameters -> Maybe Text
samlMetadataDocument} -> Maybe Text
samlMetadataDocument) (\s :: FederationParameters
s@FederationParameters' {} Maybe Text
a -> FederationParameters
s {$sel:samlMetadataDocument:FederationParameters' :: Maybe Text
samlMetadataDocument = Maybe Text
a} :: FederationParameters)

instance Core.FromJSON FederationParameters where
  parseJSON :: Value -> Parser FederationParameters
parseJSON =
    String
-> (Object -> Parser FederationParameters)
-> Value
-> Parser FederationParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FederationParameters"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> FederationParameters
FederationParameters'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe Text
 -> Maybe Text
 -> FederationParameters)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe Text
      -> FederationParameters)
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
"samlMetadataURL")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe Text
   -> FederationParameters)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe Text
      -> FederationParameters)
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
"applicationCallBackURL")
            Parser
  (Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe Text
   -> FederationParameters)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe Text -> Maybe Text -> FederationParameters)
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
"federationURN")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe Text -> Maybe Text -> FederationParameters)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Maybe Text -> Maybe Text -> FederationParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributeMap" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> FederationParameters)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> FederationParameters)
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
"federationProviderName")
            Parser (Maybe Text -> FederationParameters)
-> Parser (Maybe Text) -> Parser FederationParameters
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
"samlMetadataDocument")
      )

instance Prelude.Hashable FederationParameters

instance Prelude.NFData FederationParameters

instance Core.ToJSON FederationParameters where
  toJSON :: FederationParameters -> Value
toJSON FederationParameters' {Maybe Text
Maybe (HashMap Text Text)
samlMetadataDocument :: Maybe Text
federationProviderName :: Maybe Text
attributeMap :: Maybe (HashMap Text Text)
federationURN :: Maybe Text
applicationCallBackURL :: Maybe Text
samlMetadataURL :: Maybe Text
$sel:samlMetadataDocument:FederationParameters' :: FederationParameters -> Maybe Text
$sel:federationProviderName:FederationParameters' :: FederationParameters -> Maybe Text
$sel:attributeMap:FederationParameters' :: FederationParameters -> Maybe (HashMap Text Text)
$sel:federationURN:FederationParameters' :: FederationParameters -> Maybe Text
$sel:applicationCallBackURL:FederationParameters' :: FederationParameters -> Maybe Text
$sel:samlMetadataURL:FederationParameters' :: FederationParameters -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"samlMetadataURL" 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
samlMetadataURL,
            (Text
"applicationCallBackURL" 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
applicationCallBackURL,
            (Text
"federationURN" 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
federationURN,
            (Text
"attributeMap" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
attributeMap,
            (Text
"federationProviderName" 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
federationProviderName,
            (Text
"samlMetadataDocument" 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
samlMetadataDocument
          ]
      )