{-# 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.IoTSiteWise.Types.IAMRoleIdentity
-- 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.IoTSiteWise.Types.IAMRoleIdentity where

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

-- | Contains information about an Identity and Access Management role. For
-- more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html IAM roles>
-- in the /IAM User Guide/.
--
-- /See:/ 'newIAMRoleIdentity' smart constructor.
data IAMRoleIdentity = IAMRoleIdentity'
  { -- | The ARN of the IAM role. For more information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM ARNs>
    -- in the /IAM User Guide/.
    IAMRoleIdentity -> Text
arn :: Prelude.Text
  }
  deriving (IAMRoleIdentity -> IAMRoleIdentity -> Bool
(IAMRoleIdentity -> IAMRoleIdentity -> Bool)
-> (IAMRoleIdentity -> IAMRoleIdentity -> Bool)
-> Eq IAMRoleIdentity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IAMRoleIdentity -> IAMRoleIdentity -> Bool
$c/= :: IAMRoleIdentity -> IAMRoleIdentity -> Bool
== :: IAMRoleIdentity -> IAMRoleIdentity -> Bool
$c== :: IAMRoleIdentity -> IAMRoleIdentity -> Bool
Prelude.Eq, ReadPrec [IAMRoleIdentity]
ReadPrec IAMRoleIdentity
Int -> ReadS IAMRoleIdentity
ReadS [IAMRoleIdentity]
(Int -> ReadS IAMRoleIdentity)
-> ReadS [IAMRoleIdentity]
-> ReadPrec IAMRoleIdentity
-> ReadPrec [IAMRoleIdentity]
-> Read IAMRoleIdentity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IAMRoleIdentity]
$creadListPrec :: ReadPrec [IAMRoleIdentity]
readPrec :: ReadPrec IAMRoleIdentity
$creadPrec :: ReadPrec IAMRoleIdentity
readList :: ReadS [IAMRoleIdentity]
$creadList :: ReadS [IAMRoleIdentity]
readsPrec :: Int -> ReadS IAMRoleIdentity
$creadsPrec :: Int -> ReadS IAMRoleIdentity
Prelude.Read, Int -> IAMRoleIdentity -> ShowS
[IAMRoleIdentity] -> ShowS
IAMRoleIdentity -> String
(Int -> IAMRoleIdentity -> ShowS)
-> (IAMRoleIdentity -> String)
-> ([IAMRoleIdentity] -> ShowS)
-> Show IAMRoleIdentity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IAMRoleIdentity] -> ShowS
$cshowList :: [IAMRoleIdentity] -> ShowS
show :: IAMRoleIdentity -> String
$cshow :: IAMRoleIdentity -> String
showsPrec :: Int -> IAMRoleIdentity -> ShowS
$cshowsPrec :: Int -> IAMRoleIdentity -> ShowS
Prelude.Show, (forall x. IAMRoleIdentity -> Rep IAMRoleIdentity x)
-> (forall x. Rep IAMRoleIdentity x -> IAMRoleIdentity)
-> Generic IAMRoleIdentity
forall x. Rep IAMRoleIdentity x -> IAMRoleIdentity
forall x. IAMRoleIdentity -> Rep IAMRoleIdentity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IAMRoleIdentity x -> IAMRoleIdentity
$cfrom :: forall x. IAMRoleIdentity -> Rep IAMRoleIdentity x
Prelude.Generic)

-- |
-- Create a value of 'IAMRoleIdentity' 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:
--
-- 'arn', 'iAMRoleIdentity_arn' - The ARN of the IAM role. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM ARNs>
-- in the /IAM User Guide/.
newIAMRoleIdentity ::
  -- | 'arn'
  Prelude.Text ->
  IAMRoleIdentity
newIAMRoleIdentity :: Text -> IAMRoleIdentity
newIAMRoleIdentity Text
pArn_ =
  IAMRoleIdentity' :: Text -> IAMRoleIdentity
IAMRoleIdentity' {$sel:arn:IAMRoleIdentity' :: Text
arn = Text
pArn_}

-- | The ARN of the IAM role. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM ARNs>
-- in the /IAM User Guide/.
iAMRoleIdentity_arn :: Lens.Lens' IAMRoleIdentity Prelude.Text
iAMRoleIdentity_arn :: (Text -> f Text) -> IAMRoleIdentity -> f IAMRoleIdentity
iAMRoleIdentity_arn = (IAMRoleIdentity -> Text)
-> (IAMRoleIdentity -> Text -> IAMRoleIdentity)
-> Lens IAMRoleIdentity IAMRoleIdentity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IAMRoleIdentity' {Text
arn :: Text
$sel:arn:IAMRoleIdentity' :: IAMRoleIdentity -> Text
arn} -> Text
arn) (\s :: IAMRoleIdentity
s@IAMRoleIdentity' {} Text
a -> IAMRoleIdentity
s {$sel:arn:IAMRoleIdentity' :: Text
arn = Text
a} :: IAMRoleIdentity)

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

instance Prelude.Hashable IAMRoleIdentity

instance Prelude.NFData IAMRoleIdentity

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