{-# 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.SageMaker.Types.CognitoConfig
-- 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.SageMaker.Types.CognitoConfig 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

-- | Use this parameter to configure your Amazon Cognito workforce. A single
-- Cognito workforce is created using and corresponds to a single
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html Amazon Cognito user pool>.
--
-- /See:/ 'newCognitoConfig' smart constructor.
data CognitoConfig = CognitoConfig'
  { -- | A
    -- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html user pool>
    -- is a user directory in Amazon Cognito. With a user pool, your users can
    -- sign in to your web or mobile app through Amazon Cognito. Your users can
    -- also sign in through social identity providers like Google, Facebook,
    -- Amazon, or Apple, and through SAML identity providers.
    CognitoConfig -> Text
userPool :: Prelude.Text,
    -- | The client ID for your Amazon Cognito user pool.
    CognitoConfig -> Text
clientId :: Prelude.Text
  }
  deriving (CognitoConfig -> CognitoConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CognitoConfig -> CognitoConfig -> Bool
$c/= :: CognitoConfig -> CognitoConfig -> Bool
== :: CognitoConfig -> CognitoConfig -> Bool
$c== :: CognitoConfig -> CognitoConfig -> Bool
Prelude.Eq, ReadPrec [CognitoConfig]
ReadPrec CognitoConfig
Int -> ReadS CognitoConfig
ReadS [CognitoConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CognitoConfig]
$creadListPrec :: ReadPrec [CognitoConfig]
readPrec :: ReadPrec CognitoConfig
$creadPrec :: ReadPrec CognitoConfig
readList :: ReadS [CognitoConfig]
$creadList :: ReadS [CognitoConfig]
readsPrec :: Int -> ReadS CognitoConfig
$creadsPrec :: Int -> ReadS CognitoConfig
Prelude.Read, Int -> CognitoConfig -> ShowS
[CognitoConfig] -> ShowS
CognitoConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CognitoConfig] -> ShowS
$cshowList :: [CognitoConfig] -> ShowS
show :: CognitoConfig -> String
$cshow :: CognitoConfig -> String
showsPrec :: Int -> CognitoConfig -> ShowS
$cshowsPrec :: Int -> CognitoConfig -> ShowS
Prelude.Show, forall x. Rep CognitoConfig x -> CognitoConfig
forall x. CognitoConfig -> Rep CognitoConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CognitoConfig x -> CognitoConfig
$cfrom :: forall x. CognitoConfig -> Rep CognitoConfig x
Prelude.Generic)

-- |
-- Create a value of 'CognitoConfig' 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:
--
-- 'userPool', 'cognitoConfig_userPool' - A
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html user pool>
-- is a user directory in Amazon Cognito. With a user pool, your users can
-- sign in to your web or mobile app through Amazon Cognito. Your users can
-- also sign in through social identity providers like Google, Facebook,
-- Amazon, or Apple, and through SAML identity providers.
--
-- 'clientId', 'cognitoConfig_clientId' - The client ID for your Amazon Cognito user pool.
newCognitoConfig ::
  -- | 'userPool'
  Prelude.Text ->
  -- | 'clientId'
  Prelude.Text ->
  CognitoConfig
newCognitoConfig :: Text -> Text -> CognitoConfig
newCognitoConfig Text
pUserPool_ Text
pClientId_ =
  CognitoConfig'
    { $sel:userPool:CognitoConfig' :: Text
userPool = Text
pUserPool_,
      $sel:clientId:CognitoConfig' :: Text
clientId = Text
pClientId_
    }

-- | A
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html user pool>
-- is a user directory in Amazon Cognito. With a user pool, your users can
-- sign in to your web or mobile app through Amazon Cognito. Your users can
-- also sign in through social identity providers like Google, Facebook,
-- Amazon, or Apple, and through SAML identity providers.
cognitoConfig_userPool :: Lens.Lens' CognitoConfig Prelude.Text
cognitoConfig_userPool :: Lens' CognitoConfig Text
cognitoConfig_userPool = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CognitoConfig' {Text
userPool :: Text
$sel:userPool:CognitoConfig' :: CognitoConfig -> Text
userPool} -> Text
userPool) (\s :: CognitoConfig
s@CognitoConfig' {} Text
a -> CognitoConfig
s {$sel:userPool:CognitoConfig' :: Text
userPool = Text
a} :: CognitoConfig)

-- | The client ID for your Amazon Cognito user pool.
cognitoConfig_clientId :: Lens.Lens' CognitoConfig Prelude.Text
cognitoConfig_clientId :: Lens' CognitoConfig Text
cognitoConfig_clientId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CognitoConfig' {Text
clientId :: Text
$sel:clientId:CognitoConfig' :: CognitoConfig -> Text
clientId} -> Text
clientId) (\s :: CognitoConfig
s@CognitoConfig' {} Text
a -> CognitoConfig
s {$sel:clientId:CognitoConfig' :: Text
clientId = Text
a} :: CognitoConfig)

instance Data.FromJSON CognitoConfig where
  parseJSON :: Value -> Parser CognitoConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CognitoConfig"
      ( \Object
x ->
          Text -> Text -> CognitoConfig
CognitoConfig'
            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
"UserPool")
            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
"ClientId")
      )

instance Prelude.Hashable CognitoConfig where
  hashWithSalt :: Int -> CognitoConfig -> Int
hashWithSalt Int
_salt CognitoConfig' {Text
clientId :: Text
userPool :: Text
$sel:clientId:CognitoConfig' :: CognitoConfig -> Text
$sel:userPool:CognitoConfig' :: CognitoConfig -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userPool
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clientId

instance Prelude.NFData CognitoConfig where
  rnf :: CognitoConfig -> ()
rnf CognitoConfig' {Text
clientId :: Text
userPool :: Text
$sel:clientId:CognitoConfig' :: CognitoConfig -> Text
$sel:userPool:CognitoConfig' :: CognitoConfig -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
userPool
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clientId

instance Data.ToJSON CognitoConfig where
  toJSON :: CognitoConfig -> Value
toJSON CognitoConfig' {Text
clientId :: Text
userPool :: Text
$sel:clientId:CognitoConfig' :: CognitoConfig -> Text
$sel:userPool:CognitoConfig' :: CognitoConfig -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"UserPool" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userPool),
            forall a. a -> Maybe a
Prelude.Just (Key
"ClientId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clientId)
          ]
      )