{-# 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.SnowDeviceManagement.Types.CpuOptions
-- 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.SnowDeviceManagement.Types.CpuOptions where

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

-- | The options for how a device\'s CPU is configured.
--
-- /See:/ 'newCpuOptions' smart constructor.
data CpuOptions = CpuOptions'
  { -- | The number of cores that the CPU can use.
    CpuOptions -> Maybe Int
coreCount :: Prelude.Maybe Prelude.Int,
    -- | The number of threads per core in the CPU.
    CpuOptions -> Maybe Int
threadsPerCore :: Prelude.Maybe Prelude.Int
  }
  deriving (CpuOptions -> CpuOptions -> Bool
(CpuOptions -> CpuOptions -> Bool)
-> (CpuOptions -> CpuOptions -> Bool) -> Eq CpuOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CpuOptions -> CpuOptions -> Bool
$c/= :: CpuOptions -> CpuOptions -> Bool
== :: CpuOptions -> CpuOptions -> Bool
$c== :: CpuOptions -> CpuOptions -> Bool
Prelude.Eq, ReadPrec [CpuOptions]
ReadPrec CpuOptions
Int -> ReadS CpuOptions
ReadS [CpuOptions]
(Int -> ReadS CpuOptions)
-> ReadS [CpuOptions]
-> ReadPrec CpuOptions
-> ReadPrec [CpuOptions]
-> Read CpuOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CpuOptions]
$creadListPrec :: ReadPrec [CpuOptions]
readPrec :: ReadPrec CpuOptions
$creadPrec :: ReadPrec CpuOptions
readList :: ReadS [CpuOptions]
$creadList :: ReadS [CpuOptions]
readsPrec :: Int -> ReadS CpuOptions
$creadsPrec :: Int -> ReadS CpuOptions
Prelude.Read, Int -> CpuOptions -> ShowS
[CpuOptions] -> ShowS
CpuOptions -> String
(Int -> CpuOptions -> ShowS)
-> (CpuOptions -> String)
-> ([CpuOptions] -> ShowS)
-> Show CpuOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CpuOptions] -> ShowS
$cshowList :: [CpuOptions] -> ShowS
show :: CpuOptions -> String
$cshow :: CpuOptions -> String
showsPrec :: Int -> CpuOptions -> ShowS
$cshowsPrec :: Int -> CpuOptions -> ShowS
Prelude.Show, (forall x. CpuOptions -> Rep CpuOptions x)
-> (forall x. Rep CpuOptions x -> CpuOptions) -> Generic CpuOptions
forall x. Rep CpuOptions x -> CpuOptions
forall x. CpuOptions -> Rep CpuOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CpuOptions x -> CpuOptions
$cfrom :: forall x. CpuOptions -> Rep CpuOptions x
Prelude.Generic)

-- |
-- Create a value of 'CpuOptions' 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:
--
-- 'coreCount', 'cpuOptions_coreCount' - The number of cores that the CPU can use.
--
-- 'threadsPerCore', 'cpuOptions_threadsPerCore' - The number of threads per core in the CPU.
newCpuOptions ::
  CpuOptions
newCpuOptions :: CpuOptions
newCpuOptions =
  CpuOptions' :: Maybe Int -> Maybe Int -> CpuOptions
CpuOptions'
    { $sel:coreCount:CpuOptions' :: Maybe Int
coreCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:threadsPerCore:CpuOptions' :: Maybe Int
threadsPerCore = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of cores that the CPU can use.
cpuOptions_coreCount :: Lens.Lens' CpuOptions (Prelude.Maybe Prelude.Int)
cpuOptions_coreCount :: (Maybe Int -> f (Maybe Int)) -> CpuOptions -> f CpuOptions
cpuOptions_coreCount = (CpuOptions -> Maybe Int)
-> (CpuOptions -> Maybe Int -> CpuOptions)
-> Lens CpuOptions CpuOptions (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CpuOptions' {Maybe Int
coreCount :: Maybe Int
$sel:coreCount:CpuOptions' :: CpuOptions -> Maybe Int
coreCount} -> Maybe Int
coreCount) (\s :: CpuOptions
s@CpuOptions' {} Maybe Int
a -> CpuOptions
s {$sel:coreCount:CpuOptions' :: Maybe Int
coreCount = Maybe Int
a} :: CpuOptions)

-- | The number of threads per core in the CPU.
cpuOptions_threadsPerCore :: Lens.Lens' CpuOptions (Prelude.Maybe Prelude.Int)
cpuOptions_threadsPerCore :: (Maybe Int -> f (Maybe Int)) -> CpuOptions -> f CpuOptions
cpuOptions_threadsPerCore = (CpuOptions -> Maybe Int)
-> (CpuOptions -> Maybe Int -> CpuOptions)
-> Lens CpuOptions CpuOptions (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CpuOptions' {Maybe Int
threadsPerCore :: Maybe Int
$sel:threadsPerCore:CpuOptions' :: CpuOptions -> Maybe Int
threadsPerCore} -> Maybe Int
threadsPerCore) (\s :: CpuOptions
s@CpuOptions' {} Maybe Int
a -> CpuOptions
s {$sel:threadsPerCore:CpuOptions' :: Maybe Int
threadsPerCore = Maybe Int
a} :: CpuOptions)

instance Core.FromJSON CpuOptions where
  parseJSON :: Value -> Parser CpuOptions
parseJSON =
    String
-> (Object -> Parser CpuOptions) -> Value -> Parser CpuOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CpuOptions"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> CpuOptions
CpuOptions'
            (Maybe Int -> Maybe Int -> CpuOptions)
-> Parser (Maybe Int) -> Parser (Maybe Int -> CpuOptions)
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
"coreCount")
            Parser (Maybe Int -> CpuOptions)
-> Parser (Maybe Int) -> Parser CpuOptions
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
"threadsPerCore")
      )

instance Prelude.Hashable CpuOptions

instance Prelude.NFData CpuOptions