{-# 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-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.DeletionTaskFailureReasonType where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.RoleUsageType
import qualified Amazonka.Lens as Lens
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 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],
    -- | A short description of the reason that the service-linked role deletion
    -- failed.
    DeletionTaskFailureReasonType -> Maybe Text
reason :: Prelude.Maybe Prelude.Text
  }
  deriving (DeletionTaskFailureReasonType
-> DeletionTaskFailureReasonType -> Bool
(DeletionTaskFailureReasonType
 -> DeletionTaskFailureReasonType -> Bool)
-> (DeletionTaskFailureReasonType
    -> DeletionTaskFailureReasonType -> Bool)
-> Eq DeletionTaskFailureReasonType
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]
(Int -> ReadS DeletionTaskFailureReasonType)
-> ReadS [DeletionTaskFailureReasonType]
-> ReadPrec DeletionTaskFailureReasonType
-> ReadPrec [DeletionTaskFailureReasonType]
-> Read 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
(Int -> DeletionTaskFailureReasonType -> ShowS)
-> (DeletionTaskFailureReasonType -> String)
-> ([DeletionTaskFailureReasonType] -> ShowS)
-> Show DeletionTaskFailureReasonType
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.
 DeletionTaskFailureReasonType
 -> Rep DeletionTaskFailureReasonType x)
-> (forall x.
    Rep DeletionTaskFailureReasonType x
    -> DeletionTaskFailureReasonType)
-> Generic DeletionTaskFailureReasonType
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:
--
-- '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.
--
-- 'reason', 'deletionTaskFailureReasonType_reason' - A short description of the reason that the service-linked role deletion
-- failed.
newDeletionTaskFailureReasonType ::
  DeletionTaskFailureReasonType
newDeletionTaskFailureReasonType :: DeletionTaskFailureReasonType
newDeletionTaskFailureReasonType =
  DeletionTaskFailureReasonType' :: Maybe [RoleUsageType]
-> Maybe Text -> DeletionTaskFailureReasonType
DeletionTaskFailureReasonType'
    { $sel:roleUsageList:DeletionTaskFailureReasonType' :: Maybe [RoleUsageType]
roleUsageList =
        Maybe [RoleUsageType]
forall a. Maybe a
Prelude.Nothing,
      $sel:reason:DeletionTaskFailureReasonType' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe [RoleUsageType] -> f (Maybe [RoleUsageType]))
-> DeletionTaskFailureReasonType -> f DeletionTaskFailureReasonType
deletionTaskFailureReasonType_roleUsageList = (DeletionTaskFailureReasonType -> Maybe [RoleUsageType])
-> (DeletionTaskFailureReasonType
    -> Maybe [RoleUsageType] -> DeletionTaskFailureReasonType)
-> Lens
     DeletionTaskFailureReasonType
     DeletionTaskFailureReasonType
     (Maybe [RoleUsageType])
     (Maybe [RoleUsageType])
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) ((Maybe [RoleUsageType] -> f (Maybe [RoleUsageType]))
 -> DeletionTaskFailureReasonType
 -> f DeletionTaskFailureReasonType)
-> ((Maybe [RoleUsageType] -> f (Maybe [RoleUsageType]))
    -> Maybe [RoleUsageType] -> f (Maybe [RoleUsageType]))
-> (Maybe [RoleUsageType] -> f (Maybe [RoleUsageType]))
-> DeletionTaskFailureReasonType
-> f DeletionTaskFailureReasonType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [RoleUsageType] [RoleUsageType] [RoleUsageType] [RoleUsageType]
-> Iso
     (Maybe [RoleUsageType])
     (Maybe [RoleUsageType])
     (Maybe [RoleUsageType])
     (Maybe [RoleUsageType])
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
  [RoleUsageType] [RoleUsageType] [RoleUsageType] [RoleUsageType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A short description of the reason that the service-linked role deletion
-- failed.
deletionTaskFailureReasonType_reason :: Lens.Lens' DeletionTaskFailureReasonType (Prelude.Maybe Prelude.Text)
deletionTaskFailureReasonType_reason :: (Maybe Text -> f (Maybe Text))
-> DeletionTaskFailureReasonType -> f DeletionTaskFailureReasonType
deletionTaskFailureReasonType_reason = (DeletionTaskFailureReasonType -> Maybe Text)
-> (DeletionTaskFailureReasonType
    -> Maybe Text -> DeletionTaskFailureReasonType)
-> Lens
     DeletionTaskFailureReasonType
     DeletionTaskFailureReasonType
     (Maybe Text)
     (Maybe Text)
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)

instance Core.FromXML DeletionTaskFailureReasonType where
  parseXML :: [Node] -> Either String DeletionTaskFailureReasonType
parseXML [Node]
x =
    Maybe [RoleUsageType]
-> Maybe Text -> DeletionTaskFailureReasonType
DeletionTaskFailureReasonType'
      (Maybe [RoleUsageType]
 -> Maybe Text -> DeletionTaskFailureReasonType)
-> Either String (Maybe [RoleUsageType])
-> Either String (Maybe Text -> DeletionTaskFailureReasonType)
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
"RoleUsageList" 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 [RoleUsageType]))
-> Either String (Maybe [RoleUsageType])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [RoleUsageType])
-> [Node] -> Either String (Maybe [RoleUsageType])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [RoleUsageType]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either String (Maybe Text -> DeletionTaskFailureReasonType)
-> Either String (Maybe Text)
-> Either String DeletionTaskFailureReasonType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Reason")

instance
  Prelude.Hashable
    DeletionTaskFailureReasonType

instance Prelude.NFData DeletionTaskFailureReasonType