{-# 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.RobOMaker.Types.FailureSummary
-- 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.RobOMaker.Types.FailureSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RobOMaker.Types.WorldFailure

-- | Information about worlds that failed.
--
-- /See:/ 'newFailureSummary' smart constructor.
data FailureSummary = FailureSummary'
  { -- | The worlds that failed.
    FailureSummary -> Maybe [WorldFailure]
failures :: Prelude.Maybe [WorldFailure],
    -- | The total number of failures.
    FailureSummary -> Maybe Int
totalFailureCount :: Prelude.Maybe Prelude.Int
  }
  deriving (FailureSummary -> FailureSummary -> Bool
(FailureSummary -> FailureSummary -> Bool)
-> (FailureSummary -> FailureSummary -> Bool) -> Eq FailureSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailureSummary -> FailureSummary -> Bool
$c/= :: FailureSummary -> FailureSummary -> Bool
== :: FailureSummary -> FailureSummary -> Bool
$c== :: FailureSummary -> FailureSummary -> Bool
Prelude.Eq, ReadPrec [FailureSummary]
ReadPrec FailureSummary
Int -> ReadS FailureSummary
ReadS [FailureSummary]
(Int -> ReadS FailureSummary)
-> ReadS [FailureSummary]
-> ReadPrec FailureSummary
-> ReadPrec [FailureSummary]
-> Read FailureSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailureSummary]
$creadListPrec :: ReadPrec [FailureSummary]
readPrec :: ReadPrec FailureSummary
$creadPrec :: ReadPrec FailureSummary
readList :: ReadS [FailureSummary]
$creadList :: ReadS [FailureSummary]
readsPrec :: Int -> ReadS FailureSummary
$creadsPrec :: Int -> ReadS FailureSummary
Prelude.Read, Int -> FailureSummary -> ShowS
[FailureSummary] -> ShowS
FailureSummary -> String
(Int -> FailureSummary -> ShowS)
-> (FailureSummary -> String)
-> ([FailureSummary] -> ShowS)
-> Show FailureSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailureSummary] -> ShowS
$cshowList :: [FailureSummary] -> ShowS
show :: FailureSummary -> String
$cshow :: FailureSummary -> String
showsPrec :: Int -> FailureSummary -> ShowS
$cshowsPrec :: Int -> FailureSummary -> ShowS
Prelude.Show, (forall x. FailureSummary -> Rep FailureSummary x)
-> (forall x. Rep FailureSummary x -> FailureSummary)
-> Generic FailureSummary
forall x. Rep FailureSummary x -> FailureSummary
forall x. FailureSummary -> Rep FailureSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailureSummary x -> FailureSummary
$cfrom :: forall x. FailureSummary -> Rep FailureSummary x
Prelude.Generic)

-- |
-- Create a value of 'FailureSummary' 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:
--
-- 'failures', 'failureSummary_failures' - The worlds that failed.
--
-- 'totalFailureCount', 'failureSummary_totalFailureCount' - The total number of failures.
newFailureSummary ::
  FailureSummary
newFailureSummary :: FailureSummary
newFailureSummary =
  FailureSummary' :: Maybe [WorldFailure] -> Maybe Int -> FailureSummary
FailureSummary'
    { $sel:failures:FailureSummary' :: Maybe [WorldFailure]
failures = Maybe [WorldFailure]
forall a. Maybe a
Prelude.Nothing,
      $sel:totalFailureCount:FailureSummary' :: Maybe Int
totalFailureCount = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The worlds that failed.
failureSummary_failures :: Lens.Lens' FailureSummary (Prelude.Maybe [WorldFailure])
failureSummary_failures :: (Maybe [WorldFailure] -> f (Maybe [WorldFailure]))
-> FailureSummary -> f FailureSummary
failureSummary_failures = (FailureSummary -> Maybe [WorldFailure])
-> (FailureSummary -> Maybe [WorldFailure] -> FailureSummary)
-> Lens
     FailureSummary
     FailureSummary
     (Maybe [WorldFailure])
     (Maybe [WorldFailure])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureSummary' {Maybe [WorldFailure]
failures :: Maybe [WorldFailure]
$sel:failures:FailureSummary' :: FailureSummary -> Maybe [WorldFailure]
failures} -> Maybe [WorldFailure]
failures) (\s :: FailureSummary
s@FailureSummary' {} Maybe [WorldFailure]
a -> FailureSummary
s {$sel:failures:FailureSummary' :: Maybe [WorldFailure]
failures = Maybe [WorldFailure]
a} :: FailureSummary) ((Maybe [WorldFailure] -> f (Maybe [WorldFailure]))
 -> FailureSummary -> f FailureSummary)
-> ((Maybe [WorldFailure] -> f (Maybe [WorldFailure]))
    -> Maybe [WorldFailure] -> f (Maybe [WorldFailure]))
-> (Maybe [WorldFailure] -> f (Maybe [WorldFailure]))
-> FailureSummary
-> f FailureSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [WorldFailure] [WorldFailure] [WorldFailure] [WorldFailure]
-> Iso
     (Maybe [WorldFailure])
     (Maybe [WorldFailure])
     (Maybe [WorldFailure])
     (Maybe [WorldFailure])
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 [WorldFailure] [WorldFailure] [WorldFailure] [WorldFailure]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The total number of failures.
failureSummary_totalFailureCount :: Lens.Lens' FailureSummary (Prelude.Maybe Prelude.Int)
failureSummary_totalFailureCount :: (Maybe Int -> f (Maybe Int)) -> FailureSummary -> f FailureSummary
failureSummary_totalFailureCount = (FailureSummary -> Maybe Int)
-> (FailureSummary -> Maybe Int -> FailureSummary)
-> Lens FailureSummary FailureSummary (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureSummary' {Maybe Int
totalFailureCount :: Maybe Int
$sel:totalFailureCount:FailureSummary' :: FailureSummary -> Maybe Int
totalFailureCount} -> Maybe Int
totalFailureCount) (\s :: FailureSummary
s@FailureSummary' {} Maybe Int
a -> FailureSummary
s {$sel:totalFailureCount:FailureSummary' :: Maybe Int
totalFailureCount = Maybe Int
a} :: FailureSummary)

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

instance Prelude.Hashable FailureSummary

instance Prelude.NFData FailureSummary