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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(CognitoConfig -> CognitoConfig -> Bool)
-> (CognitoConfig -> CognitoConfig -> Bool) -> Eq CognitoConfig
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]
(Int -> ReadS CognitoConfig)
-> ReadS [CognitoConfig]
-> ReadPrec CognitoConfig
-> ReadPrec [CognitoConfig]
-> Read 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
(Int -> CognitoConfig -> ShowS)
-> (CognitoConfig -> String)
-> ([CognitoConfig] -> ShowS)
-> Show CognitoConfig
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. CognitoConfig -> Rep CognitoConfig x)
-> (forall x. Rep CognitoConfig x -> CognitoConfig)
-> Generic CognitoConfig
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' :: Text -> Text -> CognitoConfig
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 :: (Text -> f Text) -> CognitoConfig -> f CognitoConfig
cognitoConfig_userPool = (CognitoConfig -> Text)
-> (CognitoConfig -> Text -> CognitoConfig)
-> Lens CognitoConfig CognitoConfig Text Text
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 :: (Text -> f Text) -> CognitoConfig -> f CognitoConfig
cognitoConfig_clientId = (CognitoConfig -> Text)
-> (CognitoConfig -> Text -> CognitoConfig)
-> Lens CognitoConfig CognitoConfig Text Text
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 Core.FromJSON CognitoConfig where
  parseJSON :: Value -> Parser CognitoConfig
parseJSON =
    String
-> (Object -> Parser CognitoConfig)
-> Value
-> Parser CognitoConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CognitoConfig"
      ( \Object
x ->
          Text -> Text -> CognitoConfig
CognitoConfig'
            (Text -> Text -> CognitoConfig)
-> Parser Text -> Parser (Text -> CognitoConfig)
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
"UserPool")
            Parser (Text -> CognitoConfig)
-> Parser Text -> Parser CognitoConfig
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
"ClientId")
      )

instance Prelude.Hashable CognitoConfig

instance Prelude.NFData CognitoConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserPool" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPool),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ClientId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientId)
          ]
      )