{-# 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.SuiteRunConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTDeviceAdvisor.Types.SuiteRunConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTDeviceAdvisor.Types.DeviceUnderTest
import qualified Amazonka.Prelude as Prelude

-- | Gets suite run configuration.
--
-- /See:/ 'newSuiteRunConfiguration' smart constructor.
data SuiteRunConfiguration = SuiteRunConfiguration'
  { -- | TRUE if multiple test suites run in parallel.
    SuiteRunConfiguration -> Maybe Bool
parallelRun :: Prelude.Maybe Prelude.Bool,
    -- | Sets test case list.
    SuiteRunConfiguration -> Maybe [Text]
selectedTestList :: Prelude.Maybe [Prelude.Text],
    -- | Sets the primary device for the test suite run. This requires a thing
    -- ARN or a certificate ARN.
    SuiteRunConfiguration -> DeviceUnderTest
primaryDevice :: DeviceUnderTest
  }
  deriving (SuiteRunConfiguration -> SuiteRunConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SuiteRunConfiguration -> SuiteRunConfiguration -> Bool
$c/= :: SuiteRunConfiguration -> SuiteRunConfiguration -> Bool
== :: SuiteRunConfiguration -> SuiteRunConfiguration -> Bool
$c== :: SuiteRunConfiguration -> SuiteRunConfiguration -> Bool
Prelude.Eq, ReadPrec [SuiteRunConfiguration]
ReadPrec SuiteRunConfiguration
Int -> ReadS SuiteRunConfiguration
ReadS [SuiteRunConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SuiteRunConfiguration]
$creadListPrec :: ReadPrec [SuiteRunConfiguration]
readPrec :: ReadPrec SuiteRunConfiguration
$creadPrec :: ReadPrec SuiteRunConfiguration
readList :: ReadS [SuiteRunConfiguration]
$creadList :: ReadS [SuiteRunConfiguration]
readsPrec :: Int -> ReadS SuiteRunConfiguration
$creadsPrec :: Int -> ReadS SuiteRunConfiguration
Prelude.Read, Int -> SuiteRunConfiguration -> ShowS
[SuiteRunConfiguration] -> ShowS
SuiteRunConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SuiteRunConfiguration] -> ShowS
$cshowList :: [SuiteRunConfiguration] -> ShowS
show :: SuiteRunConfiguration -> String
$cshow :: SuiteRunConfiguration -> String
showsPrec :: Int -> SuiteRunConfiguration -> ShowS
$cshowsPrec :: Int -> SuiteRunConfiguration -> ShowS
Prelude.Show, forall x. Rep SuiteRunConfiguration x -> SuiteRunConfiguration
forall x. SuiteRunConfiguration -> Rep SuiteRunConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SuiteRunConfiguration x -> SuiteRunConfiguration
$cfrom :: forall x. SuiteRunConfiguration -> Rep SuiteRunConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SuiteRunConfiguration' 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:
--
-- 'parallelRun', 'suiteRunConfiguration_parallelRun' - TRUE if multiple test suites run in parallel.
--
-- 'selectedTestList', 'suiteRunConfiguration_selectedTestList' - Sets test case list.
--
-- 'primaryDevice', 'suiteRunConfiguration_primaryDevice' - Sets the primary device for the test suite run. This requires a thing
-- ARN or a certificate ARN.
newSuiteRunConfiguration ::
  -- | 'primaryDevice'
  DeviceUnderTest ->
  SuiteRunConfiguration
newSuiteRunConfiguration :: DeviceUnderTest -> SuiteRunConfiguration
newSuiteRunConfiguration DeviceUnderTest
pPrimaryDevice_ =
  SuiteRunConfiguration'
    { $sel:parallelRun:SuiteRunConfiguration' :: Maybe Bool
parallelRun =
        forall a. Maybe a
Prelude.Nothing,
      $sel:selectedTestList:SuiteRunConfiguration' :: Maybe [Text]
selectedTestList = forall a. Maybe a
Prelude.Nothing,
      $sel:primaryDevice:SuiteRunConfiguration' :: DeviceUnderTest
primaryDevice = DeviceUnderTest
pPrimaryDevice_
    }

-- | TRUE if multiple test suites run in parallel.
suiteRunConfiguration_parallelRun :: Lens.Lens' SuiteRunConfiguration (Prelude.Maybe Prelude.Bool)
suiteRunConfiguration_parallelRun :: Lens' SuiteRunConfiguration (Maybe Bool)
suiteRunConfiguration_parallelRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuiteRunConfiguration' {Maybe Bool
parallelRun :: Maybe Bool
$sel:parallelRun:SuiteRunConfiguration' :: SuiteRunConfiguration -> Maybe Bool
parallelRun} -> Maybe Bool
parallelRun) (\s :: SuiteRunConfiguration
s@SuiteRunConfiguration' {} Maybe Bool
a -> SuiteRunConfiguration
s {$sel:parallelRun:SuiteRunConfiguration' :: Maybe Bool
parallelRun = Maybe Bool
a} :: SuiteRunConfiguration)

-- | Sets test case list.
suiteRunConfiguration_selectedTestList :: Lens.Lens' SuiteRunConfiguration (Prelude.Maybe [Prelude.Text])
suiteRunConfiguration_selectedTestList :: Lens' SuiteRunConfiguration (Maybe [Text])
suiteRunConfiguration_selectedTestList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuiteRunConfiguration' {Maybe [Text]
selectedTestList :: Maybe [Text]
$sel:selectedTestList:SuiteRunConfiguration' :: SuiteRunConfiguration -> Maybe [Text]
selectedTestList} -> Maybe [Text]
selectedTestList) (\s :: SuiteRunConfiguration
s@SuiteRunConfiguration' {} Maybe [Text]
a -> SuiteRunConfiguration
s {$sel:selectedTestList:SuiteRunConfiguration' :: Maybe [Text]
selectedTestList = Maybe [Text]
a} :: SuiteRunConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Sets the primary device for the test suite run. This requires a thing
-- ARN or a certificate ARN.
suiteRunConfiguration_primaryDevice :: Lens.Lens' SuiteRunConfiguration DeviceUnderTest
suiteRunConfiguration_primaryDevice :: Lens' SuiteRunConfiguration DeviceUnderTest
suiteRunConfiguration_primaryDevice = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuiteRunConfiguration' {DeviceUnderTest
primaryDevice :: DeviceUnderTest
$sel:primaryDevice:SuiteRunConfiguration' :: SuiteRunConfiguration -> DeviceUnderTest
primaryDevice} -> DeviceUnderTest
primaryDevice) (\s :: SuiteRunConfiguration
s@SuiteRunConfiguration' {} DeviceUnderTest
a -> SuiteRunConfiguration
s {$sel:primaryDevice:SuiteRunConfiguration' :: DeviceUnderTest
primaryDevice = DeviceUnderTest
a} :: SuiteRunConfiguration)

instance Data.FromJSON SuiteRunConfiguration where
  parseJSON :: Value -> Parser SuiteRunConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SuiteRunConfiguration"
      ( \Object
x ->
          Maybe Bool
-> Maybe [Text] -> DeviceUnderTest -> SuiteRunConfiguration
SuiteRunConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"parallelRun")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"selectedTestList"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"primaryDevice")
      )

instance Prelude.Hashable SuiteRunConfiguration where
  hashWithSalt :: Int -> SuiteRunConfiguration -> Int
hashWithSalt Int
_salt SuiteRunConfiguration' {Maybe Bool
Maybe [Text]
DeviceUnderTest
primaryDevice :: DeviceUnderTest
selectedTestList :: Maybe [Text]
parallelRun :: Maybe Bool
$sel:primaryDevice:SuiteRunConfiguration' :: SuiteRunConfiguration -> DeviceUnderTest
$sel:selectedTestList:SuiteRunConfiguration' :: SuiteRunConfiguration -> Maybe [Text]
$sel:parallelRun:SuiteRunConfiguration' :: SuiteRunConfiguration -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
parallelRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
selectedTestList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DeviceUnderTest
primaryDevice

instance Prelude.NFData SuiteRunConfiguration where
  rnf :: SuiteRunConfiguration -> ()
rnf SuiteRunConfiguration' {Maybe Bool
Maybe [Text]
DeviceUnderTest
primaryDevice :: DeviceUnderTest
selectedTestList :: Maybe [Text]
parallelRun :: Maybe Bool
$sel:primaryDevice:SuiteRunConfiguration' :: SuiteRunConfiguration -> DeviceUnderTest
$sel:selectedTestList:SuiteRunConfiguration' :: SuiteRunConfiguration -> Maybe [Text]
$sel:parallelRun:SuiteRunConfiguration' :: SuiteRunConfiguration -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
parallelRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
selectedTestList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DeviceUnderTest
primaryDevice

instance Data.ToJSON SuiteRunConfiguration where
  toJSON :: SuiteRunConfiguration -> Value
toJSON SuiteRunConfiguration' {Maybe Bool
Maybe [Text]
DeviceUnderTest
primaryDevice :: DeviceUnderTest
selectedTestList :: Maybe [Text]
parallelRun :: Maybe Bool
$sel:primaryDevice:SuiteRunConfiguration' :: SuiteRunConfiguration -> DeviceUnderTest
$sel:selectedTestList:SuiteRunConfiguration' :: SuiteRunConfiguration -> Maybe [Text]
$sel:parallelRun:SuiteRunConfiguration' :: SuiteRunConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"parallelRun" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
parallelRun,
            (Key
"selectedTestList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
selectedTestList,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"primaryDevice" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DeviceUnderTest
primaryDevice)
          ]
      )