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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the total (metered or unmetered) minutes used by the resource
-- to run tests. Contains the sum of minutes consumed by all children.
--
-- /See:/ 'newDeviceMinutes' smart constructor.
data DeviceMinutes = DeviceMinutes'
  { -- | When specified, represents only the sum of metered minutes used by the
    -- resource to run tests.
    DeviceMinutes -> Maybe Double
metered :: Prelude.Maybe Prelude.Double,
    -- | When specified, represents the total minutes used by the resource to run
    -- tests.
    DeviceMinutes -> Maybe Double
total :: Prelude.Maybe Prelude.Double,
    -- | When specified, represents only the sum of unmetered minutes used by the
    -- resource to run tests.
    DeviceMinutes -> Maybe Double
unmetered :: Prelude.Maybe Prelude.Double
  }
  deriving (DeviceMinutes -> DeviceMinutes -> Bool
(DeviceMinutes -> DeviceMinutes -> Bool)
-> (DeviceMinutes -> DeviceMinutes -> Bool) -> Eq DeviceMinutes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeviceMinutes -> DeviceMinutes -> Bool
$c/= :: DeviceMinutes -> DeviceMinutes -> Bool
== :: DeviceMinutes -> DeviceMinutes -> Bool
$c== :: DeviceMinutes -> DeviceMinutes -> Bool
Prelude.Eq, ReadPrec [DeviceMinutes]
ReadPrec DeviceMinutes
Int -> ReadS DeviceMinutes
ReadS [DeviceMinutes]
(Int -> ReadS DeviceMinutes)
-> ReadS [DeviceMinutes]
-> ReadPrec DeviceMinutes
-> ReadPrec [DeviceMinutes]
-> Read DeviceMinutes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeviceMinutes]
$creadListPrec :: ReadPrec [DeviceMinutes]
readPrec :: ReadPrec DeviceMinutes
$creadPrec :: ReadPrec DeviceMinutes
readList :: ReadS [DeviceMinutes]
$creadList :: ReadS [DeviceMinutes]
readsPrec :: Int -> ReadS DeviceMinutes
$creadsPrec :: Int -> ReadS DeviceMinutes
Prelude.Read, Int -> DeviceMinutes -> ShowS
[DeviceMinutes] -> ShowS
DeviceMinutes -> String
(Int -> DeviceMinutes -> ShowS)
-> (DeviceMinutes -> String)
-> ([DeviceMinutes] -> ShowS)
-> Show DeviceMinutes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeviceMinutes] -> ShowS
$cshowList :: [DeviceMinutes] -> ShowS
show :: DeviceMinutes -> String
$cshow :: DeviceMinutes -> String
showsPrec :: Int -> DeviceMinutes -> ShowS
$cshowsPrec :: Int -> DeviceMinutes -> ShowS
Prelude.Show, (forall x. DeviceMinutes -> Rep DeviceMinutes x)
-> (forall x. Rep DeviceMinutes x -> DeviceMinutes)
-> Generic DeviceMinutes
forall x. Rep DeviceMinutes x -> DeviceMinutes
forall x. DeviceMinutes -> Rep DeviceMinutes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeviceMinutes x -> DeviceMinutes
$cfrom :: forall x. DeviceMinutes -> Rep DeviceMinutes x
Prelude.Generic)

-- |
-- Create a value of 'DeviceMinutes' 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:
--
-- 'metered', 'deviceMinutes_metered' - When specified, represents only the sum of metered minutes used by the
-- resource to run tests.
--
-- 'total', 'deviceMinutes_total' - When specified, represents the total minutes used by the resource to run
-- tests.
--
-- 'unmetered', 'deviceMinutes_unmetered' - When specified, represents only the sum of unmetered minutes used by the
-- resource to run tests.
newDeviceMinutes ::
  DeviceMinutes
newDeviceMinutes :: DeviceMinutes
newDeviceMinutes =
  DeviceMinutes' :: Maybe Double -> Maybe Double -> Maybe Double -> DeviceMinutes
DeviceMinutes'
    { $sel:metered:DeviceMinutes' :: Maybe Double
metered = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:total:DeviceMinutes' :: Maybe Double
total = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:unmetered:DeviceMinutes' :: Maybe Double
unmetered = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | When specified, represents only the sum of metered minutes used by the
-- resource to run tests.
deviceMinutes_metered :: Lens.Lens' DeviceMinutes (Prelude.Maybe Prelude.Double)
deviceMinutes_metered :: (Maybe Double -> f (Maybe Double))
-> DeviceMinutes -> f DeviceMinutes
deviceMinutes_metered = (DeviceMinutes -> Maybe Double)
-> (DeviceMinutes -> Maybe Double -> DeviceMinutes)
-> Lens DeviceMinutes DeviceMinutes (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceMinutes' {Maybe Double
metered :: Maybe Double
$sel:metered:DeviceMinutes' :: DeviceMinutes -> Maybe Double
metered} -> Maybe Double
metered) (\s :: DeviceMinutes
s@DeviceMinutes' {} Maybe Double
a -> DeviceMinutes
s {$sel:metered:DeviceMinutes' :: Maybe Double
metered = Maybe Double
a} :: DeviceMinutes)

-- | When specified, represents the total minutes used by the resource to run
-- tests.
deviceMinutes_total :: Lens.Lens' DeviceMinutes (Prelude.Maybe Prelude.Double)
deviceMinutes_total :: (Maybe Double -> f (Maybe Double))
-> DeviceMinutes -> f DeviceMinutes
deviceMinutes_total = (DeviceMinutes -> Maybe Double)
-> (DeviceMinutes -> Maybe Double -> DeviceMinutes)
-> Lens DeviceMinutes DeviceMinutes (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceMinutes' {Maybe Double
total :: Maybe Double
$sel:total:DeviceMinutes' :: DeviceMinutes -> Maybe Double
total} -> Maybe Double
total) (\s :: DeviceMinutes
s@DeviceMinutes' {} Maybe Double
a -> DeviceMinutes
s {$sel:total:DeviceMinutes' :: Maybe Double
total = Maybe Double
a} :: DeviceMinutes)

-- | When specified, represents only the sum of unmetered minutes used by the
-- resource to run tests.
deviceMinutes_unmetered :: Lens.Lens' DeviceMinutes (Prelude.Maybe Prelude.Double)
deviceMinutes_unmetered :: (Maybe Double -> f (Maybe Double))
-> DeviceMinutes -> f DeviceMinutes
deviceMinutes_unmetered = (DeviceMinutes -> Maybe Double)
-> (DeviceMinutes -> Maybe Double -> DeviceMinutes)
-> Lens DeviceMinutes DeviceMinutes (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceMinutes' {Maybe Double
unmetered :: Maybe Double
$sel:unmetered:DeviceMinutes' :: DeviceMinutes -> Maybe Double
unmetered} -> Maybe Double
unmetered) (\s :: DeviceMinutes
s@DeviceMinutes' {} Maybe Double
a -> DeviceMinutes
s {$sel:unmetered:DeviceMinutes' :: Maybe Double
unmetered = Maybe Double
a} :: DeviceMinutes)

instance Core.FromJSON DeviceMinutes where
  parseJSON :: Value -> Parser DeviceMinutes
parseJSON =
    String
-> (Object -> Parser DeviceMinutes)
-> Value
-> Parser DeviceMinutes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeviceMinutes"
      ( \Object
x ->
          Maybe Double -> Maybe Double -> Maybe Double -> DeviceMinutes
DeviceMinutes'
            (Maybe Double -> Maybe Double -> Maybe Double -> DeviceMinutes)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> Maybe Double -> DeviceMinutes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"metered")
            Parser (Maybe Double -> Maybe Double -> DeviceMinutes)
-> Parser (Maybe Double) -> Parser (Maybe Double -> DeviceMinutes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"total")
            Parser (Maybe Double -> DeviceMinutes)
-> Parser (Maybe Double) -> Parser DeviceMinutes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"unmetered")
      )

instance Prelude.Hashable DeviceMinutes

instance Prelude.NFData DeviceMinutes