{-# 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.DeletionTaskFailureReasonType
-- 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.DeletionTaskFailureReasonType 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.RoleUsageType
import qualified Amazonka.Prelude as Prelude

-- | The reason that the service-linked role deletion failed.
--
-- This data type is used as a response element in the
-- GetServiceLinkedRoleDeletionStatus operation.
--
-- /See:/ 'newDeletionTaskFailureReasonType' smart constructor.
data DeletionTaskFailureReasonType = DeletionTaskFailureReasonType'
  { -- | A short description of the reason that the service-linked role deletion
    -- failed.
    DeletionTaskFailureReasonType -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | A list of objects that contains details about the service-linked role
    -- deletion failure, if that information is returned by the service. If the
    -- service-linked role has active sessions or if any resources that were
    -- used by the role have not been deleted from the linked service, the role
    -- can\'t be deleted. This parameter includes a list of the resources that
    -- are associated with the role and the Region in which the resources are
    -- being used.
    DeletionTaskFailureReasonType -> Maybe [RoleUsageType]
roleUsageList :: Prelude.Maybe [RoleUsageType]
  }
  deriving (DeletionTaskFailureReasonType
-> DeletionTaskFailureReasonType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletionTaskFailureReasonType
-> DeletionTaskFailureReasonType -> Bool
$c/= :: DeletionTaskFailureReasonType
-> DeletionTaskFailureReasonType -> Bool
== :: DeletionTaskFailureReasonType
-> DeletionTaskFailureReasonType -> Bool
$c== :: DeletionTaskFailureReasonType
-> DeletionTaskFailureReasonType -> Bool
Prelude.Eq, ReadPrec [DeletionTaskFailureReasonType]
ReadPrec DeletionTaskFailureReasonType
Int -> ReadS DeletionTaskFailureReasonType
ReadS [DeletionTaskFailureReasonType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletionTaskFailureReasonType]
$creadListPrec :: ReadPrec [DeletionTaskFailureReasonType]
readPrec :: ReadPrec DeletionTaskFailureReasonType
$creadPrec :: ReadPrec DeletionTaskFailureReasonType
readList :: ReadS [DeletionTaskFailureReasonType]
$creadList :: ReadS [DeletionTaskFailureReasonType]
readsPrec :: Int -> ReadS DeletionTaskFailureReasonType
$creadsPrec :: Int -> ReadS DeletionTaskFailureReasonType
Prelude.Read, Int -> DeletionTaskFailureReasonType -> ShowS
[DeletionTaskFailureReasonType] -> ShowS
DeletionTaskFailureReasonType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletionTaskFailureReasonType] -> ShowS
$cshowList :: [DeletionTaskFailureReasonType] -> ShowS
show :: DeletionTaskFailureReasonType -> String
$cshow :: DeletionTaskFailureReasonType -> String
showsPrec :: Int -> DeletionTaskFailureReasonType -> ShowS
$cshowsPrec :: Int -> DeletionTaskFailureReasonType -> ShowS
Prelude.Show, forall x.
Rep DeletionTaskFailureReasonType x
-> DeletionTaskFailureReasonType
forall x.
DeletionTaskFailureReasonType
-> Rep DeletionTaskFailureReasonType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeletionTaskFailureReasonType x
-> DeletionTaskFailureReasonType
$cfrom :: forall x.
DeletionTaskFailureReasonType
-> Rep DeletionTaskFailureReasonType x
Prelude.Generic)

-- |
-- Create a value of 'DeletionTaskFailureReasonType' 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:
--
-- 'reason', 'deletionTaskFailureReasonType_reason' - A short description of the reason that the service-linked role deletion
-- failed.
--
-- 'roleUsageList', 'deletionTaskFailureReasonType_roleUsageList' - A list of objects that contains details about the service-linked role
-- deletion failure, if that information is returned by the service. If the
-- service-linked role has active sessions or if any resources that were
-- used by the role have not been deleted from the linked service, the role
-- can\'t be deleted. This parameter includes a list of the resources that
-- are associated with the role and the Region in which the resources are
-- being used.
newDeletionTaskFailureReasonType ::
  DeletionTaskFailureReasonType
newDeletionTaskFailureReasonType :: DeletionTaskFailureReasonType
newDeletionTaskFailureReasonType =
  DeletionTaskFailureReasonType'
    { $sel:reason:DeletionTaskFailureReasonType' :: Maybe Text
reason =
        forall a. Maybe a
Prelude.Nothing,
      $sel:roleUsageList:DeletionTaskFailureReasonType' :: Maybe [RoleUsageType]
roleUsageList = forall a. Maybe a
Prelude.Nothing
    }

-- | A short description of the reason that the service-linked role deletion
-- failed.
deletionTaskFailureReasonType_reason :: Lens.Lens' DeletionTaskFailureReasonType (Prelude.Maybe Prelude.Text)
deletionTaskFailureReasonType_reason :: Lens' DeletionTaskFailureReasonType (Maybe Text)
deletionTaskFailureReasonType_reason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletionTaskFailureReasonType' {Maybe Text
reason :: Maybe Text
$sel:reason:DeletionTaskFailureReasonType' :: DeletionTaskFailureReasonType -> Maybe Text
reason} -> Maybe Text
reason) (\s :: DeletionTaskFailureReasonType
s@DeletionTaskFailureReasonType' {} Maybe Text
a -> DeletionTaskFailureReasonType
s {$sel:reason:DeletionTaskFailureReasonType' :: Maybe Text
reason = Maybe Text
a} :: DeletionTaskFailureReasonType)

-- | A list of objects that contains details about the service-linked role
-- deletion failure, if that information is returned by the service. If the
-- service-linked role has active sessions or if any resources that were
-- used by the role have not been deleted from the linked service, the role
-- can\'t be deleted. This parameter includes a list of the resources that
-- are associated with the role and the Region in which the resources are
-- being used.
deletionTaskFailureReasonType_roleUsageList :: Lens.Lens' DeletionTaskFailureReasonType (Prelude.Maybe [RoleUsageType])
deletionTaskFailureReasonType_roleUsageList :: Lens' DeletionTaskFailureReasonType (Maybe [RoleUsageType])
deletionTaskFailureReasonType_roleUsageList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletionTaskFailureReasonType' {Maybe [RoleUsageType]
roleUsageList :: Maybe [RoleUsageType]
$sel:roleUsageList:DeletionTaskFailureReasonType' :: DeletionTaskFailureReasonType -> Maybe [RoleUsageType]
roleUsageList} -> Maybe [RoleUsageType]
roleUsageList) (\s :: DeletionTaskFailureReasonType
s@DeletionTaskFailureReasonType' {} Maybe [RoleUsageType]
a -> DeletionTaskFailureReasonType
s {$sel:roleUsageList:DeletionTaskFailureReasonType' :: Maybe [RoleUsageType]
roleUsageList = Maybe [RoleUsageType]
a} :: DeletionTaskFailureReasonType) 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

instance Data.FromXML DeletionTaskFailureReasonType where
  parseXML :: [Node] -> Either String DeletionTaskFailureReasonType
parseXML [Node]
x =
    Maybe Text
-> Maybe [RoleUsageType] -> DeletionTaskFailureReasonType
DeletionTaskFailureReasonType'
      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
"Reason")
      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
"RoleUsageList"
                      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")
                  )

instance
  Prelude.Hashable
    DeletionTaskFailureReasonType
  where
  hashWithSalt :: Int -> DeletionTaskFailureReasonType -> Int
hashWithSalt Int
_salt DeletionTaskFailureReasonType' {Maybe [RoleUsageType]
Maybe Text
roleUsageList :: Maybe [RoleUsageType]
reason :: Maybe Text
$sel:roleUsageList:DeletionTaskFailureReasonType' :: DeletionTaskFailureReasonType -> Maybe [RoleUsageType]
$sel:reason:DeletionTaskFailureReasonType' :: DeletionTaskFailureReasonType -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [RoleUsageType]
roleUsageList

instance Prelude.NFData DeletionTaskFailureReasonType where
  rnf :: DeletionTaskFailureReasonType -> ()
rnf DeletionTaskFailureReasonType' {Maybe [RoleUsageType]
Maybe Text
roleUsageList :: Maybe [RoleUsageType]
reason :: Maybe Text
$sel:roleUsageList:DeletionTaskFailureReasonType' :: DeletionTaskFailureReasonType -> Maybe [RoleUsageType]
$sel:reason:DeletionTaskFailureReasonType' :: DeletionTaskFailureReasonType -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [RoleUsageType]
roleUsageList