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

-- | 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
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]
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
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. 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'
      { $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 :: Lens' CognitoMemberDefinition Text
cognitoMemberDefinition_userPool = 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 :: Lens' CognitoMemberDefinition Text
cognitoMemberDefinition_userGroup = 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 :: Lens' CognitoMemberDefinition Text
cognitoMemberDefinition_clientId = 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 Data.FromJSON CognitoMemberDefinition where
  parseJSON :: Value -> Parser CognitoMemberDefinition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CognitoMemberDefinition"
      ( \Object
x ->
          Text -> Text -> Text -> CognitoMemberDefinition
CognitoMemberDefinition'
            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
"UserGroup")
            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 CognitoMemberDefinition where
  hashWithSalt :: Int -> CognitoMemberDefinition -> Int
hashWithSalt Int
_salt CognitoMemberDefinition' {Text
clientId :: Text
userGroup :: Text
userPool :: Text
$sel:clientId:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
$sel:userGroup:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
$sel:userPool:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userPool
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userGroup
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clientId

instance Prelude.NFData CognitoMemberDefinition where
  rnf :: CognitoMemberDefinition -> ()
rnf CognitoMemberDefinition' {Text
clientId :: Text
userGroup :: Text
userPool :: Text
$sel:clientId:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
$sel:userGroup:CognitoMemberDefinition' :: CognitoMemberDefinition -> Text
$sel:userPool:CognitoMemberDefinition' :: CognitoMemberDefinition -> 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
userGroup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clientId

instance Data.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
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
"UserGroup" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userGroup),
            forall a. a -> Maybe a
Prelude.Just (Key
"ClientId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clientId)
          ]
      )