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

import qualified Amazonka.Core as Core
import Amazonka.DeviceFarm.Types.DeviceFilter
import qualified Amazonka.Lens as Lens
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 number of devices that matched the device filter selection criteria.
    DeviceSelectionResult -> Maybe Int
matchedDevicesCount :: Prelude.Maybe Prelude.Int,
    -- | The filters in a device selection result.
    DeviceSelectionResult -> Maybe [DeviceFilter]
filters :: Prelude.Maybe [DeviceFilter],
    -- | 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
(DeviceSelectionResult -> DeviceSelectionResult -> Bool)
-> (DeviceSelectionResult -> DeviceSelectionResult -> Bool)
-> Eq DeviceSelectionResult
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]
(Int -> ReadS DeviceSelectionResult)
-> ReadS [DeviceSelectionResult]
-> ReadPrec DeviceSelectionResult
-> ReadPrec [DeviceSelectionResult]
-> Read 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
(Int -> DeviceSelectionResult -> ShowS)
-> (DeviceSelectionResult -> String)
-> ([DeviceSelectionResult] -> ShowS)
-> Show DeviceSelectionResult
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. DeviceSelectionResult -> Rep DeviceSelectionResult x)
-> (forall x. Rep DeviceSelectionResult x -> DeviceSelectionResult)
-> Generic DeviceSelectionResult
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:
--
-- 'matchedDevicesCount', 'deviceSelectionResult_matchedDevicesCount' - The number of devices that matched the device filter selection criteria.
--
-- 'filters', 'deviceSelectionResult_filters' - The filters in a device selection result.
--
-- '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' :: Maybe Int
-> Maybe [DeviceFilter] -> Maybe Int -> DeviceSelectionResult
DeviceSelectionResult'
    { $sel:matchedDevicesCount:DeviceSelectionResult' :: Maybe Int
matchedDevicesCount =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:DeviceSelectionResult' :: Maybe [DeviceFilter]
filters = Maybe [DeviceFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:maxDevices:DeviceSelectionResult' :: Maybe Int
maxDevices = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of devices that matched the device filter selection criteria.
deviceSelectionResult_matchedDevicesCount :: Lens.Lens' DeviceSelectionResult (Prelude.Maybe Prelude.Int)
deviceSelectionResult_matchedDevicesCount :: (Maybe Int -> f (Maybe Int))
-> DeviceSelectionResult -> f DeviceSelectionResult
deviceSelectionResult_matchedDevicesCount = (DeviceSelectionResult -> Maybe Int)
-> (DeviceSelectionResult -> Maybe Int -> DeviceSelectionResult)
-> Lens
     DeviceSelectionResult DeviceSelectionResult (Maybe Int) (Maybe Int)
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 filters in a device selection result.
deviceSelectionResult_filters :: Lens.Lens' DeviceSelectionResult (Prelude.Maybe [DeviceFilter])
deviceSelectionResult_filters :: (Maybe [DeviceFilter] -> f (Maybe [DeviceFilter]))
-> DeviceSelectionResult -> f DeviceSelectionResult
deviceSelectionResult_filters = (DeviceSelectionResult -> Maybe [DeviceFilter])
-> (DeviceSelectionResult
    -> Maybe [DeviceFilter] -> DeviceSelectionResult)
-> Lens
     DeviceSelectionResult
     DeviceSelectionResult
     (Maybe [DeviceFilter])
     (Maybe [DeviceFilter])
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) ((Maybe [DeviceFilter] -> f (Maybe [DeviceFilter]))
 -> DeviceSelectionResult -> f DeviceSelectionResult)
-> ((Maybe [DeviceFilter] -> f (Maybe [DeviceFilter]))
    -> Maybe [DeviceFilter] -> f (Maybe [DeviceFilter]))
-> (Maybe [DeviceFilter] -> f (Maybe [DeviceFilter]))
-> DeviceSelectionResult
-> f DeviceSelectionResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [DeviceFilter] [DeviceFilter] [DeviceFilter] [DeviceFilter]
-> Iso
     (Maybe [DeviceFilter])
     (Maybe [DeviceFilter])
     (Maybe [DeviceFilter])
     (Maybe [DeviceFilter])
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 [DeviceFilter] [DeviceFilter] [DeviceFilter] [DeviceFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Int -> f (Maybe Int))
-> DeviceSelectionResult -> f DeviceSelectionResult
deviceSelectionResult_maxDevices = (DeviceSelectionResult -> Maybe Int)
-> (DeviceSelectionResult -> Maybe Int -> DeviceSelectionResult)
-> Lens
     DeviceSelectionResult DeviceSelectionResult (Maybe Int) (Maybe Int)
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 Core.FromJSON DeviceSelectionResult where
  parseJSON :: Value -> Parser DeviceSelectionResult
parseJSON =
    String
-> (Object -> Parser DeviceSelectionResult)
-> Value
-> Parser DeviceSelectionResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeviceSelectionResult"
      ( \Object
x ->
          Maybe Int
-> Maybe [DeviceFilter] -> Maybe Int -> DeviceSelectionResult
DeviceSelectionResult'
            (Maybe Int
 -> Maybe [DeviceFilter] -> Maybe Int -> DeviceSelectionResult)
-> Parser (Maybe Int)
-> Parser
     (Maybe [DeviceFilter] -> Maybe Int -> DeviceSelectionResult)
forall (f :: * -> *) a b. Functor 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
"matchedDevicesCount")
            Parser (Maybe [DeviceFilter] -> Maybe Int -> DeviceSelectionResult)
-> Parser (Maybe [DeviceFilter])
-> Parser (Maybe Int -> DeviceSelectionResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [DeviceFilter]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"filters" Parser (Maybe (Maybe [DeviceFilter]))
-> Maybe [DeviceFilter] -> Parser (Maybe [DeviceFilter])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DeviceFilter]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Int -> DeviceSelectionResult)
-> Parser (Maybe Int) -> Parser DeviceSelectionResult
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
"maxDevices")
      )

instance Prelude.Hashable DeviceSelectionResult

instance Prelude.NFData DeviceSelectionResult