{-# 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.CpuOptionsRequest
-- 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.CpuOptionsRequest 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. Both the core count and threads per
-- core must be specified in the request.
--
-- /See:/ 'newCpuOptionsRequest' smart constructor.
data CpuOptionsRequest = CpuOptionsRequest'
  { -- | The number of CPU cores for the instance.
    CpuOptionsRequest -> Maybe Int
coreCount :: Prelude.Maybe Prelude.Int,
    -- | The number of threads per CPU core. To disable multithreading for the
    -- instance, specify a value of @1@. Otherwise, specify the default value
    -- of @2@.
    CpuOptionsRequest -> Maybe Int
threadsPerCore :: Prelude.Maybe Prelude.Int
  }
  deriving (CpuOptionsRequest -> CpuOptionsRequest -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CpuOptionsRequest -> CpuOptionsRequest -> Bool
$c/= :: CpuOptionsRequest -> CpuOptionsRequest -> Bool
== :: CpuOptionsRequest -> CpuOptionsRequest -> Bool
$c== :: CpuOptionsRequest -> CpuOptionsRequest -> Bool
Prelude.Eq, ReadPrec [CpuOptionsRequest]
ReadPrec CpuOptionsRequest
Int -> ReadS CpuOptionsRequest
ReadS [CpuOptionsRequest]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CpuOptionsRequest]
$creadListPrec :: ReadPrec [CpuOptionsRequest]
readPrec :: ReadPrec CpuOptionsRequest
$creadPrec :: ReadPrec CpuOptionsRequest
readList :: ReadS [CpuOptionsRequest]
$creadList :: ReadS [CpuOptionsRequest]
readsPrec :: Int -> ReadS CpuOptionsRequest
$creadsPrec :: Int -> ReadS CpuOptionsRequest
Prelude.Read, Int -> CpuOptionsRequest -> ShowS
[CpuOptionsRequest] -> ShowS
CpuOptionsRequest -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CpuOptionsRequest] -> ShowS
$cshowList :: [CpuOptionsRequest] -> ShowS
show :: CpuOptionsRequest -> String
$cshow :: CpuOptionsRequest -> String
showsPrec :: Int -> CpuOptionsRequest -> ShowS
$cshowsPrec :: Int -> CpuOptionsRequest -> ShowS
Prelude.Show, forall x. Rep CpuOptionsRequest x -> CpuOptionsRequest
forall x. CpuOptionsRequest -> Rep CpuOptionsRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CpuOptionsRequest x -> CpuOptionsRequest
$cfrom :: forall x. CpuOptionsRequest -> Rep CpuOptionsRequest x
Prelude.Generic)

-- |
-- Create a value of 'CpuOptionsRequest' 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', 'cpuOptionsRequest_coreCount' - The number of CPU cores for the instance.
--
-- 'threadsPerCore', 'cpuOptionsRequest_threadsPerCore' - The number of threads per CPU core. To disable multithreading for the
-- instance, specify a value of @1@. Otherwise, specify the default value
-- of @2@.
newCpuOptionsRequest ::
  CpuOptionsRequest
newCpuOptionsRequest :: CpuOptionsRequest
newCpuOptionsRequest =
  CpuOptionsRequest'
    { $sel:coreCount:CpuOptionsRequest' :: Maybe Int
coreCount = forall a. Maybe a
Prelude.Nothing,
      $sel:threadsPerCore:CpuOptionsRequest' :: Maybe Int
threadsPerCore = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The number of threads per CPU core. To disable multithreading for the
-- instance, specify a value of @1@. Otherwise, specify the default value
-- of @2@.
cpuOptionsRequest_threadsPerCore :: Lens.Lens' CpuOptionsRequest (Prelude.Maybe Prelude.Int)
cpuOptionsRequest_threadsPerCore :: Lens' CpuOptionsRequest (Maybe Int)
cpuOptionsRequest_threadsPerCore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CpuOptionsRequest' {Maybe Int
threadsPerCore :: Maybe Int
$sel:threadsPerCore:CpuOptionsRequest' :: CpuOptionsRequest -> Maybe Int
threadsPerCore} -> Maybe Int
threadsPerCore) (\s :: CpuOptionsRequest
s@CpuOptionsRequest' {} Maybe Int
a -> CpuOptionsRequest
s {$sel:threadsPerCore:CpuOptionsRequest' :: Maybe Int
threadsPerCore = Maybe Int
a} :: CpuOptionsRequest)

instance Prelude.Hashable CpuOptionsRequest where
  hashWithSalt :: Int -> CpuOptionsRequest -> Int
hashWithSalt Int
_salt CpuOptionsRequest' {Maybe Int
threadsPerCore :: Maybe Int
coreCount :: Maybe Int
$sel:threadsPerCore:CpuOptionsRequest' :: CpuOptionsRequest -> Maybe Int
$sel:coreCount:CpuOptionsRequest' :: CpuOptionsRequest -> 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 CpuOptionsRequest where
  rnf :: CpuOptionsRequest -> ()
rnf CpuOptionsRequest' {Maybe Int
threadsPerCore :: Maybe Int
coreCount :: Maybe Int
$sel:threadsPerCore:CpuOptionsRequest' :: CpuOptionsRequest -> Maybe Int
$sel:coreCount:CpuOptionsRequest' :: CpuOptionsRequest -> 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

instance Data.ToQuery CpuOptionsRequest where
  toQuery :: CpuOptionsRequest -> QueryString
toQuery CpuOptionsRequest' {Maybe Int
threadsPerCore :: Maybe Int
coreCount :: Maybe Int
$sel:threadsPerCore:CpuOptionsRequest' :: CpuOptionsRequest -> Maybe Int
$sel:coreCount:CpuOptionsRequest' :: CpuOptionsRequest -> Maybe Int
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"CoreCount" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
coreCount,
        ByteString
"ThreadsPerCore" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
threadsPerCore
      ]