{-# 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.IoTDeviceAdvisor.Types.GroupResult
-- 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.IoTDeviceAdvisor.Types.GroupResult where

import qualified Amazonka.Core as Core
import Amazonka.IoTDeviceAdvisor.Types.TestCaseRun
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Show Group Result.
--
-- /See:/ 'newGroupResult' smart constructor.
data GroupResult = GroupResult'
  { -- | Tests under Group Result.
    GroupResult -> Maybe [TestCaseRun]
tests :: Prelude.Maybe [TestCaseRun],
    -- | Group result Id.
    GroupResult -> Maybe Text
groupId :: Prelude.Maybe Prelude.Text,
    -- | Group Result Name.
    GroupResult -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text
  }
  deriving (GroupResult -> GroupResult -> Bool
(GroupResult -> GroupResult -> Bool)
-> (GroupResult -> GroupResult -> Bool) -> Eq GroupResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupResult -> GroupResult -> Bool
$c/= :: GroupResult -> GroupResult -> Bool
== :: GroupResult -> GroupResult -> Bool
$c== :: GroupResult -> GroupResult -> Bool
Prelude.Eq, ReadPrec [GroupResult]
ReadPrec GroupResult
Int -> ReadS GroupResult
ReadS [GroupResult]
(Int -> ReadS GroupResult)
-> ReadS [GroupResult]
-> ReadPrec GroupResult
-> ReadPrec [GroupResult]
-> Read GroupResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupResult]
$creadListPrec :: ReadPrec [GroupResult]
readPrec :: ReadPrec GroupResult
$creadPrec :: ReadPrec GroupResult
readList :: ReadS [GroupResult]
$creadList :: ReadS [GroupResult]
readsPrec :: Int -> ReadS GroupResult
$creadsPrec :: Int -> ReadS GroupResult
Prelude.Read, Int -> GroupResult -> ShowS
[GroupResult] -> ShowS
GroupResult -> String
(Int -> GroupResult -> ShowS)
-> (GroupResult -> String)
-> ([GroupResult] -> ShowS)
-> Show GroupResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupResult] -> ShowS
$cshowList :: [GroupResult] -> ShowS
show :: GroupResult -> String
$cshow :: GroupResult -> String
showsPrec :: Int -> GroupResult -> ShowS
$cshowsPrec :: Int -> GroupResult -> ShowS
Prelude.Show, (forall x. GroupResult -> Rep GroupResult x)
-> (forall x. Rep GroupResult x -> GroupResult)
-> Generic GroupResult
forall x. Rep GroupResult x -> GroupResult
forall x. GroupResult -> Rep GroupResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GroupResult x -> GroupResult
$cfrom :: forall x. GroupResult -> Rep GroupResult x
Prelude.Generic)

-- |
-- Create a value of 'GroupResult' 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:
--
-- 'tests', 'groupResult_tests' - Tests under Group Result.
--
-- 'groupId', 'groupResult_groupId' - Group result Id.
--
-- 'groupName', 'groupResult_groupName' - Group Result Name.
newGroupResult ::
  GroupResult
newGroupResult :: GroupResult
newGroupResult =
  GroupResult' :: Maybe [TestCaseRun] -> Maybe Text -> Maybe Text -> GroupResult
GroupResult'
    { $sel:tests:GroupResult' :: Maybe [TestCaseRun]
tests = Maybe [TestCaseRun]
forall a. Maybe a
Prelude.Nothing,
      $sel:groupId:GroupResult' :: Maybe Text
groupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:GroupResult' :: Maybe Text
groupName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Tests under Group Result.
groupResult_tests :: Lens.Lens' GroupResult (Prelude.Maybe [TestCaseRun])
groupResult_tests :: (Maybe [TestCaseRun] -> f (Maybe [TestCaseRun]))
-> GroupResult -> f GroupResult
groupResult_tests = (GroupResult -> Maybe [TestCaseRun])
-> (GroupResult -> Maybe [TestCaseRun] -> GroupResult)
-> Lens
     GroupResult GroupResult (Maybe [TestCaseRun]) (Maybe [TestCaseRun])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupResult' {Maybe [TestCaseRun]
tests :: Maybe [TestCaseRun]
$sel:tests:GroupResult' :: GroupResult -> Maybe [TestCaseRun]
tests} -> Maybe [TestCaseRun]
tests) (\s :: GroupResult
s@GroupResult' {} Maybe [TestCaseRun]
a -> GroupResult
s {$sel:tests:GroupResult' :: Maybe [TestCaseRun]
tests = Maybe [TestCaseRun]
a} :: GroupResult) ((Maybe [TestCaseRun] -> f (Maybe [TestCaseRun]))
 -> GroupResult -> f GroupResult)
-> ((Maybe [TestCaseRun] -> f (Maybe [TestCaseRun]))
    -> Maybe [TestCaseRun] -> f (Maybe [TestCaseRun]))
-> (Maybe [TestCaseRun] -> f (Maybe [TestCaseRun]))
-> GroupResult
-> f GroupResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [TestCaseRun] [TestCaseRun] [TestCaseRun] [TestCaseRun]
-> Iso
     (Maybe [TestCaseRun])
     (Maybe [TestCaseRun])
     (Maybe [TestCaseRun])
     (Maybe [TestCaseRun])
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 [TestCaseRun] [TestCaseRun] [TestCaseRun] [TestCaseRun]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Group result Id.
groupResult_groupId :: Lens.Lens' GroupResult (Prelude.Maybe Prelude.Text)
groupResult_groupId :: (Maybe Text -> f (Maybe Text)) -> GroupResult -> f GroupResult
groupResult_groupId = (GroupResult -> Maybe Text)
-> (GroupResult -> Maybe Text -> GroupResult)
-> Lens GroupResult GroupResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupResult' {Maybe Text
groupId :: Maybe Text
$sel:groupId:GroupResult' :: GroupResult -> Maybe Text
groupId} -> Maybe Text
groupId) (\s :: GroupResult
s@GroupResult' {} Maybe Text
a -> GroupResult
s {$sel:groupId:GroupResult' :: Maybe Text
groupId = Maybe Text
a} :: GroupResult)

-- | Group Result Name.
groupResult_groupName :: Lens.Lens' GroupResult (Prelude.Maybe Prelude.Text)
groupResult_groupName :: (Maybe Text -> f (Maybe Text)) -> GroupResult -> f GroupResult
groupResult_groupName = (GroupResult -> Maybe Text)
-> (GroupResult -> Maybe Text -> GroupResult)
-> Lens GroupResult GroupResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupResult' {Maybe Text
groupName :: Maybe Text
$sel:groupName:GroupResult' :: GroupResult -> Maybe Text
groupName} -> Maybe Text
groupName) (\s :: GroupResult
s@GroupResult' {} Maybe Text
a -> GroupResult
s {$sel:groupName:GroupResult' :: Maybe Text
groupName = Maybe Text
a} :: GroupResult)

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

instance Prelude.Hashable GroupResult

instance Prelude.NFData GroupResult