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

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

-- | Represents the amount of CPU that an app is using on a physical device.
-- Does not represent system-wide CPU usage.
--
-- /See:/ 'newCPU' smart constructor.
data CPU = CPU'
  { -- | The CPU\'s frequency.
    CPU -> Maybe Text
frequency :: Prelude.Maybe Prelude.Text,
    -- | The clock speed of the device\'s CPU, expressed in hertz (Hz). For
    -- example, a 1.2 GHz CPU is expressed as 1200000000.
    CPU -> Maybe Double
clock :: Prelude.Maybe Prelude.Double,
    -- | The CPU\'s architecture (for example, x86 or ARM).
    CPU -> Maybe Text
architecture :: Prelude.Maybe Prelude.Text
  }
  deriving (CPU -> CPU -> Bool
(CPU -> CPU -> Bool) -> (CPU -> CPU -> Bool) -> Eq CPU
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CPU -> CPU -> Bool
$c/= :: CPU -> CPU -> Bool
== :: CPU -> CPU -> Bool
$c== :: CPU -> CPU -> Bool
Prelude.Eq, ReadPrec [CPU]
ReadPrec CPU
Int -> ReadS CPU
ReadS [CPU]
(Int -> ReadS CPU)
-> ReadS [CPU] -> ReadPrec CPU -> ReadPrec [CPU] -> Read CPU
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CPU]
$creadListPrec :: ReadPrec [CPU]
readPrec :: ReadPrec CPU
$creadPrec :: ReadPrec CPU
readList :: ReadS [CPU]
$creadList :: ReadS [CPU]
readsPrec :: Int -> ReadS CPU
$creadsPrec :: Int -> ReadS CPU
Prelude.Read, Int -> CPU -> ShowS
[CPU] -> ShowS
CPU -> String
(Int -> CPU -> ShowS)
-> (CPU -> String) -> ([CPU] -> ShowS) -> Show CPU
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CPU] -> ShowS
$cshowList :: [CPU] -> ShowS
show :: CPU -> String
$cshow :: CPU -> String
showsPrec :: Int -> CPU -> ShowS
$cshowsPrec :: Int -> CPU -> ShowS
Prelude.Show, (forall x. CPU -> Rep CPU x)
-> (forall x. Rep CPU x -> CPU) -> Generic CPU
forall x. Rep CPU x -> CPU
forall x. CPU -> Rep CPU x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CPU x -> CPU
$cfrom :: forall x. CPU -> Rep CPU x
Prelude.Generic)

-- |
-- Create a value of 'CPU' 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:
--
-- 'frequency', 'cpu_frequency' - The CPU\'s frequency.
--
-- 'clock', 'cpu_clock' - The clock speed of the device\'s CPU, expressed in hertz (Hz). For
-- example, a 1.2 GHz CPU is expressed as 1200000000.
--
-- 'architecture', 'cpu_architecture' - The CPU\'s architecture (for example, x86 or ARM).
newCPU ::
  CPU
newCPU :: CPU
newCPU =
  CPU' :: Maybe Text -> Maybe Double -> Maybe Text -> CPU
CPU'
    { $sel:frequency:CPU' :: Maybe Text
frequency = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clock:CPU' :: Maybe Double
clock = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:architecture:CPU' :: Maybe Text
architecture = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The CPU\'s frequency.
cpu_frequency :: Lens.Lens' CPU (Prelude.Maybe Prelude.Text)
cpu_frequency :: (Maybe Text -> f (Maybe Text)) -> CPU -> f CPU
cpu_frequency = (CPU -> Maybe Text)
-> (CPU -> Maybe Text -> CPU)
-> Lens CPU CPU (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPU' {Maybe Text
frequency :: Maybe Text
$sel:frequency:CPU' :: CPU -> Maybe Text
frequency} -> Maybe Text
frequency) (\s :: CPU
s@CPU' {} Maybe Text
a -> CPU
s {$sel:frequency:CPU' :: Maybe Text
frequency = Maybe Text
a} :: CPU)

-- | The clock speed of the device\'s CPU, expressed in hertz (Hz). For
-- example, a 1.2 GHz CPU is expressed as 1200000000.
cpu_clock :: Lens.Lens' CPU (Prelude.Maybe Prelude.Double)
cpu_clock :: (Maybe Double -> f (Maybe Double)) -> CPU -> f CPU
cpu_clock = (CPU -> Maybe Double)
-> (CPU -> Maybe Double -> CPU)
-> Lens CPU CPU (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPU' {Maybe Double
clock :: Maybe Double
$sel:clock:CPU' :: CPU -> Maybe Double
clock} -> Maybe Double
clock) (\s :: CPU
s@CPU' {} Maybe Double
a -> CPU
s {$sel:clock:CPU' :: Maybe Double
clock = Maybe Double
a} :: CPU)

-- | The CPU\'s architecture (for example, x86 or ARM).
cpu_architecture :: Lens.Lens' CPU (Prelude.Maybe Prelude.Text)
cpu_architecture :: (Maybe Text -> f (Maybe Text)) -> CPU -> f CPU
cpu_architecture = (CPU -> Maybe Text)
-> (CPU -> Maybe Text -> CPU)
-> Lens CPU CPU (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPU' {Maybe Text
architecture :: Maybe Text
$sel:architecture:CPU' :: CPU -> Maybe Text
architecture} -> Maybe Text
architecture) (\s :: CPU
s@CPU' {} Maybe Text
a -> CPU
s {$sel:architecture:CPU' :: Maybe Text
architecture = Maybe Text
a} :: CPU)

instance Core.FromJSON CPU where
  parseJSON :: Value -> Parser CPU
parseJSON =
    String -> (Object -> Parser CPU) -> Value -> Parser CPU
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CPU"
      ( \Object
x ->
          Maybe Text -> Maybe Double -> Maybe Text -> CPU
CPU'
            (Maybe Text -> Maybe Double -> Maybe Text -> CPU)
-> Parser (Maybe Text)
-> Parser (Maybe Double -> Maybe Text -> CPU)
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
"frequency")
            Parser (Maybe Double -> Maybe Text -> CPU)
-> Parser (Maybe Double) -> Parser (Maybe Text -> CPU)
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
"clock")
            Parser (Maybe Text -> CPU) -> Parser (Maybe Text) -> Parser CPU
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
"architecture")
      )

instance Prelude.Hashable CPU

instance Prelude.NFData CPU