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

import Amazonka.Config.Types.RemediationConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'FailedRemediationBatch' 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:
--
-- 'failedItems', 'failedRemediationBatch_failedItems' - Returns remediation configurations of the failed items.
--
-- 'failureMessage', 'failedRemediationBatch_failureMessage' - Returns a failure message. For example, the resource is already
-- compliant.
newFailedRemediationBatch ::
  FailedRemediationBatch
newFailedRemediationBatch :: FailedRemediationBatch
newFailedRemediationBatch =
  FailedRemediationBatch'
    { $sel:failedItems:FailedRemediationBatch' :: Maybe [RemediationConfiguration]
failedItems =
        forall a. Maybe a
Prelude.Nothing,
      $sel:failureMessage:FailedRemediationBatch' :: Maybe Text
failureMessage = forall a. Maybe a
Prelude.Nothing
    }

-- | Returns remediation configurations of the failed items.
failedRemediationBatch_failedItems :: Lens.Lens' FailedRemediationBatch (Prelude.Maybe [RemediationConfiguration])
failedRemediationBatch_failedItems :: Lens' FailedRemediationBatch (Maybe [RemediationConfiguration])
failedRemediationBatch_failedItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedRemediationBatch' {Maybe [RemediationConfiguration]
failedItems :: Maybe [RemediationConfiguration]
$sel:failedItems:FailedRemediationBatch' :: FailedRemediationBatch -> Maybe [RemediationConfiguration]
failedItems} -> Maybe [RemediationConfiguration]
failedItems) (\s :: FailedRemediationBatch
s@FailedRemediationBatch' {} Maybe [RemediationConfiguration]
a -> FailedRemediationBatch
s {$sel:failedItems:FailedRemediationBatch' :: Maybe [RemediationConfiguration]
failedItems = Maybe [RemediationConfiguration]
a} :: FailedRemediationBatch) 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

-- | Returns a failure message. For example, the resource is already
-- compliant.
failedRemediationBatch_failureMessage :: Lens.Lens' FailedRemediationBatch (Prelude.Maybe Prelude.Text)
failedRemediationBatch_failureMessage :: Lens' FailedRemediationBatch (Maybe Text)
failedRemediationBatch_failureMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedRemediationBatch' {Maybe Text
failureMessage :: Maybe Text
$sel:failureMessage:FailedRemediationBatch' :: FailedRemediationBatch -> Maybe Text
failureMessage} -> Maybe Text
failureMessage) (\s :: FailedRemediationBatch
s@FailedRemediationBatch' {} Maybe Text
a -> FailedRemediationBatch
s {$sel:failureMessage:FailedRemediationBatch' :: Maybe Text
failureMessage = Maybe Text
a} :: FailedRemediationBatch)

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

instance Prelude.Hashable FailedRemediationBatch where
  hashWithSalt :: Int -> FailedRemediationBatch -> Int
hashWithSalt Int
_salt FailedRemediationBatch' {Maybe [RemediationConfiguration]
Maybe Text
failureMessage :: Maybe Text
failedItems :: Maybe [RemediationConfiguration]
$sel:failureMessage:FailedRemediationBatch' :: FailedRemediationBatch -> Maybe Text
$sel:failedItems:FailedRemediationBatch' :: FailedRemediationBatch -> Maybe [RemediationConfiguration]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [RemediationConfiguration]
failedItems
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
failureMessage

instance Prelude.NFData FailedRemediationBatch where
  rnf :: FailedRemediationBatch -> ()
rnf FailedRemediationBatch' {Maybe [RemediationConfiguration]
Maybe Text
failureMessage :: Maybe Text
failedItems :: Maybe [RemediationConfiguration]
$sel:failureMessage:FailedRemediationBatch' :: FailedRemediationBatch -> Maybe Text
$sel:failedItems:FailedRemediationBatch' :: FailedRemediationBatch -> Maybe [RemediationConfiguration]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [RemediationConfiguration]
failedItems
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
failureMessage