{-# 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.Config.Types.FailedRemediationExceptionBatch
-- 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.Config.Types.FailedRemediationExceptionBatch where

import Amazonka.Config.Types.RemediationException
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | List of each of the failed remediation exceptions with specific reasons.
--
-- /See:/ 'newFailedRemediationExceptionBatch' smart constructor.
data FailedRemediationExceptionBatch = FailedRemediationExceptionBatch'
  { -- | Returns a failure message. For example, the auto-remediation has failed.
    FailedRemediationExceptionBatch -> Maybe Text
failureMessage :: Prelude.Maybe Prelude.Text,
    -- | Returns remediation exception resource key object of the failed items.
    FailedRemediationExceptionBatch -> Maybe [RemediationException]
failedItems :: Prelude.Maybe [RemediationException]
  }
  deriving (FailedRemediationExceptionBatch
-> FailedRemediationExceptionBatch -> Bool
(FailedRemediationExceptionBatch
 -> FailedRemediationExceptionBatch -> Bool)
-> (FailedRemediationExceptionBatch
    -> FailedRemediationExceptionBatch -> Bool)
-> Eq FailedRemediationExceptionBatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailedRemediationExceptionBatch
-> FailedRemediationExceptionBatch -> Bool
$c/= :: FailedRemediationExceptionBatch
-> FailedRemediationExceptionBatch -> Bool
== :: FailedRemediationExceptionBatch
-> FailedRemediationExceptionBatch -> Bool
$c== :: FailedRemediationExceptionBatch
-> FailedRemediationExceptionBatch -> Bool
Prelude.Eq, ReadPrec [FailedRemediationExceptionBatch]
ReadPrec FailedRemediationExceptionBatch
Int -> ReadS FailedRemediationExceptionBatch
ReadS [FailedRemediationExceptionBatch]
(Int -> ReadS FailedRemediationExceptionBatch)
-> ReadS [FailedRemediationExceptionBatch]
-> ReadPrec FailedRemediationExceptionBatch
-> ReadPrec [FailedRemediationExceptionBatch]
-> Read FailedRemediationExceptionBatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailedRemediationExceptionBatch]
$creadListPrec :: ReadPrec [FailedRemediationExceptionBatch]
readPrec :: ReadPrec FailedRemediationExceptionBatch
$creadPrec :: ReadPrec FailedRemediationExceptionBatch
readList :: ReadS [FailedRemediationExceptionBatch]
$creadList :: ReadS [FailedRemediationExceptionBatch]
readsPrec :: Int -> ReadS FailedRemediationExceptionBatch
$creadsPrec :: Int -> ReadS FailedRemediationExceptionBatch
Prelude.Read, Int -> FailedRemediationExceptionBatch -> ShowS
[FailedRemediationExceptionBatch] -> ShowS
FailedRemediationExceptionBatch -> String
(Int -> FailedRemediationExceptionBatch -> ShowS)
-> (FailedRemediationExceptionBatch -> String)
-> ([FailedRemediationExceptionBatch] -> ShowS)
-> Show FailedRemediationExceptionBatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailedRemediationExceptionBatch] -> ShowS
$cshowList :: [FailedRemediationExceptionBatch] -> ShowS
show :: FailedRemediationExceptionBatch -> String
$cshow :: FailedRemediationExceptionBatch -> String
showsPrec :: Int -> FailedRemediationExceptionBatch -> ShowS
$cshowsPrec :: Int -> FailedRemediationExceptionBatch -> ShowS
Prelude.Show, (forall x.
 FailedRemediationExceptionBatch
 -> Rep FailedRemediationExceptionBatch x)
-> (forall x.
    Rep FailedRemediationExceptionBatch x
    -> FailedRemediationExceptionBatch)
-> Generic FailedRemediationExceptionBatch
forall x.
Rep FailedRemediationExceptionBatch x
-> FailedRemediationExceptionBatch
forall x.
FailedRemediationExceptionBatch
-> Rep FailedRemediationExceptionBatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FailedRemediationExceptionBatch x
-> FailedRemediationExceptionBatch
$cfrom :: forall x.
FailedRemediationExceptionBatch
-> Rep FailedRemediationExceptionBatch x
Prelude.Generic)

-- |
-- Create a value of 'FailedRemediationExceptionBatch' 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:
--
-- 'failureMessage', 'failedRemediationExceptionBatch_failureMessage' - Returns a failure message. For example, the auto-remediation has failed.
--
-- 'failedItems', 'failedRemediationExceptionBatch_failedItems' - Returns remediation exception resource key object of the failed items.
newFailedRemediationExceptionBatch ::
  FailedRemediationExceptionBatch
newFailedRemediationExceptionBatch :: FailedRemediationExceptionBatch
newFailedRemediationExceptionBatch =
  FailedRemediationExceptionBatch' :: Maybe Text
-> Maybe [RemediationException] -> FailedRemediationExceptionBatch
FailedRemediationExceptionBatch'
    { $sel:failureMessage:FailedRemediationExceptionBatch' :: Maybe Text
failureMessage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:failedItems:FailedRemediationExceptionBatch' :: Maybe [RemediationException]
failedItems = Maybe [RemediationException]
forall a. Maybe a
Prelude.Nothing
    }

-- | Returns a failure message. For example, the auto-remediation has failed.
failedRemediationExceptionBatch_failureMessage :: Lens.Lens' FailedRemediationExceptionBatch (Prelude.Maybe Prelude.Text)
failedRemediationExceptionBatch_failureMessage :: (Maybe Text -> f (Maybe Text))
-> FailedRemediationExceptionBatch
-> f FailedRemediationExceptionBatch
failedRemediationExceptionBatch_failureMessage = (FailedRemediationExceptionBatch -> Maybe Text)
-> (FailedRemediationExceptionBatch
    -> Maybe Text -> FailedRemediationExceptionBatch)
-> Lens
     FailedRemediationExceptionBatch
     FailedRemediationExceptionBatch
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedRemediationExceptionBatch' {Maybe Text
failureMessage :: Maybe Text
$sel:failureMessage:FailedRemediationExceptionBatch' :: FailedRemediationExceptionBatch -> Maybe Text
failureMessage} -> Maybe Text
failureMessage) (\s :: FailedRemediationExceptionBatch
s@FailedRemediationExceptionBatch' {} Maybe Text
a -> FailedRemediationExceptionBatch
s {$sel:failureMessage:FailedRemediationExceptionBatch' :: Maybe Text
failureMessage = Maybe Text
a} :: FailedRemediationExceptionBatch)

-- | Returns remediation exception resource key object of the failed items.
failedRemediationExceptionBatch_failedItems :: Lens.Lens' FailedRemediationExceptionBatch (Prelude.Maybe [RemediationException])
failedRemediationExceptionBatch_failedItems :: (Maybe [RemediationException] -> f (Maybe [RemediationException]))
-> FailedRemediationExceptionBatch
-> f FailedRemediationExceptionBatch
failedRemediationExceptionBatch_failedItems = (FailedRemediationExceptionBatch -> Maybe [RemediationException])
-> (FailedRemediationExceptionBatch
    -> Maybe [RemediationException] -> FailedRemediationExceptionBatch)
-> Lens
     FailedRemediationExceptionBatch
     FailedRemediationExceptionBatch
     (Maybe [RemediationException])
     (Maybe [RemediationException])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedRemediationExceptionBatch' {Maybe [RemediationException]
failedItems :: Maybe [RemediationException]
$sel:failedItems:FailedRemediationExceptionBatch' :: FailedRemediationExceptionBatch -> Maybe [RemediationException]
failedItems} -> Maybe [RemediationException]
failedItems) (\s :: FailedRemediationExceptionBatch
s@FailedRemediationExceptionBatch' {} Maybe [RemediationException]
a -> FailedRemediationExceptionBatch
s {$sel:failedItems:FailedRemediationExceptionBatch' :: Maybe [RemediationException]
failedItems = Maybe [RemediationException]
a} :: FailedRemediationExceptionBatch) ((Maybe [RemediationException] -> f (Maybe [RemediationException]))
 -> FailedRemediationExceptionBatch
 -> f FailedRemediationExceptionBatch)
-> ((Maybe [RemediationException]
     -> f (Maybe [RemediationException]))
    -> Maybe [RemediationException]
    -> f (Maybe [RemediationException]))
-> (Maybe [RemediationException]
    -> f (Maybe [RemediationException]))
-> FailedRemediationExceptionBatch
-> f FailedRemediationExceptionBatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [RemediationException]
  [RemediationException]
  [RemediationException]
  [RemediationException]
-> Iso
     (Maybe [RemediationException])
     (Maybe [RemediationException])
     (Maybe [RemediationException])
     (Maybe [RemediationException])
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
  [RemediationException]
  [RemediationException]
  [RemediationException]
  [RemediationException]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.FromJSON
    FailedRemediationExceptionBatch
  where
  parseJSON :: Value -> Parser FailedRemediationExceptionBatch
parseJSON =
    String
-> (Object -> Parser FailedRemediationExceptionBatch)
-> Value
-> Parser FailedRemediationExceptionBatch
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FailedRemediationExceptionBatch"
      ( \Object
x ->
          Maybe Text
-> Maybe [RemediationException] -> FailedRemediationExceptionBatch
FailedRemediationExceptionBatch'
            (Maybe Text
 -> Maybe [RemediationException] -> FailedRemediationExceptionBatch)
-> Parser (Maybe Text)
-> Parser
     (Maybe [RemediationException] -> FailedRemediationExceptionBatch)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FailureMessage")
            Parser
  (Maybe [RemediationException] -> FailedRemediationExceptionBatch)
-> Parser (Maybe [RemediationException])
-> Parser FailedRemediationExceptionBatch
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [RemediationException]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FailedItems" Parser (Maybe (Maybe [RemediationException]))
-> Maybe [RemediationException]
-> Parser (Maybe [RemediationException])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [RemediationException]
forall a. Monoid a => a
Prelude.mempty)
      )

instance
  Prelude.Hashable
    FailedRemediationExceptionBatch

instance
  Prelude.NFData
    FailedRemediationExceptionBatch