{-# 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.DeviceFarm.Types.UniqueProblem
-- 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.DeviceFarm.Types.UniqueProblem where

import qualified Amazonka.Core as Core
import Amazonka.DeviceFarm.Types.Problem
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A collection of one or more problems, grouped by their result.
--
-- /See:/ 'newUniqueProblem' smart constructor.
data UniqueProblem = UniqueProblem'
  { -- | Information about the problems.
    UniqueProblem -> Maybe [Problem]
problems :: Prelude.Maybe [Problem],
    -- | A message about the unique problems\' result.
    UniqueProblem -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (UniqueProblem -> UniqueProblem -> Bool
(UniqueProblem -> UniqueProblem -> Bool)
-> (UniqueProblem -> UniqueProblem -> Bool) -> Eq UniqueProblem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UniqueProblem -> UniqueProblem -> Bool
$c/= :: UniqueProblem -> UniqueProblem -> Bool
== :: UniqueProblem -> UniqueProblem -> Bool
$c== :: UniqueProblem -> UniqueProblem -> Bool
Prelude.Eq, ReadPrec [UniqueProblem]
ReadPrec UniqueProblem
Int -> ReadS UniqueProblem
ReadS [UniqueProblem]
(Int -> ReadS UniqueProblem)
-> ReadS [UniqueProblem]
-> ReadPrec UniqueProblem
-> ReadPrec [UniqueProblem]
-> Read UniqueProblem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UniqueProblem]
$creadListPrec :: ReadPrec [UniqueProblem]
readPrec :: ReadPrec UniqueProblem
$creadPrec :: ReadPrec UniqueProblem
readList :: ReadS [UniqueProblem]
$creadList :: ReadS [UniqueProblem]
readsPrec :: Int -> ReadS UniqueProblem
$creadsPrec :: Int -> ReadS UniqueProblem
Prelude.Read, Int -> UniqueProblem -> ShowS
[UniqueProblem] -> ShowS
UniqueProblem -> String
(Int -> UniqueProblem -> ShowS)
-> (UniqueProblem -> String)
-> ([UniqueProblem] -> ShowS)
-> Show UniqueProblem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UniqueProblem] -> ShowS
$cshowList :: [UniqueProblem] -> ShowS
show :: UniqueProblem -> String
$cshow :: UniqueProblem -> String
showsPrec :: Int -> UniqueProblem -> ShowS
$cshowsPrec :: Int -> UniqueProblem -> ShowS
Prelude.Show, (forall x. UniqueProblem -> Rep UniqueProblem x)
-> (forall x. Rep UniqueProblem x -> UniqueProblem)
-> Generic UniqueProblem
forall x. Rep UniqueProblem x -> UniqueProblem
forall x. UniqueProblem -> Rep UniqueProblem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UniqueProblem x -> UniqueProblem
$cfrom :: forall x. UniqueProblem -> Rep UniqueProblem x
Prelude.Generic)

-- |
-- Create a value of 'UniqueProblem' 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:
--
-- 'problems', 'uniqueProblem_problems' - Information about the problems.
--
-- 'message', 'uniqueProblem_message' - A message about the unique problems\' result.
newUniqueProblem ::
  UniqueProblem
newUniqueProblem :: UniqueProblem
newUniqueProblem =
  UniqueProblem' :: Maybe [Problem] -> Maybe Text -> UniqueProblem
UniqueProblem'
    { $sel:problems:UniqueProblem' :: Maybe [Problem]
problems = Maybe [Problem]
forall a. Maybe a
Prelude.Nothing,
      $sel:message:UniqueProblem' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the problems.
uniqueProblem_problems :: Lens.Lens' UniqueProblem (Prelude.Maybe [Problem])
uniqueProblem_problems :: (Maybe [Problem] -> f (Maybe [Problem]))
-> UniqueProblem -> f UniqueProblem
uniqueProblem_problems = (UniqueProblem -> Maybe [Problem])
-> (UniqueProblem -> Maybe [Problem] -> UniqueProblem)
-> Lens
     UniqueProblem UniqueProblem (Maybe [Problem]) (Maybe [Problem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UniqueProblem' {Maybe [Problem]
problems :: Maybe [Problem]
$sel:problems:UniqueProblem' :: UniqueProblem -> Maybe [Problem]
problems} -> Maybe [Problem]
problems) (\s :: UniqueProblem
s@UniqueProblem' {} Maybe [Problem]
a -> UniqueProblem
s {$sel:problems:UniqueProblem' :: Maybe [Problem]
problems = Maybe [Problem]
a} :: UniqueProblem) ((Maybe [Problem] -> f (Maybe [Problem]))
 -> UniqueProblem -> f UniqueProblem)
-> ((Maybe [Problem] -> f (Maybe [Problem]))
    -> Maybe [Problem] -> f (Maybe [Problem]))
-> (Maybe [Problem] -> f (Maybe [Problem]))
-> UniqueProblem
-> f UniqueProblem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Problem] [Problem] [Problem] [Problem]
-> Iso
     (Maybe [Problem])
     (Maybe [Problem])
     (Maybe [Problem])
     (Maybe [Problem])
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 [Problem] [Problem] [Problem] [Problem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A message about the unique problems\' result.
uniqueProblem_message :: Lens.Lens' UniqueProblem (Prelude.Maybe Prelude.Text)
uniqueProblem_message :: (Maybe Text -> f (Maybe Text)) -> UniqueProblem -> f UniqueProblem
uniqueProblem_message = (UniqueProblem -> Maybe Text)
-> (UniqueProblem -> Maybe Text -> UniqueProblem)
-> Lens UniqueProblem UniqueProblem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UniqueProblem' {Maybe Text
message :: Maybe Text
$sel:message:UniqueProblem' :: UniqueProblem -> Maybe Text
message} -> Maybe Text
message) (\s :: UniqueProblem
s@UniqueProblem' {} Maybe Text
a -> UniqueProblem
s {$sel:message:UniqueProblem' :: Maybe Text
message = Maybe Text
a} :: UniqueProblem)

instance Core.FromJSON UniqueProblem where
  parseJSON :: Value -> Parser UniqueProblem
parseJSON =
    String
-> (Object -> Parser UniqueProblem)
-> Value
-> Parser UniqueProblem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UniqueProblem"
      ( \Object
x ->
          Maybe [Problem] -> Maybe Text -> UniqueProblem
UniqueProblem'
            (Maybe [Problem] -> Maybe Text -> UniqueProblem)
-> Parser (Maybe [Problem]) -> Parser (Maybe Text -> UniqueProblem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Problem]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"problems" Parser (Maybe (Maybe [Problem]))
-> Maybe [Problem] -> Parser (Maybe [Problem])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Problem]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> UniqueProblem)
-> Parser (Maybe Text) -> Parser UniqueProblem
forall (f :: * -> *) a b. Applicative f => 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
"message")
      )

instance Prelude.Hashable UniqueProblem

instance Prelude.NFData UniqueProblem