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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DeviceFarm.Types.DeviceFilter
import qualified Amazonka.Prelude as Prelude

-- | Contains the run results requested by the device selection configuration
-- and how many devices were returned. For an example of the JSON response
-- syntax, see ScheduleRun.
--
-- /See:/ 'newDeviceSelectionResult' smart constructor.
data DeviceSelectionResult = DeviceSelectionResult'
  { -- | The filters in a device selection result.
    DeviceSelectionResult -> Maybe [DeviceFilter]
filters :: Prelude.Maybe [DeviceFilter],
    -- | The number of devices that matched the device filter selection criteria.
    DeviceSelectionResult -> Maybe Int
matchedDevicesCount :: Prelude.Maybe Prelude.Int,
    -- | The maximum number of devices to be selected by a device filter and
    -- included in a test run.
    DeviceSelectionResult -> Maybe Int
maxDevices :: Prelude.Maybe Prelude.Int
  }
  deriving (DeviceSelectionResult -> DeviceSelectionResult -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeviceSelectionResult -> DeviceSelectionResult -> Bool
$c/= :: DeviceSelectionResult -> DeviceSelectionResult -> Bool
== :: DeviceSelectionResult -> DeviceSelectionResult -> Bool
$c== :: DeviceSelectionResult -> DeviceSelectionResult -> Bool
Prelude.Eq, ReadPrec [DeviceSelectionResult]
ReadPrec DeviceSelectionResult
Int -> ReadS DeviceSelectionResult
ReadS [DeviceSelectionResult]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeviceSelectionResult]
$creadListPrec :: ReadPrec [DeviceSelectionResult]
readPrec :: ReadPrec DeviceSelectionResult
$creadPrec :: ReadPrec DeviceSelectionResult
readList :: ReadS [DeviceSelectionResult]
$creadList :: ReadS [DeviceSelectionResult]
readsPrec :: Int -> ReadS DeviceSelectionResult
$creadsPrec :: Int -> ReadS DeviceSelectionResult
Prelude.Read, Int -> DeviceSelectionResult -> ShowS
[DeviceSelectionResult] -> ShowS
DeviceSelectionResult -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeviceSelectionResult] -> ShowS
$cshowList :: [DeviceSelectionResult] -> ShowS
show :: DeviceSelectionResult -> String
$cshow :: DeviceSelectionResult -> String
showsPrec :: Int -> DeviceSelectionResult -> ShowS
$cshowsPrec :: Int -> DeviceSelectionResult -> ShowS
Prelude.Show, forall x. Rep DeviceSelectionResult x -> DeviceSelectionResult
forall x. DeviceSelectionResult -> Rep DeviceSelectionResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeviceSelectionResult x -> DeviceSelectionResult
$cfrom :: forall x. DeviceSelectionResult -> Rep DeviceSelectionResult x
Prelude.Generic)

-- |
-- Create a value of 'DeviceSelectionResult' 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:
--
-- 'filters', 'deviceSelectionResult_filters' - The filters in a device selection result.
--
-- 'matchedDevicesCount', 'deviceSelectionResult_matchedDevicesCount' - The number of devices that matched the device filter selection criteria.
--
-- 'maxDevices', 'deviceSelectionResult_maxDevices' - The maximum number of devices to be selected by a device filter and
-- included in a test run.
newDeviceSelectionResult ::
  DeviceSelectionResult
newDeviceSelectionResult :: DeviceSelectionResult
newDeviceSelectionResult =
  DeviceSelectionResult'
    { $sel:filters:DeviceSelectionResult' :: Maybe [DeviceFilter]
filters = forall a. Maybe a
Prelude.Nothing,
      $sel:matchedDevicesCount:DeviceSelectionResult' :: Maybe Int
matchedDevicesCount = forall a. Maybe a
Prelude.Nothing,
      $sel:maxDevices:DeviceSelectionResult' :: Maybe Int
maxDevices = forall a. Maybe a
Prelude.Nothing
    }

-- | The filters in a device selection result.
deviceSelectionResult_filters :: Lens.Lens' DeviceSelectionResult (Prelude.Maybe [DeviceFilter])
deviceSelectionResult_filters :: Lens' DeviceSelectionResult (Maybe [DeviceFilter])
deviceSelectionResult_filters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceSelectionResult' {Maybe [DeviceFilter]
filters :: Maybe [DeviceFilter]
$sel:filters:DeviceSelectionResult' :: DeviceSelectionResult -> Maybe [DeviceFilter]
filters} -> Maybe [DeviceFilter]
filters) (\s :: DeviceSelectionResult
s@DeviceSelectionResult' {} Maybe [DeviceFilter]
a -> DeviceSelectionResult
s {$sel:filters:DeviceSelectionResult' :: Maybe [DeviceFilter]
filters = Maybe [DeviceFilter]
a} :: DeviceSelectionResult) 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

-- | The number of devices that matched the device filter selection criteria.
deviceSelectionResult_matchedDevicesCount :: Lens.Lens' DeviceSelectionResult (Prelude.Maybe Prelude.Int)
deviceSelectionResult_matchedDevicesCount :: Lens' DeviceSelectionResult (Maybe Int)
deviceSelectionResult_matchedDevicesCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceSelectionResult' {Maybe Int
matchedDevicesCount :: Maybe Int
$sel:matchedDevicesCount:DeviceSelectionResult' :: DeviceSelectionResult -> Maybe Int
matchedDevicesCount} -> Maybe Int
matchedDevicesCount) (\s :: DeviceSelectionResult
s@DeviceSelectionResult' {} Maybe Int
a -> DeviceSelectionResult
s {$sel:matchedDevicesCount:DeviceSelectionResult' :: Maybe Int
matchedDevicesCount = Maybe Int
a} :: DeviceSelectionResult)

-- | The maximum number of devices to be selected by a device filter and
-- included in a test run.
deviceSelectionResult_maxDevices :: Lens.Lens' DeviceSelectionResult (Prelude.Maybe Prelude.Int)
deviceSelectionResult_maxDevices :: Lens' DeviceSelectionResult (Maybe Int)
deviceSelectionResult_maxDevices = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceSelectionResult' {Maybe Int
maxDevices :: Maybe Int
$sel:maxDevices:DeviceSelectionResult' :: DeviceSelectionResult -> Maybe Int
maxDevices} -> Maybe Int
maxDevices) (\s :: DeviceSelectionResult
s@DeviceSelectionResult' {} Maybe Int
a -> DeviceSelectionResult
s {$sel:maxDevices:DeviceSelectionResult' :: Maybe Int
maxDevices = Maybe Int
a} :: DeviceSelectionResult)

instance Data.FromJSON DeviceSelectionResult where
  parseJSON :: Value -> Parser DeviceSelectionResult
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DeviceSelectionResult"
      ( \Object
x ->
          Maybe [DeviceFilter]
-> Maybe Int -> Maybe Int -> DeviceSelectionResult
DeviceSelectionResult'
            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
"filters" 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 (Maybe a)
Data..:? Key
"matchedDevicesCount")
            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
"maxDevices")
      )

instance Prelude.Hashable DeviceSelectionResult where
  hashWithSalt :: Int -> DeviceSelectionResult -> Int
hashWithSalt Int
_salt DeviceSelectionResult' {Maybe Int
Maybe [DeviceFilter]
maxDevices :: Maybe Int
matchedDevicesCount :: Maybe Int
filters :: Maybe [DeviceFilter]
$sel:maxDevices:DeviceSelectionResult' :: DeviceSelectionResult -> Maybe Int
$sel:matchedDevicesCount:DeviceSelectionResult' :: DeviceSelectionResult -> Maybe Int
$sel:filters:DeviceSelectionResult' :: DeviceSelectionResult -> Maybe [DeviceFilter]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DeviceFilter]
filters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
matchedDevicesCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxDevices

instance Prelude.NFData DeviceSelectionResult where
  rnf :: DeviceSelectionResult -> ()
rnf DeviceSelectionResult' {Maybe Int
Maybe [DeviceFilter]
maxDevices :: Maybe Int
matchedDevicesCount :: Maybe Int
filters :: Maybe [DeviceFilter]
$sel:maxDevices:DeviceSelectionResult' :: DeviceSelectionResult -> Maybe Int
$sel:matchedDevicesCount:DeviceSelectionResult' :: DeviceSelectionResult -> Maybe Int
$sel:filters:DeviceSelectionResult' :: DeviceSelectionResult -> Maybe [DeviceFilter]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DeviceFilter]
filters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
matchedDevicesCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxDevices