{-# 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.IAM.Types.InstanceProfile
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IAM.Types.InstanceProfile where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types.Role
import Amazonka.IAM.Types.Tag
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an instance profile.
--
-- This data type is used as a response element in the following
-- operations:
--
-- -   CreateInstanceProfile
--
-- -   GetInstanceProfile
--
-- -   ListInstanceProfiles
--
-- -   ListInstanceProfilesForRole
--
-- /See:/ 'newInstanceProfile' smart constructor.
data InstanceProfile = InstanceProfile'
  { -- | A list of tags that are attached to the instance profile. For more
    -- information about tagging, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
    -- in the /IAM User Guide/.
    InstanceProfile -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The path to the instance profile. For more information about paths, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
    -- in the /IAM User Guide/.
    InstanceProfile -> Text
path :: Prelude.Text,
    -- | The name identifying the instance profile.
    InstanceProfile -> Text
instanceProfileName :: Prelude.Text,
    -- | The stable and unique string identifying the instance profile. For more
    -- information about IDs, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
    -- in the /IAM User Guide/.
    InstanceProfile -> Text
instanceProfileId :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) specifying the instance profile. For more
    -- information about ARNs and how to use them in policies, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
    -- in the /IAM User Guide/.
    InstanceProfile -> Text
arn :: Prelude.Text,
    -- | The date when the instance profile was created.
    InstanceProfile -> ISO8601
createDate :: Data.ISO8601,
    -- | The role associated with the instance profile.
    InstanceProfile -> [Role]
roles :: [Role]
  }
  deriving (InstanceProfile -> InstanceProfile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceProfile -> InstanceProfile -> Bool
$c/= :: InstanceProfile -> InstanceProfile -> Bool
== :: InstanceProfile -> InstanceProfile -> Bool
$c== :: InstanceProfile -> InstanceProfile -> Bool
Prelude.Eq, ReadPrec [InstanceProfile]
ReadPrec InstanceProfile
Int -> ReadS InstanceProfile
ReadS [InstanceProfile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceProfile]
$creadListPrec :: ReadPrec [InstanceProfile]
readPrec :: ReadPrec InstanceProfile
$creadPrec :: ReadPrec InstanceProfile
readList :: ReadS [InstanceProfile]
$creadList :: ReadS [InstanceProfile]
readsPrec :: Int -> ReadS InstanceProfile
$creadsPrec :: Int -> ReadS InstanceProfile
Prelude.Read, Int -> InstanceProfile -> ShowS
[InstanceProfile] -> ShowS
InstanceProfile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceProfile] -> ShowS
$cshowList :: [InstanceProfile] -> ShowS
show :: InstanceProfile -> String
$cshow :: InstanceProfile -> String
showsPrec :: Int -> InstanceProfile -> ShowS
$cshowsPrec :: Int -> InstanceProfile -> ShowS
Prelude.Show, forall x. Rep InstanceProfile x -> InstanceProfile
forall x. InstanceProfile -> Rep InstanceProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceProfile x -> InstanceProfile
$cfrom :: forall x. InstanceProfile -> Rep InstanceProfile x
Prelude.Generic)

-- |
-- Create a value of 'InstanceProfile' 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:
--
-- 'tags', 'instanceProfile_tags' - A list of tags that are attached to the instance profile. For more
-- information about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
--
-- 'path', 'instanceProfile_path' - The path to the instance profile. For more information about paths, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
--
-- 'instanceProfileName', 'instanceProfile_instanceProfileName' - The name identifying the instance profile.
--
-- 'instanceProfileId', 'instanceProfile_instanceProfileId' - The stable and unique string identifying the instance profile. For more
-- information about IDs, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
--
-- 'arn', 'instanceProfile_arn' - The Amazon Resource Name (ARN) specifying the instance profile. For more
-- information about ARNs and how to use them in policies, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
--
-- 'createDate', 'instanceProfile_createDate' - The date when the instance profile was created.
--
-- 'roles', 'instanceProfile_roles' - The role associated with the instance profile.
newInstanceProfile ::
  -- | 'path'
  Prelude.Text ->
  -- | 'instanceProfileName'
  Prelude.Text ->
  -- | 'instanceProfileId'
  Prelude.Text ->
  -- | 'arn'
  Prelude.Text ->
  -- | 'createDate'
  Prelude.UTCTime ->
  InstanceProfile
newInstanceProfile :: Text -> Text -> Text -> Text -> UTCTime -> InstanceProfile
newInstanceProfile
  Text
pPath_
  Text
pInstanceProfileName_
  Text
pInstanceProfileId_
  Text
pArn_
  UTCTime
pCreateDate_ =
    InstanceProfile'
      { $sel:tags:InstanceProfile' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:path:InstanceProfile' :: Text
path = Text
pPath_,
        $sel:instanceProfileName:InstanceProfile' :: Text
instanceProfileName = Text
pInstanceProfileName_,
        $sel:instanceProfileId:InstanceProfile' :: Text
instanceProfileId = Text
pInstanceProfileId_,
        $sel:arn:InstanceProfile' :: Text
arn = Text
pArn_,
        $sel:createDate:InstanceProfile' :: ISO8601
createDate = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreateDate_,
        $sel:roles:InstanceProfile' :: [Role]
roles = forall a. Monoid a => a
Prelude.mempty
      }

-- | A list of tags that are attached to the instance profile. For more
-- information about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
instanceProfile_tags :: Lens.Lens' InstanceProfile (Prelude.Maybe [Tag])
instanceProfile_tags :: Lens' InstanceProfile (Maybe [Tag])
instanceProfile_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceProfile' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:InstanceProfile' :: InstanceProfile -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: InstanceProfile
s@InstanceProfile' {} Maybe [Tag]
a -> InstanceProfile
s {$sel:tags:InstanceProfile' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: InstanceProfile) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The path to the instance profile. For more information about paths, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
instanceProfile_path :: Lens.Lens' InstanceProfile Prelude.Text
instanceProfile_path :: Lens' InstanceProfile Text
instanceProfile_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceProfile' {Text
path :: Text
$sel:path:InstanceProfile' :: InstanceProfile -> Text
path} -> Text
path) (\s :: InstanceProfile
s@InstanceProfile' {} Text
a -> InstanceProfile
s {$sel:path:InstanceProfile' :: Text
path = Text
a} :: InstanceProfile)

-- | The name identifying the instance profile.
instanceProfile_instanceProfileName :: Lens.Lens' InstanceProfile Prelude.Text
instanceProfile_instanceProfileName :: Lens' InstanceProfile Text
instanceProfile_instanceProfileName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceProfile' {Text
instanceProfileName :: Text
$sel:instanceProfileName:InstanceProfile' :: InstanceProfile -> Text
instanceProfileName} -> Text
instanceProfileName) (\s :: InstanceProfile
s@InstanceProfile' {} Text
a -> InstanceProfile
s {$sel:instanceProfileName:InstanceProfile' :: Text
instanceProfileName = Text
a} :: InstanceProfile)

-- | The stable and unique string identifying the instance profile. For more
-- information about IDs, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
instanceProfile_instanceProfileId :: Lens.Lens' InstanceProfile Prelude.Text
instanceProfile_instanceProfileId :: Lens' InstanceProfile Text
instanceProfile_instanceProfileId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceProfile' {Text
instanceProfileId :: Text
$sel:instanceProfileId:InstanceProfile' :: InstanceProfile -> Text
instanceProfileId} -> Text
instanceProfileId) (\s :: InstanceProfile
s@InstanceProfile' {} Text
a -> InstanceProfile
s {$sel:instanceProfileId:InstanceProfile' :: Text
instanceProfileId = Text
a} :: InstanceProfile)

-- | The Amazon Resource Name (ARN) specifying the instance profile. For more
-- information about ARNs and how to use them in policies, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
instanceProfile_arn :: Lens.Lens' InstanceProfile Prelude.Text
instanceProfile_arn :: Lens' InstanceProfile Text
instanceProfile_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceProfile' {Text
arn :: Text
$sel:arn:InstanceProfile' :: InstanceProfile -> Text
arn} -> Text
arn) (\s :: InstanceProfile
s@InstanceProfile' {} Text
a -> InstanceProfile
s {$sel:arn:InstanceProfile' :: Text
arn = Text
a} :: InstanceProfile)

-- | The date when the instance profile was created.
instanceProfile_createDate :: Lens.Lens' InstanceProfile Prelude.UTCTime
instanceProfile_createDate :: Lens' InstanceProfile UTCTime
instanceProfile_createDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceProfile' {ISO8601
createDate :: ISO8601
$sel:createDate:InstanceProfile' :: InstanceProfile -> ISO8601
createDate} -> ISO8601
createDate) (\s :: InstanceProfile
s@InstanceProfile' {} ISO8601
a -> InstanceProfile
s {$sel:createDate:InstanceProfile' :: ISO8601
createDate = ISO8601
a} :: InstanceProfile) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The role associated with the instance profile.
instanceProfile_roles :: Lens.Lens' InstanceProfile [Role]
instanceProfile_roles :: Lens' InstanceProfile [Role]
instanceProfile_roles = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceProfile' {[Role]
roles :: [Role]
$sel:roles:InstanceProfile' :: InstanceProfile -> [Role]
roles} -> [Role]
roles) (\s :: InstanceProfile
s@InstanceProfile' {} [Role]
a -> InstanceProfile
s {$sel:roles:InstanceProfile' :: [Role]
roles = [Role]
a} :: InstanceProfile) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML InstanceProfile where
  parseXML :: [Node] -> Either String InstanceProfile
parseXML [Node]
x =
    Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> [Role]
-> InstanceProfile
InstanceProfile'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Tags"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Path")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"InstanceProfileName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"InstanceProfileId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Arn")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"CreateDate")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Roles"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member"
                  )

instance Prelude.Hashable InstanceProfile where
  hashWithSalt :: Int -> InstanceProfile -> Int
hashWithSalt Int
_salt InstanceProfile' {[Role]
Maybe [Tag]
Text
ISO8601
roles :: [Role]
createDate :: ISO8601
arn :: Text
instanceProfileId :: Text
instanceProfileName :: Text
path :: Text
tags :: Maybe [Tag]
$sel:roles:InstanceProfile' :: InstanceProfile -> [Role]
$sel:createDate:InstanceProfile' :: InstanceProfile -> ISO8601
$sel:arn:InstanceProfile' :: InstanceProfile -> Text
$sel:instanceProfileId:InstanceProfile' :: InstanceProfile -> Text
$sel:instanceProfileName:InstanceProfile' :: InstanceProfile -> Text
$sel:path:InstanceProfile' :: InstanceProfile -> Text
$sel:tags:InstanceProfile' :: InstanceProfile -> Maybe [Tag]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceProfileName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceProfileId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
createDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Role]
roles

instance Prelude.NFData InstanceProfile where
  rnf :: InstanceProfile -> ()
rnf InstanceProfile' {[Role]
Maybe [Tag]
Text
ISO8601
roles :: [Role]
createDate :: ISO8601
arn :: Text
instanceProfileId :: Text
instanceProfileName :: Text
path :: Text
tags :: Maybe [Tag]
$sel:roles:InstanceProfile' :: InstanceProfile -> [Role]
$sel:createDate:InstanceProfile' :: InstanceProfile -> ISO8601
$sel:arn:InstanceProfile' :: InstanceProfile -> Text
$sel:instanceProfileId:InstanceProfile' :: InstanceProfile -> Text
$sel:instanceProfileName:InstanceProfile' :: InstanceProfile -> Text
$sel:path:InstanceProfile' :: InstanceProfile -> Text
$sel:tags:InstanceProfile' :: InstanceProfile -> Maybe [Tag]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
path
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
instanceProfileName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
instanceProfileId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
createDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Role]
roles