{-# 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.EC2.Types.LaunchTemplateCpuOptions
-- 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.EC2.Types.LaunchTemplateCpuOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'LaunchTemplateCpuOptions' 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', 'launchTemplateCpuOptions_coreCount' - The number of CPU cores for the instance.
--
-- 'threadsPerCore', 'launchTemplateCpuOptions_threadsPerCore' - The number of threads per CPU core.
newLaunchTemplateCpuOptions ::
  LaunchTemplateCpuOptions
newLaunchTemplateCpuOptions :: LaunchTemplateCpuOptions
newLaunchTemplateCpuOptions =
  LaunchTemplateCpuOptions'
    { $sel:coreCount:LaunchTemplateCpuOptions' :: Maybe Int
coreCount =
        forall a. Maybe a
Prelude.Nothing,
      $sel:threadsPerCore:LaunchTemplateCpuOptions' :: Maybe Int
threadsPerCore = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of CPU cores for the instance.
launchTemplateCpuOptions_coreCount :: Lens.Lens' LaunchTemplateCpuOptions (Prelude.Maybe Prelude.Int)
launchTemplateCpuOptions_coreCount :: Lens' LaunchTemplateCpuOptions (Maybe Int)
launchTemplateCpuOptions_coreCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateCpuOptions' {Maybe Int
coreCount :: Maybe Int
$sel:coreCount:LaunchTemplateCpuOptions' :: LaunchTemplateCpuOptions -> Maybe Int
coreCount} -> Maybe Int
coreCount) (\s :: LaunchTemplateCpuOptions
s@LaunchTemplateCpuOptions' {} Maybe Int
a -> LaunchTemplateCpuOptions
s {$sel:coreCount:LaunchTemplateCpuOptions' :: Maybe Int
coreCount = Maybe Int
a} :: LaunchTemplateCpuOptions)

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

instance Data.FromXML LaunchTemplateCpuOptions where
  parseXML :: [Node] -> Either String LaunchTemplateCpuOptions
parseXML [Node]
x =
    Maybe Int -> Maybe Int -> LaunchTemplateCpuOptions
LaunchTemplateCpuOptions'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"coreCount")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"threadsPerCore")

instance Prelude.Hashable LaunchTemplateCpuOptions where
  hashWithSalt :: Int -> LaunchTemplateCpuOptions -> Int
hashWithSalt Int
_salt LaunchTemplateCpuOptions' {Maybe Int
threadsPerCore :: Maybe Int
coreCount :: Maybe Int
$sel:threadsPerCore:LaunchTemplateCpuOptions' :: LaunchTemplateCpuOptions -> Maybe Int
$sel:coreCount:LaunchTemplateCpuOptions' :: LaunchTemplateCpuOptions -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
coreCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
threadsPerCore

instance Prelude.NFData LaunchTemplateCpuOptions where
  rnf :: LaunchTemplateCpuOptions -> ()
rnf LaunchTemplateCpuOptions' {Maybe Int
threadsPerCore :: Maybe Int
coreCount :: Maybe Int
$sel:threadsPerCore:LaunchTemplateCpuOptions' :: LaunchTemplateCpuOptions -> Maybe Int
$sel:coreCount:LaunchTemplateCpuOptions' :: LaunchTemplateCpuOptions -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
coreCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
threadsPerCore