{-# 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-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.IAM.Types.InstanceProfile where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.Role
import Amazonka.IAM.Types.Tag
import qualified Amazonka.Lens as Lens
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 :: Core.ISO8601,
    -- | The role associated with the instance profile.
    InstanceProfile -> [Role]
roles :: [Role]
  }
  deriving (InstanceProfile -> InstanceProfile -> Bool
(InstanceProfile -> InstanceProfile -> Bool)
-> (InstanceProfile -> InstanceProfile -> Bool)
-> Eq InstanceProfile
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]
(Int -> ReadS InstanceProfile)
-> ReadS [InstanceProfile]
-> ReadPrec InstanceProfile
-> ReadPrec [InstanceProfile]
-> Read 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
(Int -> InstanceProfile -> ShowS)
-> (InstanceProfile -> String)
-> ([InstanceProfile] -> ShowS)
-> Show InstanceProfile
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. InstanceProfile -> Rep InstanceProfile x)
-> (forall x. Rep InstanceProfile x -> InstanceProfile)
-> Generic InstanceProfile
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' :: Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> [Role]
-> InstanceProfile
InstanceProfile'
      { $sel:tags:InstanceProfile' :: Maybe [Tag]
tags = Maybe [Tag]
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 = Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreateDate_,
        $sel:roles:InstanceProfile' :: [Role]
roles = [Role]
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 :: (Maybe [Tag] -> f (Maybe [Tag]))
-> InstanceProfile -> f InstanceProfile
instanceProfile_tags = (InstanceProfile -> Maybe [Tag])
-> (InstanceProfile -> Maybe [Tag] -> InstanceProfile)
-> Lens InstanceProfile InstanceProfile (Maybe [Tag]) (Maybe [Tag])
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) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> InstanceProfile -> f InstanceProfile)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> InstanceProfile
-> f InstanceProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 AnIso [Tag] [Tag] [Tag] [Tag]
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 :: (Text -> f Text) -> InstanceProfile -> f InstanceProfile
instanceProfile_path = (InstanceProfile -> Text)
-> (InstanceProfile -> Text -> InstanceProfile)
-> Lens InstanceProfile InstanceProfile Text Text
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 :: (Text -> f Text) -> InstanceProfile -> f InstanceProfile
instanceProfile_instanceProfileName = (InstanceProfile -> Text)
-> (InstanceProfile -> Text -> InstanceProfile)
-> Lens InstanceProfile InstanceProfile Text Text
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 :: (Text -> f Text) -> InstanceProfile -> f InstanceProfile
instanceProfile_instanceProfileId = (InstanceProfile -> Text)
-> (InstanceProfile -> Text -> InstanceProfile)
-> Lens InstanceProfile InstanceProfile Text Text
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 :: (Text -> f Text) -> InstanceProfile -> f InstanceProfile
instanceProfile_arn = (InstanceProfile -> Text)
-> (InstanceProfile -> Text -> InstanceProfile)
-> Lens InstanceProfile InstanceProfile Text Text
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 :: (UTCTime -> f UTCTime) -> InstanceProfile -> f InstanceProfile
instanceProfile_createDate = (InstanceProfile -> ISO8601)
-> (InstanceProfile -> ISO8601 -> InstanceProfile)
-> Lens InstanceProfile InstanceProfile ISO8601 ISO8601
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) ((ISO8601 -> f ISO8601) -> InstanceProfile -> f InstanceProfile)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> InstanceProfile
-> f InstanceProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The role associated with the instance profile.
instanceProfile_roles :: Lens.Lens' InstanceProfile [Role]
instanceProfile_roles :: ([Role] -> f [Role]) -> InstanceProfile -> f InstanceProfile
instanceProfile_roles = (InstanceProfile -> [Role])
-> (InstanceProfile -> [Role] -> InstanceProfile)
-> Lens InstanceProfile InstanceProfile [Role] [Role]
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) (([Role] -> f [Role]) -> InstanceProfile -> f InstanceProfile)
-> (([Role] -> f [Role]) -> [Role] -> f [Role])
-> ([Role] -> f [Role])
-> InstanceProfile
-> f InstanceProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Role] -> f [Role]) -> [Role] -> f [Role]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable InstanceProfile

instance Prelude.NFData InstanceProfile