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

-- | Specifies the SAML Identity Provider\'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
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]
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
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. 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'
    { $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 :: Lens' SAMLIdp Text
sAMLIdp_metadataContent = 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 :: Lens' SAMLIdp Text
sAMLIdp_entityId = 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 Data.FromJSON SAMLIdp where
  parseJSON :: Value -> Parser SAMLIdp
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SAMLIdp"
      ( \Object
x ->
          Text -> Text -> SAMLIdp
SAMLIdp'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MetadataContent")
            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
"EntityId")
      )

instance Prelude.Hashable SAMLIdp where
  hashWithSalt :: Int -> SAMLIdp -> Int
hashWithSalt Int
_salt SAMLIdp' {Text
entityId :: Text
metadataContent :: Text
$sel:entityId:SAMLIdp' :: SAMLIdp -> Text
$sel:metadataContent:SAMLIdp' :: SAMLIdp -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
metadataContent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entityId

instance Prelude.NFData SAMLIdp where
  rnf :: SAMLIdp -> ()
rnf SAMLIdp' {Text
entityId :: Text
metadataContent :: Text
$sel:entityId:SAMLIdp' :: SAMLIdp -> Text
$sel:metadataContent:SAMLIdp' :: SAMLIdp -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
metadataContent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
entityId

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"MetadataContent" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
metadataContent),
            forall a. a -> Maybe a
Prelude.Just (Key
"EntityId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
entityId)
          ]
      )