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

import qualified Amazonka.Core as Core
import Amazonka.DeviceFarm.Types.DevicePoolType
import Amazonka.DeviceFarm.Types.Rule
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a collection of device types.
--
-- /See:/ 'newDevicePool' smart constructor.
data DevicePool = DevicePool'
  { -- | The device pool\'s ARN.
    DevicePool -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | Information about the device pool\'s rules.
    DevicePool -> Maybe [Rule]
rules :: Prelude.Maybe [Rule],
    -- | The device pool\'s name.
    DevicePool -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The number of devices that Device Farm can add to your device pool.
    -- Device Farm adds devices that are available and meet the criteria that
    -- you assign for the @rules@ parameter. Depending on how many devices meet
    -- these constraints, your device pool might contain fewer devices than the
    -- value for this parameter.
    --
    -- By specifying the maximum number of devices, you can control the costs
    -- that you incur by running tests.
    DevicePool -> Maybe Int
maxDevices :: Prelude.Maybe Prelude.Int,
    -- | The device pool\'s type.
    --
    -- Allowed values include:
    --
    -- -   CURATED: A device pool that is created and managed by AWS Device
    --     Farm.
    --
    -- -   PRIVATE: A device pool that is created and managed by the device
    --     pool developer.
    DevicePool -> Maybe DevicePoolType
type' :: Prelude.Maybe DevicePoolType,
    -- | The device pool\'s description.
    DevicePool -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (DevicePool -> DevicePool -> Bool
(DevicePool -> DevicePool -> Bool)
-> (DevicePool -> DevicePool -> Bool) -> Eq DevicePool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DevicePool -> DevicePool -> Bool
$c/= :: DevicePool -> DevicePool -> Bool
== :: DevicePool -> DevicePool -> Bool
$c== :: DevicePool -> DevicePool -> Bool
Prelude.Eq, ReadPrec [DevicePool]
ReadPrec DevicePool
Int -> ReadS DevicePool
ReadS [DevicePool]
(Int -> ReadS DevicePool)
-> ReadS [DevicePool]
-> ReadPrec DevicePool
-> ReadPrec [DevicePool]
-> Read DevicePool
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DevicePool]
$creadListPrec :: ReadPrec [DevicePool]
readPrec :: ReadPrec DevicePool
$creadPrec :: ReadPrec DevicePool
readList :: ReadS [DevicePool]
$creadList :: ReadS [DevicePool]
readsPrec :: Int -> ReadS DevicePool
$creadsPrec :: Int -> ReadS DevicePool
Prelude.Read, Int -> DevicePool -> ShowS
[DevicePool] -> ShowS
DevicePool -> String
(Int -> DevicePool -> ShowS)
-> (DevicePool -> String)
-> ([DevicePool] -> ShowS)
-> Show DevicePool
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DevicePool] -> ShowS
$cshowList :: [DevicePool] -> ShowS
show :: DevicePool -> String
$cshow :: DevicePool -> String
showsPrec :: Int -> DevicePool -> ShowS
$cshowsPrec :: Int -> DevicePool -> ShowS
Prelude.Show, (forall x. DevicePool -> Rep DevicePool x)
-> (forall x. Rep DevicePool x -> DevicePool) -> Generic DevicePool
forall x. Rep DevicePool x -> DevicePool
forall x. DevicePool -> Rep DevicePool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DevicePool x -> DevicePool
$cfrom :: forall x. DevicePool -> Rep DevicePool x
Prelude.Generic)

-- |
-- Create a value of 'DevicePool' 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:
--
-- 'arn', 'devicePool_arn' - The device pool\'s ARN.
--
-- 'rules', 'devicePool_rules' - Information about the device pool\'s rules.
--
-- 'name', 'devicePool_name' - The device pool\'s name.
--
-- 'maxDevices', 'devicePool_maxDevices' - The number of devices that Device Farm can add to your device pool.
-- Device Farm adds devices that are available and meet the criteria that
-- you assign for the @rules@ parameter. Depending on how many devices meet
-- these constraints, your device pool might contain fewer devices than the
-- value for this parameter.
--
-- By specifying the maximum number of devices, you can control the costs
-- that you incur by running tests.
--
-- 'type'', 'devicePool_type' - The device pool\'s type.
--
-- Allowed values include:
--
-- -   CURATED: A device pool that is created and managed by AWS Device
--     Farm.
--
-- -   PRIVATE: A device pool that is created and managed by the device
--     pool developer.
--
-- 'description', 'devicePool_description' - The device pool\'s description.
newDevicePool ::
  DevicePool
newDevicePool :: DevicePool
newDevicePool =
  DevicePool' :: Maybe Text
-> Maybe [Rule]
-> Maybe Text
-> Maybe Int
-> Maybe DevicePoolType
-> Maybe Text
-> DevicePool
DevicePool'
    { $sel:arn:DevicePool' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:rules:DevicePool' :: Maybe [Rule]
rules = Maybe [Rule]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DevicePool' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxDevices:DevicePool' :: Maybe Int
maxDevices = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:type':DevicePool' :: Maybe DevicePoolType
type' = Maybe DevicePoolType
forall a. Maybe a
Prelude.Nothing,
      $sel:description:DevicePool' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The device pool\'s ARN.
devicePool_arn :: Lens.Lens' DevicePool (Prelude.Maybe Prelude.Text)
devicePool_arn :: (Maybe Text -> f (Maybe Text)) -> DevicePool -> f DevicePool
devicePool_arn = (DevicePool -> Maybe Text)
-> (DevicePool -> Maybe Text -> DevicePool)
-> Lens DevicePool DevicePool (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DevicePool' {Maybe Text
arn :: Maybe Text
$sel:arn:DevicePool' :: DevicePool -> Maybe Text
arn} -> Maybe Text
arn) (\s :: DevicePool
s@DevicePool' {} Maybe Text
a -> DevicePool
s {$sel:arn:DevicePool' :: Maybe Text
arn = Maybe Text
a} :: DevicePool)

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

-- | The device pool\'s name.
devicePool_name :: Lens.Lens' DevicePool (Prelude.Maybe Prelude.Text)
devicePool_name :: (Maybe Text -> f (Maybe Text)) -> DevicePool -> f DevicePool
devicePool_name = (DevicePool -> Maybe Text)
-> (DevicePool -> Maybe Text -> DevicePool)
-> Lens DevicePool DevicePool (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DevicePool' {Maybe Text
name :: Maybe Text
$sel:name:DevicePool' :: DevicePool -> Maybe Text
name} -> Maybe Text
name) (\s :: DevicePool
s@DevicePool' {} Maybe Text
a -> DevicePool
s {$sel:name:DevicePool' :: Maybe Text
name = Maybe Text
a} :: DevicePool)

-- | The number of devices that Device Farm can add to your device pool.
-- Device Farm adds devices that are available and meet the criteria that
-- you assign for the @rules@ parameter. Depending on how many devices meet
-- these constraints, your device pool might contain fewer devices than the
-- value for this parameter.
--
-- By specifying the maximum number of devices, you can control the costs
-- that you incur by running tests.
devicePool_maxDevices :: Lens.Lens' DevicePool (Prelude.Maybe Prelude.Int)
devicePool_maxDevices :: (Maybe Int -> f (Maybe Int)) -> DevicePool -> f DevicePool
devicePool_maxDevices = (DevicePool -> Maybe Int)
-> (DevicePool -> Maybe Int -> DevicePool)
-> Lens DevicePool DevicePool (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DevicePool' {Maybe Int
maxDevices :: Maybe Int
$sel:maxDevices:DevicePool' :: DevicePool -> Maybe Int
maxDevices} -> Maybe Int
maxDevices) (\s :: DevicePool
s@DevicePool' {} Maybe Int
a -> DevicePool
s {$sel:maxDevices:DevicePool' :: Maybe Int
maxDevices = Maybe Int
a} :: DevicePool)

-- | The device pool\'s type.
--
-- Allowed values include:
--
-- -   CURATED: A device pool that is created and managed by AWS Device
--     Farm.
--
-- -   PRIVATE: A device pool that is created and managed by the device
--     pool developer.
devicePool_type :: Lens.Lens' DevicePool (Prelude.Maybe DevicePoolType)
devicePool_type :: (Maybe DevicePoolType -> f (Maybe DevicePoolType))
-> DevicePool -> f DevicePool
devicePool_type = (DevicePool -> Maybe DevicePoolType)
-> (DevicePool -> Maybe DevicePoolType -> DevicePool)
-> Lens
     DevicePool DevicePool (Maybe DevicePoolType) (Maybe DevicePoolType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DevicePool' {Maybe DevicePoolType
type' :: Maybe DevicePoolType
$sel:type':DevicePool' :: DevicePool -> Maybe DevicePoolType
type'} -> Maybe DevicePoolType
type') (\s :: DevicePool
s@DevicePool' {} Maybe DevicePoolType
a -> DevicePool
s {$sel:type':DevicePool' :: Maybe DevicePoolType
type' = Maybe DevicePoolType
a} :: DevicePool)

-- | The device pool\'s description.
devicePool_description :: Lens.Lens' DevicePool (Prelude.Maybe Prelude.Text)
devicePool_description :: (Maybe Text -> f (Maybe Text)) -> DevicePool -> f DevicePool
devicePool_description = (DevicePool -> Maybe Text)
-> (DevicePool -> Maybe Text -> DevicePool)
-> Lens DevicePool DevicePool (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DevicePool' {Maybe Text
description :: Maybe Text
$sel:description:DevicePool' :: DevicePool -> Maybe Text
description} -> Maybe Text
description) (\s :: DevicePool
s@DevicePool' {} Maybe Text
a -> DevicePool
s {$sel:description:DevicePool' :: Maybe Text
description = Maybe Text
a} :: DevicePool)

instance Core.FromJSON DevicePool where
  parseJSON :: Value -> Parser DevicePool
parseJSON =
    String
-> (Object -> Parser DevicePool) -> Value -> Parser DevicePool
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DevicePool"
      ( \Object
x ->
          Maybe Text
-> Maybe [Rule]
-> Maybe Text
-> Maybe Int
-> Maybe DevicePoolType
-> Maybe Text
-> DevicePool
DevicePool'
            (Maybe Text
 -> Maybe [Rule]
 -> Maybe Text
 -> Maybe Int
 -> Maybe DevicePoolType
 -> Maybe Text
 -> DevicePool)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Rule]
      -> Maybe Text
      -> Maybe Int
      -> Maybe DevicePoolType
      -> Maybe Text
      -> DevicePool)
forall (f :: * -> *) a b. Functor 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
"arn")
            Parser
  (Maybe [Rule]
   -> Maybe Text
   -> Maybe Int
   -> Maybe DevicePoolType
   -> Maybe Text
   -> DevicePool)
-> Parser (Maybe [Rule])
-> Parser
     (Maybe Text
      -> Maybe Int -> Maybe DevicePoolType -> Maybe Text -> DevicePool)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Rule]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"rules" Parser (Maybe (Maybe [Rule]))
-> Maybe [Rule] -> Parser (Maybe [Rule])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Rule]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe Int -> Maybe DevicePoolType -> Maybe Text -> DevicePool)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int -> Maybe DevicePoolType -> Maybe Text -> DevicePool)
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
"name")
            Parser
  (Maybe Int -> Maybe DevicePoolType -> Maybe Text -> DevicePool)
-> Parser (Maybe Int)
-> Parser (Maybe DevicePoolType -> Maybe Text -> DevicePool)
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")
            Parser (Maybe DevicePoolType -> Maybe Text -> DevicePool)
-> Parser (Maybe DevicePoolType)
-> Parser (Maybe Text -> DevicePool)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DevicePoolType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
            Parser (Maybe Text -> DevicePool)
-> Parser (Maybe Text) -> Parser DevicePool
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
"description")
      )

instance Prelude.Hashable DevicePool

instance Prelude.NFData DevicePool