{-# 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.EC2.Types.IamInstanceProfileAssociation
-- 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.EC2.Types.IamInstanceProfileAssociation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.IamInstanceProfile
import Amazonka.EC2.Types.IamInstanceProfileAssociationState
import qualified Amazonka.Prelude as Prelude

-- | Describes an association between an IAM instance profile and an
-- instance.
--
-- /See:/ 'newIamInstanceProfileAssociation' smart constructor.
data IamInstanceProfileAssociation = IamInstanceProfileAssociation'
  { -- | The ID of the association.
    IamInstanceProfileAssociation -> Maybe Text
associationId :: Prelude.Maybe Prelude.Text,
    -- | The IAM instance profile.
    IamInstanceProfileAssociation -> Maybe IamInstanceProfile
iamInstanceProfile :: Prelude.Maybe IamInstanceProfile,
    -- | The ID of the instance.
    IamInstanceProfileAssociation -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The state of the association.
    IamInstanceProfileAssociation
-> Maybe IamInstanceProfileAssociationState
state :: Prelude.Maybe IamInstanceProfileAssociationState,
    -- | The time the IAM instance profile was associated with the instance.
    IamInstanceProfileAssociation -> Maybe ISO8601
timestamp :: Prelude.Maybe Data.ISO8601
  }
  deriving (IamInstanceProfileAssociation
-> IamInstanceProfileAssociation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IamInstanceProfileAssociation
-> IamInstanceProfileAssociation -> Bool
$c/= :: IamInstanceProfileAssociation
-> IamInstanceProfileAssociation -> Bool
== :: IamInstanceProfileAssociation
-> IamInstanceProfileAssociation -> Bool
$c== :: IamInstanceProfileAssociation
-> IamInstanceProfileAssociation -> Bool
Prelude.Eq, ReadPrec [IamInstanceProfileAssociation]
ReadPrec IamInstanceProfileAssociation
Int -> ReadS IamInstanceProfileAssociation
ReadS [IamInstanceProfileAssociation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IamInstanceProfileAssociation]
$creadListPrec :: ReadPrec [IamInstanceProfileAssociation]
readPrec :: ReadPrec IamInstanceProfileAssociation
$creadPrec :: ReadPrec IamInstanceProfileAssociation
readList :: ReadS [IamInstanceProfileAssociation]
$creadList :: ReadS [IamInstanceProfileAssociation]
readsPrec :: Int -> ReadS IamInstanceProfileAssociation
$creadsPrec :: Int -> ReadS IamInstanceProfileAssociation
Prelude.Read, Int -> IamInstanceProfileAssociation -> ShowS
[IamInstanceProfileAssociation] -> ShowS
IamInstanceProfileAssociation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IamInstanceProfileAssociation] -> ShowS
$cshowList :: [IamInstanceProfileAssociation] -> ShowS
show :: IamInstanceProfileAssociation -> String
$cshow :: IamInstanceProfileAssociation -> String
showsPrec :: Int -> IamInstanceProfileAssociation -> ShowS
$cshowsPrec :: Int -> IamInstanceProfileAssociation -> ShowS
Prelude.Show, forall x.
Rep IamInstanceProfileAssociation x
-> IamInstanceProfileAssociation
forall x.
IamInstanceProfileAssociation
-> Rep IamInstanceProfileAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IamInstanceProfileAssociation x
-> IamInstanceProfileAssociation
$cfrom :: forall x.
IamInstanceProfileAssociation
-> Rep IamInstanceProfileAssociation x
Prelude.Generic)

-- |
-- Create a value of 'IamInstanceProfileAssociation' 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:
--
-- 'associationId', 'iamInstanceProfileAssociation_associationId' - The ID of the association.
--
-- 'iamInstanceProfile', 'iamInstanceProfileAssociation_iamInstanceProfile' - The IAM instance profile.
--
-- 'instanceId', 'iamInstanceProfileAssociation_instanceId' - The ID of the instance.
--
-- 'state', 'iamInstanceProfileAssociation_state' - The state of the association.
--
-- 'timestamp', 'iamInstanceProfileAssociation_timestamp' - The time the IAM instance profile was associated with the instance.
newIamInstanceProfileAssociation ::
  IamInstanceProfileAssociation
newIamInstanceProfileAssociation :: IamInstanceProfileAssociation
newIamInstanceProfileAssociation =
  IamInstanceProfileAssociation'
    { $sel:associationId:IamInstanceProfileAssociation' :: Maybe Text
associationId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:iamInstanceProfile:IamInstanceProfileAssociation' :: Maybe IamInstanceProfile
iamInstanceProfile = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:IamInstanceProfileAssociation' :: Maybe Text
instanceId = forall a. Maybe a
Prelude.Nothing,
      $sel:state:IamInstanceProfileAssociation' :: Maybe IamInstanceProfileAssociationState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:IamInstanceProfileAssociation' :: Maybe ISO8601
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the association.
iamInstanceProfileAssociation_associationId :: Lens.Lens' IamInstanceProfileAssociation (Prelude.Maybe Prelude.Text)
iamInstanceProfileAssociation_associationId :: Lens' IamInstanceProfileAssociation (Maybe Text)
iamInstanceProfileAssociation_associationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IamInstanceProfileAssociation' {Maybe Text
associationId :: Maybe Text
$sel:associationId:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe Text
associationId} -> Maybe Text
associationId) (\s :: IamInstanceProfileAssociation
s@IamInstanceProfileAssociation' {} Maybe Text
a -> IamInstanceProfileAssociation
s {$sel:associationId:IamInstanceProfileAssociation' :: Maybe Text
associationId = Maybe Text
a} :: IamInstanceProfileAssociation)

-- | The IAM instance profile.
iamInstanceProfileAssociation_iamInstanceProfile :: Lens.Lens' IamInstanceProfileAssociation (Prelude.Maybe IamInstanceProfile)
iamInstanceProfileAssociation_iamInstanceProfile :: Lens' IamInstanceProfileAssociation (Maybe IamInstanceProfile)
iamInstanceProfileAssociation_iamInstanceProfile = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IamInstanceProfileAssociation' {Maybe IamInstanceProfile
iamInstanceProfile :: Maybe IamInstanceProfile
$sel:iamInstanceProfile:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe IamInstanceProfile
iamInstanceProfile} -> Maybe IamInstanceProfile
iamInstanceProfile) (\s :: IamInstanceProfileAssociation
s@IamInstanceProfileAssociation' {} Maybe IamInstanceProfile
a -> IamInstanceProfileAssociation
s {$sel:iamInstanceProfile:IamInstanceProfileAssociation' :: Maybe IamInstanceProfile
iamInstanceProfile = Maybe IamInstanceProfile
a} :: IamInstanceProfileAssociation)

-- | The ID of the instance.
iamInstanceProfileAssociation_instanceId :: Lens.Lens' IamInstanceProfileAssociation (Prelude.Maybe Prelude.Text)
iamInstanceProfileAssociation_instanceId :: Lens' IamInstanceProfileAssociation (Maybe Text)
iamInstanceProfileAssociation_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IamInstanceProfileAssociation' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: IamInstanceProfileAssociation
s@IamInstanceProfileAssociation' {} Maybe Text
a -> IamInstanceProfileAssociation
s {$sel:instanceId:IamInstanceProfileAssociation' :: Maybe Text
instanceId = Maybe Text
a} :: IamInstanceProfileAssociation)

-- | The state of the association.
iamInstanceProfileAssociation_state :: Lens.Lens' IamInstanceProfileAssociation (Prelude.Maybe IamInstanceProfileAssociationState)
iamInstanceProfileAssociation_state :: Lens'
  IamInstanceProfileAssociation
  (Maybe IamInstanceProfileAssociationState)
iamInstanceProfileAssociation_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IamInstanceProfileAssociation' {Maybe IamInstanceProfileAssociationState
state :: Maybe IamInstanceProfileAssociationState
$sel:state:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation
-> Maybe IamInstanceProfileAssociationState
state} -> Maybe IamInstanceProfileAssociationState
state) (\s :: IamInstanceProfileAssociation
s@IamInstanceProfileAssociation' {} Maybe IamInstanceProfileAssociationState
a -> IamInstanceProfileAssociation
s {$sel:state:IamInstanceProfileAssociation' :: Maybe IamInstanceProfileAssociationState
state = Maybe IamInstanceProfileAssociationState
a} :: IamInstanceProfileAssociation)

-- | The time the IAM instance profile was associated with the instance.
iamInstanceProfileAssociation_timestamp :: Lens.Lens' IamInstanceProfileAssociation (Prelude.Maybe Prelude.UTCTime)
iamInstanceProfileAssociation_timestamp :: Lens' IamInstanceProfileAssociation (Maybe UTCTime)
iamInstanceProfileAssociation_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IamInstanceProfileAssociation' {Maybe ISO8601
timestamp :: Maybe ISO8601
$sel:timestamp:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe ISO8601
timestamp} -> Maybe ISO8601
timestamp) (\s :: IamInstanceProfileAssociation
s@IamInstanceProfileAssociation' {} Maybe ISO8601
a -> IamInstanceProfileAssociation
s {$sel:timestamp:IamInstanceProfileAssociation' :: Maybe ISO8601
timestamp = Maybe ISO8601
a} :: IamInstanceProfileAssociation) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromXML IamInstanceProfileAssociation where
  parseXML :: [Node] -> Either String IamInstanceProfileAssociation
parseXML [Node]
x =
    Maybe Text
-> Maybe IamInstanceProfile
-> Maybe Text
-> Maybe IamInstanceProfileAssociationState
-> Maybe ISO8601
-> IamInstanceProfileAssociation
IamInstanceProfileAssociation'
      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
"associationId")
      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
"iamInstanceProfile")
      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
"instanceId")
      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
"state")
      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
"timestamp")

instance
  Prelude.Hashable
    IamInstanceProfileAssociation
  where
  hashWithSalt :: Int -> IamInstanceProfileAssociation -> Int
hashWithSalt Int
_salt IamInstanceProfileAssociation' {Maybe Text
Maybe ISO8601
Maybe IamInstanceProfile
Maybe IamInstanceProfileAssociationState
timestamp :: Maybe ISO8601
state :: Maybe IamInstanceProfileAssociationState
instanceId :: Maybe Text
iamInstanceProfile :: Maybe IamInstanceProfile
associationId :: Maybe Text
$sel:timestamp:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe ISO8601
$sel:state:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation
-> Maybe IamInstanceProfileAssociationState
$sel:instanceId:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe Text
$sel:iamInstanceProfile:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe IamInstanceProfile
$sel:associationId:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
associationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IamInstanceProfile
iamInstanceProfile
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IamInstanceProfileAssociationState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
timestamp

instance Prelude.NFData IamInstanceProfileAssociation where
  rnf :: IamInstanceProfileAssociation -> ()
rnf IamInstanceProfileAssociation' {Maybe Text
Maybe ISO8601
Maybe IamInstanceProfile
Maybe IamInstanceProfileAssociationState
timestamp :: Maybe ISO8601
state :: Maybe IamInstanceProfileAssociationState
instanceId :: Maybe Text
iamInstanceProfile :: Maybe IamInstanceProfile
associationId :: Maybe Text
$sel:timestamp:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe ISO8601
$sel:state:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation
-> Maybe IamInstanceProfileAssociationState
$sel:instanceId:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe Text
$sel:iamInstanceProfile:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe IamInstanceProfile
$sel:associationId:IamInstanceProfileAssociation' :: IamInstanceProfileAssociation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
associationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IamInstanceProfile
iamInstanceProfile
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IamInstanceProfileAssociationState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
timestamp