{-# 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.SAMLIdp
-- 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.SAMLIdp where

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

-- | The SAML identity povider\'s information.
--
-- /See:/ 'newSAMLIdp' smart constructor.
data SAMLIdp = SAMLIdp'
  { -- | The metadata of the SAML application in XML format.
    SAMLIdp -> Text
metadataContent :: Prelude.Text,
    -- | The unique entity ID of the application in SAML identity provider.
    SAMLIdp -> Text
entityId :: Prelude.Text
  }
  deriving (SAMLIdp -> SAMLIdp -> Bool
(SAMLIdp -> SAMLIdp -> Bool)
-> (SAMLIdp -> SAMLIdp -> Bool) -> Eq SAMLIdp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SAMLIdp -> SAMLIdp -> Bool
$c/= :: SAMLIdp -> SAMLIdp -> Bool
== :: SAMLIdp -> SAMLIdp -> Bool
$c== :: SAMLIdp -> SAMLIdp -> Bool
Prelude.Eq, ReadPrec [SAMLIdp]
ReadPrec SAMLIdp
Int -> ReadS SAMLIdp
ReadS [SAMLIdp]
(Int -> ReadS SAMLIdp)
-> ReadS [SAMLIdp]
-> ReadPrec SAMLIdp
-> ReadPrec [SAMLIdp]
-> Read SAMLIdp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SAMLIdp]
$creadListPrec :: ReadPrec [SAMLIdp]
readPrec :: ReadPrec SAMLIdp
$creadPrec :: ReadPrec SAMLIdp
readList :: ReadS [SAMLIdp]
$creadList :: ReadS [SAMLIdp]
readsPrec :: Int -> ReadS SAMLIdp
$creadsPrec :: Int -> ReadS SAMLIdp
Prelude.Read, Int -> SAMLIdp -> ShowS
[SAMLIdp] -> ShowS
SAMLIdp -> String
(Int -> SAMLIdp -> ShowS)
-> (SAMLIdp -> String) -> ([SAMLIdp] -> ShowS) -> Show SAMLIdp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SAMLIdp] -> ShowS
$cshowList :: [SAMLIdp] -> ShowS
show :: SAMLIdp -> String
$cshow :: SAMLIdp -> String
showsPrec :: Int -> SAMLIdp -> ShowS
$cshowsPrec :: Int -> SAMLIdp -> ShowS
Prelude.Show, (forall x. SAMLIdp -> Rep SAMLIdp x)
-> (forall x. Rep SAMLIdp x -> SAMLIdp) -> Generic SAMLIdp
forall x. Rep SAMLIdp x -> SAMLIdp
forall x. SAMLIdp -> Rep SAMLIdp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SAMLIdp x -> SAMLIdp
$cfrom :: forall x. SAMLIdp -> Rep SAMLIdp x
Prelude.Generic)

-- |
-- Create a value of 'SAMLIdp' 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:
--
-- 'metadataContent', 'sAMLIdp_metadataContent' - The metadata of the SAML application in XML format.
--
-- 'entityId', 'sAMLIdp_entityId' - The unique entity ID of the application in SAML identity provider.
newSAMLIdp ::
  -- | 'metadataContent'
  Prelude.Text ->
  -- | 'entityId'
  Prelude.Text ->
  SAMLIdp
newSAMLIdp :: Text -> Text -> SAMLIdp
newSAMLIdp Text
pMetadataContent_ Text
pEntityId_ =
  SAMLIdp' :: Text -> Text -> SAMLIdp
SAMLIdp'
    { $sel:metadataContent:SAMLIdp' :: Text
metadataContent = Text
pMetadataContent_,
      $sel:entityId:SAMLIdp' :: Text
entityId = Text
pEntityId_
    }

-- | The metadata of the SAML application in XML format.
sAMLIdp_metadataContent :: Lens.Lens' SAMLIdp Prelude.Text
sAMLIdp_metadataContent :: (Text -> f Text) -> SAMLIdp -> f SAMLIdp
sAMLIdp_metadataContent = (SAMLIdp -> Text)
-> (SAMLIdp -> Text -> SAMLIdp) -> Lens SAMLIdp SAMLIdp Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SAMLIdp' {Text
metadataContent :: Text
$sel:metadataContent:SAMLIdp' :: SAMLIdp -> Text
metadataContent} -> Text
metadataContent) (\s :: SAMLIdp
s@SAMLIdp' {} Text
a -> SAMLIdp
s {$sel:metadataContent:SAMLIdp' :: Text
metadataContent = Text
a} :: SAMLIdp)

-- | The unique entity ID of the application in SAML identity provider.
sAMLIdp_entityId :: Lens.Lens' SAMLIdp Prelude.Text
sAMLIdp_entityId :: (Text -> f Text) -> SAMLIdp -> f SAMLIdp
sAMLIdp_entityId = (SAMLIdp -> Text)
-> (SAMLIdp -> Text -> SAMLIdp) -> Lens SAMLIdp SAMLIdp Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SAMLIdp' {Text
entityId :: Text
$sel:entityId:SAMLIdp' :: SAMLIdp -> Text
entityId} -> Text
entityId) (\s :: SAMLIdp
s@SAMLIdp' {} Text
a -> SAMLIdp
s {$sel:entityId:SAMLIdp' :: Text
entityId = Text
a} :: SAMLIdp)

instance Core.FromJSON SAMLIdp where
  parseJSON :: Value -> Parser SAMLIdp
parseJSON =
    String -> (Object -> Parser SAMLIdp) -> Value -> Parser SAMLIdp
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SAMLIdp"
      ( \Object
x ->
          Text -> Text -> SAMLIdp
SAMLIdp'
            (Text -> Text -> SAMLIdp)
-> Parser Text -> Parser (Text -> SAMLIdp)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MetadataContent")
            Parser (Text -> SAMLIdp) -> Parser Text -> Parser SAMLIdp
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EntityId")
      )

instance Prelude.Hashable SAMLIdp

instance Prelude.NFData SAMLIdp

instance Core.ToJSON SAMLIdp where
  toJSON :: SAMLIdp -> Value
toJSON SAMLIdp' {Text
entityId :: Text
metadataContent :: Text
$sel:entityId:SAMLIdp' :: SAMLIdp -> Text
$sel:metadataContent:SAMLIdp' :: SAMLIdp -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"MetadataContent" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
metadataContent),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EntityId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
entityId)
          ]
      )