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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.CognitoMemberDefinition
import Amazonka.SageMaker.Types.OidcMemberDefinition

-- | Defines an Amazon Cognito or your own OIDC IdP user group that is part
-- of a work team.
--
-- /See:/ 'newMemberDefinition' smart constructor.
data MemberDefinition = MemberDefinition'
  { -- | A list user groups that exist in your OIDC Identity Provider (IdP). One
    -- to ten groups can be used to create a single private work team. When you
    -- add a user group to the list of @Groups@, you can add that user group to
    -- one or more private work teams. If you add a user group to a private
    -- work team, all workers in that user group are added to the work team.
    MemberDefinition -> Maybe OidcMemberDefinition
oidcMemberDefinition :: Prelude.Maybe OidcMemberDefinition,
    -- | The Amazon Cognito user group that is part of the work team.
    MemberDefinition -> Maybe CognitoMemberDefinition
cognitoMemberDefinition :: Prelude.Maybe CognitoMemberDefinition
  }
  deriving (MemberDefinition -> MemberDefinition -> Bool
(MemberDefinition -> MemberDefinition -> Bool)
-> (MemberDefinition -> MemberDefinition -> Bool)
-> Eq MemberDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemberDefinition -> MemberDefinition -> Bool
$c/= :: MemberDefinition -> MemberDefinition -> Bool
== :: MemberDefinition -> MemberDefinition -> Bool
$c== :: MemberDefinition -> MemberDefinition -> Bool
Prelude.Eq, ReadPrec [MemberDefinition]
ReadPrec MemberDefinition
Int -> ReadS MemberDefinition
ReadS [MemberDefinition]
(Int -> ReadS MemberDefinition)
-> ReadS [MemberDefinition]
-> ReadPrec MemberDefinition
-> ReadPrec [MemberDefinition]
-> Read MemberDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MemberDefinition]
$creadListPrec :: ReadPrec [MemberDefinition]
readPrec :: ReadPrec MemberDefinition
$creadPrec :: ReadPrec MemberDefinition
readList :: ReadS [MemberDefinition]
$creadList :: ReadS [MemberDefinition]
readsPrec :: Int -> ReadS MemberDefinition
$creadsPrec :: Int -> ReadS MemberDefinition
Prelude.Read, Int -> MemberDefinition -> ShowS
[MemberDefinition] -> ShowS
MemberDefinition -> String
(Int -> MemberDefinition -> ShowS)
-> (MemberDefinition -> String)
-> ([MemberDefinition] -> ShowS)
-> Show MemberDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MemberDefinition] -> ShowS
$cshowList :: [MemberDefinition] -> ShowS
show :: MemberDefinition -> String
$cshow :: MemberDefinition -> String
showsPrec :: Int -> MemberDefinition -> ShowS
$cshowsPrec :: Int -> MemberDefinition -> ShowS
Prelude.Show, (forall x. MemberDefinition -> Rep MemberDefinition x)
-> (forall x. Rep MemberDefinition x -> MemberDefinition)
-> Generic MemberDefinition
forall x. Rep MemberDefinition x -> MemberDefinition
forall x. MemberDefinition -> Rep MemberDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MemberDefinition x -> MemberDefinition
$cfrom :: forall x. MemberDefinition -> Rep MemberDefinition x
Prelude.Generic)

-- |
-- Create a value of 'MemberDefinition' 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:
--
-- 'oidcMemberDefinition', 'memberDefinition_oidcMemberDefinition' - A list user groups that exist in your OIDC Identity Provider (IdP). One
-- to ten groups can be used to create a single private work team. When you
-- add a user group to the list of @Groups@, you can add that user group to
-- one or more private work teams. If you add a user group to a private
-- work team, all workers in that user group are added to the work team.
--
-- 'cognitoMemberDefinition', 'memberDefinition_cognitoMemberDefinition' - The Amazon Cognito user group that is part of the work team.
newMemberDefinition ::
  MemberDefinition
newMemberDefinition :: MemberDefinition
newMemberDefinition =
  MemberDefinition' :: Maybe OidcMemberDefinition
-> Maybe CognitoMemberDefinition -> MemberDefinition
MemberDefinition'
    { $sel:oidcMemberDefinition:MemberDefinition' :: Maybe OidcMemberDefinition
oidcMemberDefinition =
        Maybe OidcMemberDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:cognitoMemberDefinition:MemberDefinition' :: Maybe CognitoMemberDefinition
cognitoMemberDefinition = Maybe CognitoMemberDefinition
forall a. Maybe a
Prelude.Nothing
    }

-- | A list user groups that exist in your OIDC Identity Provider (IdP). One
-- to ten groups can be used to create a single private work team. When you
-- add a user group to the list of @Groups@, you can add that user group to
-- one or more private work teams. If you add a user group to a private
-- work team, all workers in that user group are added to the work team.
memberDefinition_oidcMemberDefinition :: Lens.Lens' MemberDefinition (Prelude.Maybe OidcMemberDefinition)
memberDefinition_oidcMemberDefinition :: (Maybe OidcMemberDefinition -> f (Maybe OidcMemberDefinition))
-> MemberDefinition -> f MemberDefinition
memberDefinition_oidcMemberDefinition = (MemberDefinition -> Maybe OidcMemberDefinition)
-> (MemberDefinition
    -> Maybe OidcMemberDefinition -> MemberDefinition)
-> Lens
     MemberDefinition
     MemberDefinition
     (Maybe OidcMemberDefinition)
     (Maybe OidcMemberDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberDefinition' {Maybe OidcMemberDefinition
oidcMemberDefinition :: Maybe OidcMemberDefinition
$sel:oidcMemberDefinition:MemberDefinition' :: MemberDefinition -> Maybe OidcMemberDefinition
oidcMemberDefinition} -> Maybe OidcMemberDefinition
oidcMemberDefinition) (\s :: MemberDefinition
s@MemberDefinition' {} Maybe OidcMemberDefinition
a -> MemberDefinition
s {$sel:oidcMemberDefinition:MemberDefinition' :: Maybe OidcMemberDefinition
oidcMemberDefinition = Maybe OidcMemberDefinition
a} :: MemberDefinition)

-- | The Amazon Cognito user group that is part of the work team.
memberDefinition_cognitoMemberDefinition :: Lens.Lens' MemberDefinition (Prelude.Maybe CognitoMemberDefinition)
memberDefinition_cognitoMemberDefinition :: (Maybe CognitoMemberDefinition
 -> f (Maybe CognitoMemberDefinition))
-> MemberDefinition -> f MemberDefinition
memberDefinition_cognitoMemberDefinition = (MemberDefinition -> Maybe CognitoMemberDefinition)
-> (MemberDefinition
    -> Maybe CognitoMemberDefinition -> MemberDefinition)
-> Lens
     MemberDefinition
     MemberDefinition
     (Maybe CognitoMemberDefinition)
     (Maybe CognitoMemberDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberDefinition' {Maybe CognitoMemberDefinition
cognitoMemberDefinition :: Maybe CognitoMemberDefinition
$sel:cognitoMemberDefinition:MemberDefinition' :: MemberDefinition -> Maybe CognitoMemberDefinition
cognitoMemberDefinition} -> Maybe CognitoMemberDefinition
cognitoMemberDefinition) (\s :: MemberDefinition
s@MemberDefinition' {} Maybe CognitoMemberDefinition
a -> MemberDefinition
s {$sel:cognitoMemberDefinition:MemberDefinition' :: Maybe CognitoMemberDefinition
cognitoMemberDefinition = Maybe CognitoMemberDefinition
a} :: MemberDefinition)

instance Core.FromJSON MemberDefinition where
  parseJSON :: Value -> Parser MemberDefinition
parseJSON =
    String
-> (Object -> Parser MemberDefinition)
-> Value
-> Parser MemberDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MemberDefinition"
      ( \Object
x ->
          Maybe OidcMemberDefinition
-> Maybe CognitoMemberDefinition -> MemberDefinition
MemberDefinition'
            (Maybe OidcMemberDefinition
 -> Maybe CognitoMemberDefinition -> MemberDefinition)
-> Parser (Maybe OidcMemberDefinition)
-> Parser (Maybe CognitoMemberDefinition -> MemberDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe OidcMemberDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OidcMemberDefinition")
            Parser (Maybe CognitoMemberDefinition -> MemberDefinition)
-> Parser (Maybe CognitoMemberDefinition)
-> Parser MemberDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CognitoMemberDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CognitoMemberDefinition")
      )

instance Prelude.Hashable MemberDefinition

instance Prelude.NFData MemberDefinition

instance Core.ToJSON MemberDefinition where
  toJSON :: MemberDefinition -> Value
toJSON MemberDefinition' {Maybe CognitoMemberDefinition
Maybe OidcMemberDefinition
cognitoMemberDefinition :: Maybe CognitoMemberDefinition
oidcMemberDefinition :: Maybe OidcMemberDefinition
$sel:cognitoMemberDefinition:MemberDefinition' :: MemberDefinition -> Maybe CognitoMemberDefinition
$sel:oidcMemberDefinition:MemberDefinition' :: MemberDefinition -> Maybe OidcMemberDefinition
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OidcMemberDefinition" Text -> OidcMemberDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (OidcMemberDefinition -> Pair)
-> Maybe OidcMemberDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OidcMemberDefinition
oidcMemberDefinition,
            (Text
"CognitoMemberDefinition" Text -> CognitoMemberDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CognitoMemberDefinition -> Pair)
-> Maybe CognitoMemberDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CognitoMemberDefinition
cognitoMemberDefinition
          ]
      )