{-# 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.ElastiCache.Types.UpdateActionResultsMessage
-- 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.ElastiCache.Types.UpdateActionResultsMessage where

import qualified Amazonka.Core as Core
import Amazonka.ElastiCache.Types.ProcessedUpdateAction
import Amazonka.ElastiCache.Types.UnprocessedUpdateAction
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newUpdateActionResultsMessage' smart constructor.
data UpdateActionResultsMessage = UpdateActionResultsMessage'
  { -- | Update actions that haven\'t been processed successfully
    UpdateActionResultsMessage -> Maybe [UnprocessedUpdateAction]
unprocessedUpdateActions :: Prelude.Maybe [UnprocessedUpdateAction],
    -- | Update actions that have been processed successfully
    UpdateActionResultsMessage -> Maybe [ProcessedUpdateAction]
processedUpdateActions :: Prelude.Maybe [ProcessedUpdateAction]
  }
  deriving (UpdateActionResultsMessage -> UpdateActionResultsMessage -> Bool
(UpdateActionResultsMessage -> UpdateActionResultsMessage -> Bool)
-> (UpdateActionResultsMessage
    -> UpdateActionResultsMessage -> Bool)
-> Eq UpdateActionResultsMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateActionResultsMessage -> UpdateActionResultsMessage -> Bool
$c/= :: UpdateActionResultsMessage -> UpdateActionResultsMessage -> Bool
== :: UpdateActionResultsMessage -> UpdateActionResultsMessage -> Bool
$c== :: UpdateActionResultsMessage -> UpdateActionResultsMessage -> Bool
Prelude.Eq, ReadPrec [UpdateActionResultsMessage]
ReadPrec UpdateActionResultsMessage
Int -> ReadS UpdateActionResultsMessage
ReadS [UpdateActionResultsMessage]
(Int -> ReadS UpdateActionResultsMessage)
-> ReadS [UpdateActionResultsMessage]
-> ReadPrec UpdateActionResultsMessage
-> ReadPrec [UpdateActionResultsMessage]
-> Read UpdateActionResultsMessage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateActionResultsMessage]
$creadListPrec :: ReadPrec [UpdateActionResultsMessage]
readPrec :: ReadPrec UpdateActionResultsMessage
$creadPrec :: ReadPrec UpdateActionResultsMessage
readList :: ReadS [UpdateActionResultsMessage]
$creadList :: ReadS [UpdateActionResultsMessage]
readsPrec :: Int -> ReadS UpdateActionResultsMessage
$creadsPrec :: Int -> ReadS UpdateActionResultsMessage
Prelude.Read, Int -> UpdateActionResultsMessage -> ShowS
[UpdateActionResultsMessage] -> ShowS
UpdateActionResultsMessage -> String
(Int -> UpdateActionResultsMessage -> ShowS)
-> (UpdateActionResultsMessage -> String)
-> ([UpdateActionResultsMessage] -> ShowS)
-> Show UpdateActionResultsMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateActionResultsMessage] -> ShowS
$cshowList :: [UpdateActionResultsMessage] -> ShowS
show :: UpdateActionResultsMessage -> String
$cshow :: UpdateActionResultsMessage -> String
showsPrec :: Int -> UpdateActionResultsMessage -> ShowS
$cshowsPrec :: Int -> UpdateActionResultsMessage -> ShowS
Prelude.Show, (forall x.
 UpdateActionResultsMessage -> Rep UpdateActionResultsMessage x)
-> (forall x.
    Rep UpdateActionResultsMessage x -> UpdateActionResultsMessage)
-> Generic UpdateActionResultsMessage
forall x.
Rep UpdateActionResultsMessage x -> UpdateActionResultsMessage
forall x.
UpdateActionResultsMessage -> Rep UpdateActionResultsMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateActionResultsMessage x -> UpdateActionResultsMessage
$cfrom :: forall x.
UpdateActionResultsMessage -> Rep UpdateActionResultsMessage x
Prelude.Generic)

-- |
-- Create a value of 'UpdateActionResultsMessage' 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:
--
-- 'unprocessedUpdateActions', 'updateActionResultsMessage_unprocessedUpdateActions' - Update actions that haven\'t been processed successfully
--
-- 'processedUpdateActions', 'updateActionResultsMessage_processedUpdateActions' - Update actions that have been processed successfully
newUpdateActionResultsMessage ::
  UpdateActionResultsMessage
newUpdateActionResultsMessage :: UpdateActionResultsMessage
newUpdateActionResultsMessage =
  UpdateActionResultsMessage' :: Maybe [UnprocessedUpdateAction]
-> Maybe [ProcessedUpdateAction] -> UpdateActionResultsMessage
UpdateActionResultsMessage'
    { $sel:unprocessedUpdateActions:UpdateActionResultsMessage' :: Maybe [UnprocessedUpdateAction]
unprocessedUpdateActions =
        Maybe [UnprocessedUpdateAction]
forall a. Maybe a
Prelude.Nothing,
      $sel:processedUpdateActions:UpdateActionResultsMessage' :: Maybe [ProcessedUpdateAction]
processedUpdateActions = Maybe [ProcessedUpdateAction]
forall a. Maybe a
Prelude.Nothing
    }

-- | Update actions that haven\'t been processed successfully
updateActionResultsMessage_unprocessedUpdateActions :: Lens.Lens' UpdateActionResultsMessage (Prelude.Maybe [UnprocessedUpdateAction])
updateActionResultsMessage_unprocessedUpdateActions :: (Maybe [UnprocessedUpdateAction]
 -> f (Maybe [UnprocessedUpdateAction]))
-> UpdateActionResultsMessage -> f UpdateActionResultsMessage
updateActionResultsMessage_unprocessedUpdateActions = (UpdateActionResultsMessage -> Maybe [UnprocessedUpdateAction])
-> (UpdateActionResultsMessage
    -> Maybe [UnprocessedUpdateAction] -> UpdateActionResultsMessage)
-> Lens
     UpdateActionResultsMessage
     UpdateActionResultsMessage
     (Maybe [UnprocessedUpdateAction])
     (Maybe [UnprocessedUpdateAction])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateActionResultsMessage' {Maybe [UnprocessedUpdateAction]
unprocessedUpdateActions :: Maybe [UnprocessedUpdateAction]
$sel:unprocessedUpdateActions:UpdateActionResultsMessage' :: UpdateActionResultsMessage -> Maybe [UnprocessedUpdateAction]
unprocessedUpdateActions} -> Maybe [UnprocessedUpdateAction]
unprocessedUpdateActions) (\s :: UpdateActionResultsMessage
s@UpdateActionResultsMessage' {} Maybe [UnprocessedUpdateAction]
a -> UpdateActionResultsMessage
s {$sel:unprocessedUpdateActions:UpdateActionResultsMessage' :: Maybe [UnprocessedUpdateAction]
unprocessedUpdateActions = Maybe [UnprocessedUpdateAction]
a} :: UpdateActionResultsMessage) ((Maybe [UnprocessedUpdateAction]
  -> f (Maybe [UnprocessedUpdateAction]))
 -> UpdateActionResultsMessage -> f UpdateActionResultsMessage)
-> ((Maybe [UnprocessedUpdateAction]
     -> f (Maybe [UnprocessedUpdateAction]))
    -> Maybe [UnprocessedUpdateAction]
    -> f (Maybe [UnprocessedUpdateAction]))
-> (Maybe [UnprocessedUpdateAction]
    -> f (Maybe [UnprocessedUpdateAction]))
-> UpdateActionResultsMessage
-> f UpdateActionResultsMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [UnprocessedUpdateAction]
  [UnprocessedUpdateAction]
  [UnprocessedUpdateAction]
  [UnprocessedUpdateAction]
-> Iso
     (Maybe [UnprocessedUpdateAction])
     (Maybe [UnprocessedUpdateAction])
     (Maybe [UnprocessedUpdateAction])
     (Maybe [UnprocessedUpdateAction])
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
  [UnprocessedUpdateAction]
  [UnprocessedUpdateAction]
  [UnprocessedUpdateAction]
  [UnprocessedUpdateAction]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Update actions that have been processed successfully
updateActionResultsMessage_processedUpdateActions :: Lens.Lens' UpdateActionResultsMessage (Prelude.Maybe [ProcessedUpdateAction])
updateActionResultsMessage_processedUpdateActions :: (Maybe [ProcessedUpdateAction]
 -> f (Maybe [ProcessedUpdateAction]))
-> UpdateActionResultsMessage -> f UpdateActionResultsMessage
updateActionResultsMessage_processedUpdateActions = (UpdateActionResultsMessage -> Maybe [ProcessedUpdateAction])
-> (UpdateActionResultsMessage
    -> Maybe [ProcessedUpdateAction] -> UpdateActionResultsMessage)
-> Lens
     UpdateActionResultsMessage
     UpdateActionResultsMessage
     (Maybe [ProcessedUpdateAction])
     (Maybe [ProcessedUpdateAction])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateActionResultsMessage' {Maybe [ProcessedUpdateAction]
processedUpdateActions :: Maybe [ProcessedUpdateAction]
$sel:processedUpdateActions:UpdateActionResultsMessage' :: UpdateActionResultsMessage -> Maybe [ProcessedUpdateAction]
processedUpdateActions} -> Maybe [ProcessedUpdateAction]
processedUpdateActions) (\s :: UpdateActionResultsMessage
s@UpdateActionResultsMessage' {} Maybe [ProcessedUpdateAction]
a -> UpdateActionResultsMessage
s {$sel:processedUpdateActions:UpdateActionResultsMessage' :: Maybe [ProcessedUpdateAction]
processedUpdateActions = Maybe [ProcessedUpdateAction]
a} :: UpdateActionResultsMessage) ((Maybe [ProcessedUpdateAction]
  -> f (Maybe [ProcessedUpdateAction]))
 -> UpdateActionResultsMessage -> f UpdateActionResultsMessage)
-> ((Maybe [ProcessedUpdateAction]
     -> f (Maybe [ProcessedUpdateAction]))
    -> Maybe [ProcessedUpdateAction]
    -> f (Maybe [ProcessedUpdateAction]))
-> (Maybe [ProcessedUpdateAction]
    -> f (Maybe [ProcessedUpdateAction]))
-> UpdateActionResultsMessage
-> f UpdateActionResultsMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ProcessedUpdateAction]
  [ProcessedUpdateAction]
  [ProcessedUpdateAction]
  [ProcessedUpdateAction]
-> Iso
     (Maybe [ProcessedUpdateAction])
     (Maybe [ProcessedUpdateAction])
     (Maybe [ProcessedUpdateAction])
     (Maybe [ProcessedUpdateAction])
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
  [ProcessedUpdateAction]
  [ProcessedUpdateAction]
  [ProcessedUpdateAction]
  [ProcessedUpdateAction]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML UpdateActionResultsMessage where
  parseXML :: [Node] -> Either String UpdateActionResultsMessage
parseXML [Node]
x =
    Maybe [UnprocessedUpdateAction]
-> Maybe [ProcessedUpdateAction] -> UpdateActionResultsMessage
UpdateActionResultsMessage'
      (Maybe [UnprocessedUpdateAction]
 -> Maybe [ProcessedUpdateAction] -> UpdateActionResultsMessage)
-> Either String (Maybe [UnprocessedUpdateAction])
-> Either
     String
     (Maybe [ProcessedUpdateAction] -> UpdateActionResultsMessage)
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
"UnprocessedUpdateActions"
                      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 [UnprocessedUpdateAction]))
-> Either String (Maybe [UnprocessedUpdateAction])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [UnprocessedUpdateAction])
-> [Node] -> Either String (Maybe [UnprocessedUpdateAction])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may
                        (Text -> [Node] -> Either String [UnprocessedUpdateAction]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"UnprocessedUpdateAction")
                  )
      Either
  String
  (Maybe [ProcessedUpdateAction] -> UpdateActionResultsMessage)
-> Either String (Maybe [ProcessedUpdateAction])
-> Either String UpdateActionResultsMessage
forall (f :: * -> *) a b. Applicative f => 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
"ProcessedUpdateActions"
                      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 [ProcessedUpdateAction]))
-> Either String (Maybe [ProcessedUpdateAction])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [ProcessedUpdateAction])
-> [Node] -> Either String (Maybe [ProcessedUpdateAction])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [ProcessedUpdateAction]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"ProcessedUpdateAction")
                  )

instance Prelude.Hashable UpdateActionResultsMessage

instance Prelude.NFData UpdateActionResultsMessage