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

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

-- | A list of 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.
--
-- /See:/ 'newOidcMemberDefinition' smart constructor.
data OidcMemberDefinition = OidcMemberDefinition'
  { -- | A list of comma seperated strings that identifies user groups in your
    -- OIDC IdP. Each user group is made up of a group of private workers.
    OidcMemberDefinition -> NonEmpty Text
groups :: Prelude.NonEmpty Prelude.Text
  }
  deriving (OidcMemberDefinition -> OidcMemberDefinition -> Bool
(OidcMemberDefinition -> OidcMemberDefinition -> Bool)
-> (OidcMemberDefinition -> OidcMemberDefinition -> Bool)
-> Eq OidcMemberDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OidcMemberDefinition -> OidcMemberDefinition -> Bool
$c/= :: OidcMemberDefinition -> OidcMemberDefinition -> Bool
== :: OidcMemberDefinition -> OidcMemberDefinition -> Bool
$c== :: OidcMemberDefinition -> OidcMemberDefinition -> Bool
Prelude.Eq, ReadPrec [OidcMemberDefinition]
ReadPrec OidcMemberDefinition
Int -> ReadS OidcMemberDefinition
ReadS [OidcMemberDefinition]
(Int -> ReadS OidcMemberDefinition)
-> ReadS [OidcMemberDefinition]
-> ReadPrec OidcMemberDefinition
-> ReadPrec [OidcMemberDefinition]
-> Read OidcMemberDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OidcMemberDefinition]
$creadListPrec :: ReadPrec [OidcMemberDefinition]
readPrec :: ReadPrec OidcMemberDefinition
$creadPrec :: ReadPrec OidcMemberDefinition
readList :: ReadS [OidcMemberDefinition]
$creadList :: ReadS [OidcMemberDefinition]
readsPrec :: Int -> ReadS OidcMemberDefinition
$creadsPrec :: Int -> ReadS OidcMemberDefinition
Prelude.Read, Int -> OidcMemberDefinition -> ShowS
[OidcMemberDefinition] -> ShowS
OidcMemberDefinition -> String
(Int -> OidcMemberDefinition -> ShowS)
-> (OidcMemberDefinition -> String)
-> ([OidcMemberDefinition] -> ShowS)
-> Show OidcMemberDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OidcMemberDefinition] -> ShowS
$cshowList :: [OidcMemberDefinition] -> ShowS
show :: OidcMemberDefinition -> String
$cshow :: OidcMemberDefinition -> String
showsPrec :: Int -> OidcMemberDefinition -> ShowS
$cshowsPrec :: Int -> OidcMemberDefinition -> ShowS
Prelude.Show, (forall x. OidcMemberDefinition -> Rep OidcMemberDefinition x)
-> (forall x. Rep OidcMemberDefinition x -> OidcMemberDefinition)
-> Generic OidcMemberDefinition
forall x. Rep OidcMemberDefinition x -> OidcMemberDefinition
forall x. OidcMemberDefinition -> Rep OidcMemberDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OidcMemberDefinition x -> OidcMemberDefinition
$cfrom :: forall x. OidcMemberDefinition -> Rep OidcMemberDefinition x
Prelude.Generic)

-- |
-- Create a value of 'OidcMemberDefinition' 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:
--
-- 'groups', 'oidcMemberDefinition_groups' - A list of comma seperated strings that identifies user groups in your
-- OIDC IdP. Each user group is made up of a group of private workers.
newOidcMemberDefinition ::
  -- | 'groups'
  Prelude.NonEmpty Prelude.Text ->
  OidcMemberDefinition
newOidcMemberDefinition :: NonEmpty Text -> OidcMemberDefinition
newOidcMemberDefinition NonEmpty Text
pGroups_ =
  OidcMemberDefinition' :: NonEmpty Text -> OidcMemberDefinition
OidcMemberDefinition'
    { $sel:groups:OidcMemberDefinition' :: NonEmpty Text
groups =
        Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pGroups_
    }

-- | A list of comma seperated strings that identifies user groups in your
-- OIDC IdP. Each user group is made up of a group of private workers.
oidcMemberDefinition_groups :: Lens.Lens' OidcMemberDefinition (Prelude.NonEmpty Prelude.Text)
oidcMemberDefinition_groups :: (NonEmpty Text -> f (NonEmpty Text))
-> OidcMemberDefinition -> f OidcMemberDefinition
oidcMemberDefinition_groups = (OidcMemberDefinition -> NonEmpty Text)
-> (OidcMemberDefinition -> NonEmpty Text -> OidcMemberDefinition)
-> Lens
     OidcMemberDefinition
     OidcMemberDefinition
     (NonEmpty Text)
     (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OidcMemberDefinition' {NonEmpty Text
groups :: NonEmpty Text
$sel:groups:OidcMemberDefinition' :: OidcMemberDefinition -> NonEmpty Text
groups} -> NonEmpty Text
groups) (\s :: OidcMemberDefinition
s@OidcMemberDefinition' {} NonEmpty Text
a -> OidcMemberDefinition
s {$sel:groups:OidcMemberDefinition' :: NonEmpty Text
groups = NonEmpty Text
a} :: OidcMemberDefinition) ((NonEmpty Text -> f (NonEmpty Text))
 -> OidcMemberDefinition -> f OidcMemberDefinition)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> OidcMemberDefinition
-> f OidcMemberDefinition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable OidcMemberDefinition

instance Prelude.NFData OidcMemberDefinition

instance Core.ToJSON OidcMemberDefinition where
  toJSON :: OidcMemberDefinition -> Value
toJSON OidcMemberDefinition' {NonEmpty Text
groups :: NonEmpty Text
$sel:groups:OidcMemberDefinition' :: OidcMemberDefinition -> NonEmpty 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
"Groups" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
groups)]
      )