{-# 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.SSO.Types.RoleInfo
-- 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.SSO.Types.RoleInfo where

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

-- | Provides information about the role that is assigned to the user.
--
-- /See:/ 'newRoleInfo' smart constructor.
data RoleInfo = RoleInfo'
  { -- | The friendly name of the role that is assigned to the user.
    RoleInfo -> Maybe Text
roleName :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the AWS account assigned to the user.
    RoleInfo -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text
  }
  deriving (RoleInfo -> RoleInfo -> Bool
(RoleInfo -> RoleInfo -> Bool)
-> (RoleInfo -> RoleInfo -> Bool) -> Eq RoleInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RoleInfo -> RoleInfo -> Bool
$c/= :: RoleInfo -> RoleInfo -> Bool
== :: RoleInfo -> RoleInfo -> Bool
$c== :: RoleInfo -> RoleInfo -> Bool
Prelude.Eq, ReadPrec [RoleInfo]
ReadPrec RoleInfo
Int -> ReadS RoleInfo
ReadS [RoleInfo]
(Int -> ReadS RoleInfo)
-> ReadS [RoleInfo]
-> ReadPrec RoleInfo
-> ReadPrec [RoleInfo]
-> Read RoleInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RoleInfo]
$creadListPrec :: ReadPrec [RoleInfo]
readPrec :: ReadPrec RoleInfo
$creadPrec :: ReadPrec RoleInfo
readList :: ReadS [RoleInfo]
$creadList :: ReadS [RoleInfo]
readsPrec :: Int -> ReadS RoleInfo
$creadsPrec :: Int -> ReadS RoleInfo
Prelude.Read, Int -> RoleInfo -> ShowS
[RoleInfo] -> ShowS
RoleInfo -> String
(Int -> RoleInfo -> ShowS)
-> (RoleInfo -> String) -> ([RoleInfo] -> ShowS) -> Show RoleInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RoleInfo] -> ShowS
$cshowList :: [RoleInfo] -> ShowS
show :: RoleInfo -> String
$cshow :: RoleInfo -> String
showsPrec :: Int -> RoleInfo -> ShowS
$cshowsPrec :: Int -> RoleInfo -> ShowS
Prelude.Show, (forall x. RoleInfo -> Rep RoleInfo x)
-> (forall x. Rep RoleInfo x -> RoleInfo) -> Generic RoleInfo
forall x. Rep RoleInfo x -> RoleInfo
forall x. RoleInfo -> Rep RoleInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RoleInfo x -> RoleInfo
$cfrom :: forall x. RoleInfo -> Rep RoleInfo x
Prelude.Generic)

-- |
-- Create a value of 'RoleInfo' 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:
--
-- 'roleName', 'roleInfo_roleName' - The friendly name of the role that is assigned to the user.
--
-- 'accountId', 'roleInfo_accountId' - The identifier of the AWS account assigned to the user.
newRoleInfo ::
  RoleInfo
newRoleInfo :: RoleInfo
newRoleInfo =
  RoleInfo' :: Maybe Text -> Maybe Text -> RoleInfo
RoleInfo'
    { $sel:roleName:RoleInfo' :: Maybe Text
roleName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:RoleInfo' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The friendly name of the role that is assigned to the user.
roleInfo_roleName :: Lens.Lens' RoleInfo (Prelude.Maybe Prelude.Text)
roleInfo_roleName :: (Maybe Text -> f (Maybe Text)) -> RoleInfo -> f RoleInfo
roleInfo_roleName = (RoleInfo -> Maybe Text)
-> (RoleInfo -> Maybe Text -> RoleInfo)
-> Lens RoleInfo RoleInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoleInfo' {Maybe Text
roleName :: Maybe Text
$sel:roleName:RoleInfo' :: RoleInfo -> Maybe Text
roleName} -> Maybe Text
roleName) (\s :: RoleInfo
s@RoleInfo' {} Maybe Text
a -> RoleInfo
s {$sel:roleName:RoleInfo' :: Maybe Text
roleName = Maybe Text
a} :: RoleInfo)

-- | The identifier of the AWS account assigned to the user.
roleInfo_accountId :: Lens.Lens' RoleInfo (Prelude.Maybe Prelude.Text)
roleInfo_accountId :: (Maybe Text -> f (Maybe Text)) -> RoleInfo -> f RoleInfo
roleInfo_accountId = (RoleInfo -> Maybe Text)
-> (RoleInfo -> Maybe Text -> RoleInfo)
-> Lens RoleInfo RoleInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoleInfo' {Maybe Text
accountId :: Maybe Text
$sel:accountId:RoleInfo' :: RoleInfo -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: RoleInfo
s@RoleInfo' {} Maybe Text
a -> RoleInfo
s {$sel:accountId:RoleInfo' :: Maybe Text
accountId = Maybe Text
a} :: RoleInfo)

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

instance Prelude.Hashable RoleInfo

instance Prelude.NFData RoleInfo