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

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

-- | Identifies a Amazon Cognito user group. A user group can be used in on
-- or more work teams.
--
-- /See:/ 'newCognitoMemberDefinition' smart constructor.
data CognitoMemberDefinition = CognitoMemberDefinition'
  { -- | An identifier for a user pool. The user pool must be in the same region
    -- as the service that you are calling.
    CognitoMemberDefinition -> Text
userPool :: Prelude.Text,
    -- | An identifier for a user group.
    CognitoMemberDefinition -> Text
userGroup :: Prelude.Text,
    -- | An identifier for an application client. You must create the app client
    -- ID using Amazon Cognito.
    CognitoMemberDefinition -> Text
clientId :: Prelude.Text
  }
  deriving (CognitoMemberDefinition -> CognitoMemberDefinition -> Bool
(CognitoMemberDefinition -> CognitoMemberDefinition -> Bool)
-> (CognitoMemberDefinition -> CognitoMemberDefinition -> Bool)
-> Eq CognitoMemberDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CognitoMemberDefinition -> CognitoMemberDefinition -> Bool
$c/= :: CognitoMemberDefinition -> CognitoMemberDefinition -> Bool
== :: CognitoMemberDefinition -> CognitoMemberDefinition -> Bool
$c== :: CognitoMemberDefinition -> CognitoMemberDefinition -> Bool
Prelude.Eq, ReadPrec [CognitoMemberDefinition]
ReadPrec CognitoMemberDefinition
Int -> ReadS CognitoMemberDefinition
ReadS [CognitoMemberDefinition]
(Int -> ReadS CognitoMemberDefinition)
-> ReadS [CognitoMemberDefinition]
-> ReadPrec CognitoMemberDefinition
-> ReadPrec [CognitoMemberDefinition]
-> Read CognitoMemberDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CognitoMemberDefinition]
$creadListPrec :: ReadPrec [CognitoMemberDefinition]
readPrec :: ReadPrec CognitoMemberDefinition
$creadPrec :: ReadPrec CognitoMemberDefinition
readList :: ReadS [CognitoMemberDefinition]
$creadList :: ReadS [CognitoMemberDefinition]
readsPrec :: Int -> ReadS CognitoMemberDefinition
$creadsPrec :: Int -> ReadS CognitoMemberDefinition
Prelude.Read, Int -> CognitoMemberDefinition -> ShowS
[CognitoMemberDefinition] -> ShowS
CognitoMemberDefinition -> String
(Int -> CognitoMemberDefinition -> ShowS)
-> (CognitoMemberDefinition -> String)
-> ([CognitoMemberDefinition] -> ShowS)
-> Show CognitoMemberDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CognitoMemberDefinition] -> ShowS
$cshowList :: [CognitoMemberDefinition] -> ShowS
show :: CognitoMemberDefinition -> String
$cshow :: CognitoMemberDefinition -> String
showsPrec :: Int -> CognitoMemberDefinition -> ShowS
$cshowsPrec :: Int -> CognitoMemberDefinition -> ShowS
Prelude.Show, (forall x.
 CognitoMemberDefinition -> Rep CognitoMemberDefinition x)
-> (forall x.
    Rep CognitoMemberDefinition x -> CognitoMemberDefinition)
-> Generic CognitoMemberDefinition
forall x. Rep CognitoMemberDefinition x -> CognitoMemberDefinition
forall x. CognitoMemberDefinition -> Rep CognitoMemberDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CognitoMemberDefinition x -> CognitoMemberDefinition
$cfrom :: forall x. CognitoMemberDefinition -> Rep CognitoMemberDefinition x
Prelude.Generic)

-- |
-- Create a value of 'CognitoMemberDefinition' 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', 'cognitoMemberDefinition_userPool' - An identifier for a user pool. The user pool must be in the same region
-- as the service that you are calling.
--
-- 'userGroup', 'cognitoMemberDefinition_userGroup' - An identifier for a user group.
--
-- 'clientId', 'cognitoMemberDefinition_clientId' - An identifier for an application client. You must create the app client
-- ID using Amazon Cognito.
newCognitoMemberDefinition ::
  -- | 'userPool'
  Prelude.Text ->
  -- | 'userGroup'
  Prelude.Text ->
  -- | 'clientId'
  Prelude.Text ->
  CognitoMemberDefinition
newCognitoMemberDefinition :: Text -> Text -> Text -> CognitoMemberDefinition
newCognitoMemberDefinition
  Text
pUserPool_
  Text
pUserGroup_
  Text
pClientId_ =
    CognitoMemberDefinition' :: Text -> Text -> Text -> CognitoMemberDefinition
CognitoMemberDefinition'
      { $sel:userPool:CognitoMemberDefinition' :: Text
userPool = Text
pUserPool_,
        $sel:userGroup:CognitoMemberDefinition' :: Text
userGroup = Text
pUserGroup_,
        $sel:clientId:CognitoMemberDefinition' :: Text
clientId = Text
pClientId_
      }

-- | An identifier for a user pool. The user pool must be in the same region
-- as the service that you are calling.
cognitoMemberDefinition_userPool :: Lens.Lens' CognitoMemberDefinition Prelude.Text
cognitoMemberDefinition_userPool :: (Text -> f Text)
-> CognitoMemberDefinition -> f CognitoMemberDefinition
cognitoMemberDefinition_userPool = (CognitoMemberDefinition -> Text)
-> (CognitoMemberDefinition -> Text -> CognitoMemberDefinition)
-> Lens CognitoMemberDefinition CognitoMemberDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CognitoMemberDefinition' {Text
userPool :: Text
$sel:userPool:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
userPool} -> Text
userPool) (\s :: CognitoMemberDefinition
s@CognitoMemberDefinition' {} Text
a -> CognitoMemberDefinition
s {$sel:userPool:CognitoMemberDefinition' :: Text
userPool = Text
a} :: CognitoMemberDefinition)

-- | An identifier for a user group.
cognitoMemberDefinition_userGroup :: Lens.Lens' CognitoMemberDefinition Prelude.Text
cognitoMemberDefinition_userGroup :: (Text -> f Text)
-> CognitoMemberDefinition -> f CognitoMemberDefinition
cognitoMemberDefinition_userGroup = (CognitoMemberDefinition -> Text)
-> (CognitoMemberDefinition -> Text -> CognitoMemberDefinition)
-> Lens CognitoMemberDefinition CognitoMemberDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CognitoMemberDefinition' {Text
userGroup :: Text
$sel:userGroup:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
userGroup} -> Text
userGroup) (\s :: CognitoMemberDefinition
s@CognitoMemberDefinition' {} Text
a -> CognitoMemberDefinition
s {$sel:userGroup:CognitoMemberDefinition' :: Text
userGroup = Text
a} :: CognitoMemberDefinition)

-- | An identifier for an application client. You must create the app client
-- ID using Amazon Cognito.
cognitoMemberDefinition_clientId :: Lens.Lens' CognitoMemberDefinition Prelude.Text
cognitoMemberDefinition_clientId :: (Text -> f Text)
-> CognitoMemberDefinition -> f CognitoMemberDefinition
cognitoMemberDefinition_clientId = (CognitoMemberDefinition -> Text)
-> (CognitoMemberDefinition -> Text -> CognitoMemberDefinition)
-> Lens CognitoMemberDefinition CognitoMemberDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CognitoMemberDefinition' {Text
clientId :: Text
$sel:clientId:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
clientId} -> Text
clientId) (\s :: CognitoMemberDefinition
s@CognitoMemberDefinition' {} Text
a -> CognitoMemberDefinition
s {$sel:clientId:CognitoMemberDefinition' :: Text
clientId = Text
a} :: CognitoMemberDefinition)

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

instance Prelude.NFData CognitoMemberDefinition

instance Core.ToJSON CognitoMemberDefinition where
  toJSON :: CognitoMemberDefinition -> Value
toJSON CognitoMemberDefinition' {Text
clientId :: Text
userGroup :: Text
userPool :: Text
$sel:clientId:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
$sel:userGroup:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
$sel:userPool:CognitoMemberDefinition' :: CognitoMemberDefinition -> 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
"UserGroup" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userGroup),
            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)
          ]
      )