{-# 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.SSOAdmin.Types.AccountAssignment
-- 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.SSOAdmin.Types.AccountAssignment where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSOAdmin.Types.PrincipalType

-- | The assignment that indicates a principal\'s limited access to a
-- specified Amazon Web Services account with a specified permission set.
--
-- The term /principal/ here refers to a user or group that is defined in
-- Amazon Web Services SSO.
--
-- /See:/ 'newAccountAssignment' smart constructor.
data AccountAssignment = AccountAssignment'
  { -- | An identifier for an object in Amazon Web Services SSO, such as a user
    -- or group. PrincipalIds are GUIDs (For example,
    -- f81d4fae-7dec-11d0-a765-00a0c91e6bf6). For more information about
    -- PrincipalIds in Amazon Web Services SSO, see the
    -- </singlesignon/latest/IdentityStoreAPIReference/welcome.html Amazon Web Services SSO Identity Store API Reference>.
    AccountAssignment -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | The entity type for which the assignment will be created.
    AccountAssignment -> Maybe PrincipalType
principalType :: Prelude.Maybe PrincipalType,
    -- | The identifier of the Amazon Web Services account.
    AccountAssignment -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the permission set. For more information about ARNs, see
    -- </general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces>
    -- in the /Amazon Web Services General Reference/.
    AccountAssignment -> Maybe Text
permissionSetArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AccountAssignment -> AccountAssignment -> Bool
(AccountAssignment -> AccountAssignment -> Bool)
-> (AccountAssignment -> AccountAssignment -> Bool)
-> Eq AccountAssignment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountAssignment -> AccountAssignment -> Bool
$c/= :: AccountAssignment -> AccountAssignment -> Bool
== :: AccountAssignment -> AccountAssignment -> Bool
$c== :: AccountAssignment -> AccountAssignment -> Bool
Prelude.Eq, ReadPrec [AccountAssignment]
ReadPrec AccountAssignment
Int -> ReadS AccountAssignment
ReadS [AccountAssignment]
(Int -> ReadS AccountAssignment)
-> ReadS [AccountAssignment]
-> ReadPrec AccountAssignment
-> ReadPrec [AccountAssignment]
-> Read AccountAssignment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccountAssignment]
$creadListPrec :: ReadPrec [AccountAssignment]
readPrec :: ReadPrec AccountAssignment
$creadPrec :: ReadPrec AccountAssignment
readList :: ReadS [AccountAssignment]
$creadList :: ReadS [AccountAssignment]
readsPrec :: Int -> ReadS AccountAssignment
$creadsPrec :: Int -> ReadS AccountAssignment
Prelude.Read, Int -> AccountAssignment -> ShowS
[AccountAssignment] -> ShowS
AccountAssignment -> String
(Int -> AccountAssignment -> ShowS)
-> (AccountAssignment -> String)
-> ([AccountAssignment] -> ShowS)
-> Show AccountAssignment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountAssignment] -> ShowS
$cshowList :: [AccountAssignment] -> ShowS
show :: AccountAssignment -> String
$cshow :: AccountAssignment -> String
showsPrec :: Int -> AccountAssignment -> ShowS
$cshowsPrec :: Int -> AccountAssignment -> ShowS
Prelude.Show, (forall x. AccountAssignment -> Rep AccountAssignment x)
-> (forall x. Rep AccountAssignment x -> AccountAssignment)
-> Generic AccountAssignment
forall x. Rep AccountAssignment x -> AccountAssignment
forall x. AccountAssignment -> Rep AccountAssignment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountAssignment x -> AccountAssignment
$cfrom :: forall x. AccountAssignment -> Rep AccountAssignment x
Prelude.Generic)

-- |
-- Create a value of 'AccountAssignment' 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:
--
-- 'principalId', 'accountAssignment_principalId' - An identifier for an object in Amazon Web Services SSO, such as a user
-- or group. PrincipalIds are GUIDs (For example,
-- f81d4fae-7dec-11d0-a765-00a0c91e6bf6). For more information about
-- PrincipalIds in Amazon Web Services SSO, see the
-- </singlesignon/latest/IdentityStoreAPIReference/welcome.html Amazon Web Services SSO Identity Store API Reference>.
--
-- 'principalType', 'accountAssignment_principalType' - The entity type for which the assignment will be created.
--
-- 'accountId', 'accountAssignment_accountId' - The identifier of the Amazon Web Services account.
--
-- 'permissionSetArn', 'accountAssignment_permissionSetArn' - The ARN of the permission set. For more information about ARNs, see
-- </general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces>
-- in the /Amazon Web Services General Reference/.
newAccountAssignment ::
  AccountAssignment
newAccountAssignment :: AccountAssignment
newAccountAssignment =
  AccountAssignment' :: Maybe Text
-> Maybe PrincipalType
-> Maybe Text
-> Maybe Text
-> AccountAssignment
AccountAssignment'
    { $sel:principalId:AccountAssignment' :: Maybe Text
principalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:principalType:AccountAssignment' :: Maybe PrincipalType
principalType = Maybe PrincipalType
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:AccountAssignment' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:permissionSetArn:AccountAssignment' :: Maybe Text
permissionSetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An identifier for an object in Amazon Web Services SSO, such as a user
-- or group. PrincipalIds are GUIDs (For example,
-- f81d4fae-7dec-11d0-a765-00a0c91e6bf6). For more information about
-- PrincipalIds in Amazon Web Services SSO, see the
-- </singlesignon/latest/IdentityStoreAPIReference/welcome.html Amazon Web Services SSO Identity Store API Reference>.
accountAssignment_principalId :: Lens.Lens' AccountAssignment (Prelude.Maybe Prelude.Text)
accountAssignment_principalId :: (Maybe Text -> f (Maybe Text))
-> AccountAssignment -> f AccountAssignment
accountAssignment_principalId = (AccountAssignment -> Maybe Text)
-> (AccountAssignment -> Maybe Text -> AccountAssignment)
-> Lens
     AccountAssignment AccountAssignment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountAssignment' {Maybe Text
principalId :: Maybe Text
$sel:principalId:AccountAssignment' :: AccountAssignment -> Maybe Text
principalId} -> Maybe Text
principalId) (\s :: AccountAssignment
s@AccountAssignment' {} Maybe Text
a -> AccountAssignment
s {$sel:principalId:AccountAssignment' :: Maybe Text
principalId = Maybe Text
a} :: AccountAssignment)

-- | The entity type for which the assignment will be created.
accountAssignment_principalType :: Lens.Lens' AccountAssignment (Prelude.Maybe PrincipalType)
accountAssignment_principalType :: (Maybe PrincipalType -> f (Maybe PrincipalType))
-> AccountAssignment -> f AccountAssignment
accountAssignment_principalType = (AccountAssignment -> Maybe PrincipalType)
-> (AccountAssignment -> Maybe PrincipalType -> AccountAssignment)
-> Lens
     AccountAssignment
     AccountAssignment
     (Maybe PrincipalType)
     (Maybe PrincipalType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountAssignment' {Maybe PrincipalType
principalType :: Maybe PrincipalType
$sel:principalType:AccountAssignment' :: AccountAssignment -> Maybe PrincipalType
principalType} -> Maybe PrincipalType
principalType) (\s :: AccountAssignment
s@AccountAssignment' {} Maybe PrincipalType
a -> AccountAssignment
s {$sel:principalType:AccountAssignment' :: Maybe PrincipalType
principalType = Maybe PrincipalType
a} :: AccountAssignment)

-- | The identifier of the Amazon Web Services account.
accountAssignment_accountId :: Lens.Lens' AccountAssignment (Prelude.Maybe Prelude.Text)
accountAssignment_accountId :: (Maybe Text -> f (Maybe Text))
-> AccountAssignment -> f AccountAssignment
accountAssignment_accountId = (AccountAssignment -> Maybe Text)
-> (AccountAssignment -> Maybe Text -> AccountAssignment)
-> Lens
     AccountAssignment AccountAssignment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountAssignment' {Maybe Text
accountId :: Maybe Text
$sel:accountId:AccountAssignment' :: AccountAssignment -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: AccountAssignment
s@AccountAssignment' {} Maybe Text
a -> AccountAssignment
s {$sel:accountId:AccountAssignment' :: Maybe Text
accountId = Maybe Text
a} :: AccountAssignment)

-- | The ARN of the permission set. For more information about ARNs, see
-- </general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces>
-- in the /Amazon Web Services General Reference/.
accountAssignment_permissionSetArn :: Lens.Lens' AccountAssignment (Prelude.Maybe Prelude.Text)
accountAssignment_permissionSetArn :: (Maybe Text -> f (Maybe Text))
-> AccountAssignment -> f AccountAssignment
accountAssignment_permissionSetArn = (AccountAssignment -> Maybe Text)
-> (AccountAssignment -> Maybe Text -> AccountAssignment)
-> Lens
     AccountAssignment AccountAssignment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountAssignment' {Maybe Text
permissionSetArn :: Maybe Text
$sel:permissionSetArn:AccountAssignment' :: AccountAssignment -> Maybe Text
permissionSetArn} -> Maybe Text
permissionSetArn) (\s :: AccountAssignment
s@AccountAssignment' {} Maybe Text
a -> AccountAssignment
s {$sel:permissionSetArn:AccountAssignment' :: Maybe Text
permissionSetArn = Maybe Text
a} :: AccountAssignment)

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

instance Prelude.Hashable AccountAssignment

instance Prelude.NFData AccountAssignment