{-# 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.CloudWatch.Types.PartialFailure
-- 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.CloudWatch.Types.PartialFailure where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | This array is empty if the API operation was successful for all the
-- rules specified in the request. If the operation could not process one
-- of the rules, the following data is returned for each of those rules.
--
-- /See:/ 'newPartialFailure' smart constructor.
data PartialFailure = PartialFailure'
  { -- | The specified rule that could not be deleted.
    PartialFailure -> Maybe Text
failureResource :: Prelude.Maybe Prelude.Text,
    -- | The code of the error.
    PartialFailure -> Maybe Text
failureCode :: Prelude.Maybe Prelude.Text,
    -- | A description of the error.
    PartialFailure -> Maybe Text
failureDescription :: Prelude.Maybe Prelude.Text,
    -- | The type of error.
    PartialFailure -> Maybe Text
exceptionType :: Prelude.Maybe Prelude.Text
  }
  deriving (PartialFailure -> PartialFailure -> Bool
(PartialFailure -> PartialFailure -> Bool)
-> (PartialFailure -> PartialFailure -> Bool) -> Eq PartialFailure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartialFailure -> PartialFailure -> Bool
$c/= :: PartialFailure -> PartialFailure -> Bool
== :: PartialFailure -> PartialFailure -> Bool
$c== :: PartialFailure -> PartialFailure -> Bool
Prelude.Eq, ReadPrec [PartialFailure]
ReadPrec PartialFailure
Int -> ReadS PartialFailure
ReadS [PartialFailure]
(Int -> ReadS PartialFailure)
-> ReadS [PartialFailure]
-> ReadPrec PartialFailure
-> ReadPrec [PartialFailure]
-> Read PartialFailure
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartialFailure]
$creadListPrec :: ReadPrec [PartialFailure]
readPrec :: ReadPrec PartialFailure
$creadPrec :: ReadPrec PartialFailure
readList :: ReadS [PartialFailure]
$creadList :: ReadS [PartialFailure]
readsPrec :: Int -> ReadS PartialFailure
$creadsPrec :: Int -> ReadS PartialFailure
Prelude.Read, Int -> PartialFailure -> ShowS
[PartialFailure] -> ShowS
PartialFailure -> String
(Int -> PartialFailure -> ShowS)
-> (PartialFailure -> String)
-> ([PartialFailure] -> ShowS)
-> Show PartialFailure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartialFailure] -> ShowS
$cshowList :: [PartialFailure] -> ShowS
show :: PartialFailure -> String
$cshow :: PartialFailure -> String
showsPrec :: Int -> PartialFailure -> ShowS
$cshowsPrec :: Int -> PartialFailure -> ShowS
Prelude.Show, (forall x. PartialFailure -> Rep PartialFailure x)
-> (forall x. Rep PartialFailure x -> PartialFailure)
-> Generic PartialFailure
forall x. Rep PartialFailure x -> PartialFailure
forall x. PartialFailure -> Rep PartialFailure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PartialFailure x -> PartialFailure
$cfrom :: forall x. PartialFailure -> Rep PartialFailure x
Prelude.Generic)

-- |
-- Create a value of 'PartialFailure' 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:
--
-- 'failureResource', 'partialFailure_failureResource' - The specified rule that could not be deleted.
--
-- 'failureCode', 'partialFailure_failureCode' - The code of the error.
--
-- 'failureDescription', 'partialFailure_failureDescription' - A description of the error.
--
-- 'exceptionType', 'partialFailure_exceptionType' - The type of error.
newPartialFailure ::
  PartialFailure
newPartialFailure :: PartialFailure
newPartialFailure =
  PartialFailure' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> PartialFailure
PartialFailure'
    { $sel:failureResource:PartialFailure' :: Maybe Text
failureResource = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:failureCode:PartialFailure' :: Maybe Text
failureCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:failureDescription:PartialFailure' :: Maybe Text
failureDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:exceptionType:PartialFailure' :: Maybe Text
exceptionType = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The specified rule that could not be deleted.
partialFailure_failureResource :: Lens.Lens' PartialFailure (Prelude.Maybe Prelude.Text)
partialFailure_failureResource :: (Maybe Text -> f (Maybe Text))
-> PartialFailure -> f PartialFailure
partialFailure_failureResource = (PartialFailure -> Maybe Text)
-> (PartialFailure -> Maybe Text -> PartialFailure)
-> Lens PartialFailure PartialFailure (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartialFailure' {Maybe Text
failureResource :: Maybe Text
$sel:failureResource:PartialFailure' :: PartialFailure -> Maybe Text
failureResource} -> Maybe Text
failureResource) (\s :: PartialFailure
s@PartialFailure' {} Maybe Text
a -> PartialFailure
s {$sel:failureResource:PartialFailure' :: Maybe Text
failureResource = Maybe Text
a} :: PartialFailure)

-- | The code of the error.
partialFailure_failureCode :: Lens.Lens' PartialFailure (Prelude.Maybe Prelude.Text)
partialFailure_failureCode :: (Maybe Text -> f (Maybe Text))
-> PartialFailure -> f PartialFailure
partialFailure_failureCode = (PartialFailure -> Maybe Text)
-> (PartialFailure -> Maybe Text -> PartialFailure)
-> Lens PartialFailure PartialFailure (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartialFailure' {Maybe Text
failureCode :: Maybe Text
$sel:failureCode:PartialFailure' :: PartialFailure -> Maybe Text
failureCode} -> Maybe Text
failureCode) (\s :: PartialFailure
s@PartialFailure' {} Maybe Text
a -> PartialFailure
s {$sel:failureCode:PartialFailure' :: Maybe Text
failureCode = Maybe Text
a} :: PartialFailure)

-- | A description of the error.
partialFailure_failureDescription :: Lens.Lens' PartialFailure (Prelude.Maybe Prelude.Text)
partialFailure_failureDescription :: (Maybe Text -> f (Maybe Text))
-> PartialFailure -> f PartialFailure
partialFailure_failureDescription = (PartialFailure -> Maybe Text)
-> (PartialFailure -> Maybe Text -> PartialFailure)
-> Lens PartialFailure PartialFailure (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartialFailure' {Maybe Text
failureDescription :: Maybe Text
$sel:failureDescription:PartialFailure' :: PartialFailure -> Maybe Text
failureDescription} -> Maybe Text
failureDescription) (\s :: PartialFailure
s@PartialFailure' {} Maybe Text
a -> PartialFailure
s {$sel:failureDescription:PartialFailure' :: Maybe Text
failureDescription = Maybe Text
a} :: PartialFailure)

-- | The type of error.
partialFailure_exceptionType :: Lens.Lens' PartialFailure (Prelude.Maybe Prelude.Text)
partialFailure_exceptionType :: (Maybe Text -> f (Maybe Text))
-> PartialFailure -> f PartialFailure
partialFailure_exceptionType = (PartialFailure -> Maybe Text)
-> (PartialFailure -> Maybe Text -> PartialFailure)
-> Lens PartialFailure PartialFailure (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartialFailure' {Maybe Text
exceptionType :: Maybe Text
$sel:exceptionType:PartialFailure' :: PartialFailure -> Maybe Text
exceptionType} -> Maybe Text
exceptionType) (\s :: PartialFailure
s@PartialFailure' {} Maybe Text
a -> PartialFailure
s {$sel:exceptionType:PartialFailure' :: Maybe Text
exceptionType = Maybe Text
a} :: PartialFailure)

instance Core.FromXML PartialFailure where
  parseXML :: [Node] -> Either String PartialFailure
parseXML [Node]
x =
    Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> PartialFailure
PartialFailure'
      (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> PartialFailure)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> Maybe Text -> PartialFailure)
forall (f :: * -> *) a b. Functor 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
"FailureResource")
      Either
  String (Maybe Text -> Maybe Text -> Maybe Text -> PartialFailure)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Text -> PartialFailure)
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
"FailureCode")
      Either String (Maybe Text -> Maybe Text -> PartialFailure)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> PartialFailure)
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
"FailureDescription")
      Either String (Maybe Text -> PartialFailure)
-> Either String (Maybe Text) -> Either String PartialFailure
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
"ExceptionType")

instance Prelude.Hashable PartialFailure

instance Prelude.NFData PartialFailure