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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 architecture (for example, x86 or ARM).
    CPU -> Maybe Text
architecture :: 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 frequency.
    CPU -> Maybe Text
frequency :: Prelude.Maybe Prelude.Text
  }
  deriving (CPU -> CPU -> Bool
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]
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
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. 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:
--
-- 'architecture', 'cpu_architecture' - The CPU\'s architecture (for example, x86 or ARM).
--
-- '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.
--
-- 'frequency', 'cpu_frequency' - The CPU\'s frequency.
newCPU ::
  CPU
newCPU :: CPU
newCPU =
  CPU'
    { $sel:architecture:CPU' :: Maybe Text
architecture = forall a. Maybe a
Prelude.Nothing,
      $sel:clock:CPU' :: Maybe Double
clock = forall a. Maybe a
Prelude.Nothing,
      $sel:frequency:CPU' :: Maybe Text
frequency = forall a. Maybe a
Prelude.Nothing
    }

-- | The CPU\'s architecture (for example, x86 or ARM).
cpu_architecture :: Lens.Lens' CPU (Prelude.Maybe Prelude.Text)
cpu_architecture :: Lens' CPU (Maybe Text)
cpu_architecture = 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)

-- | 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 :: Lens' CPU (Maybe Double)
cpu_clock = 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 frequency.
cpu_frequency :: Lens.Lens' CPU (Prelude.Maybe Prelude.Text)
cpu_frequency :: Lens' CPU (Maybe Text)
cpu_frequency = 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)

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

instance Prelude.Hashable CPU where
  hashWithSalt :: Int -> CPU -> Int
hashWithSalt Int
_salt CPU' {Maybe Double
Maybe Text
frequency :: Maybe Text
clock :: Maybe Double
architecture :: Maybe Text
$sel:frequency:CPU' :: CPU -> Maybe Text
$sel:clock:CPU' :: CPU -> Maybe Double
$sel:architecture:CPU' :: CPU -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
architecture
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
clock
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
frequency

instance Prelude.NFData CPU where
  rnf :: CPU -> ()
rnf CPU' {Maybe Double
Maybe Text
frequency :: Maybe Text
clock :: Maybe Double
architecture :: Maybe Text
$sel:frequency:CPU' :: CPU -> Maybe Text
$sel:clock:CPU' :: CPU -> Maybe Double
$sel:architecture:CPU' :: CPU -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
architecture
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
clock
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
frequency