{-# 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.VCpuInfo
-- 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.VCpuInfo 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

-- | Describes the vCPU configurations for the instance type.
--
-- /See:/ 'newVCpuInfo' smart constructor.
data VCpuInfo = VCpuInfo'
  { -- | The default number of cores for the instance type.
    VCpuInfo -> Maybe Int
defaultCores :: Prelude.Maybe Prelude.Int,
    -- | The default number of threads per core for the instance type.
    VCpuInfo -> Maybe Int
defaultThreadsPerCore :: Prelude.Maybe Prelude.Int,
    -- | The default number of vCPUs for the instance type.
    VCpuInfo -> Maybe Int
defaultVCpus :: Prelude.Maybe Prelude.Int,
    -- | The valid number of cores that can be configured for the instance type.
    VCpuInfo -> Maybe [Int]
validCores :: Prelude.Maybe [Prelude.Int],
    -- | The valid number of threads per core that can be configured for the
    -- instance type.
    VCpuInfo -> Maybe [Int]
validThreadsPerCore :: Prelude.Maybe [Prelude.Int]
  }
  deriving (VCpuInfo -> VCpuInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VCpuInfo -> VCpuInfo -> Bool
$c/= :: VCpuInfo -> VCpuInfo -> Bool
== :: VCpuInfo -> VCpuInfo -> Bool
$c== :: VCpuInfo -> VCpuInfo -> Bool
Prelude.Eq, ReadPrec [VCpuInfo]
ReadPrec VCpuInfo
Int -> ReadS VCpuInfo
ReadS [VCpuInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VCpuInfo]
$creadListPrec :: ReadPrec [VCpuInfo]
readPrec :: ReadPrec VCpuInfo
$creadPrec :: ReadPrec VCpuInfo
readList :: ReadS [VCpuInfo]
$creadList :: ReadS [VCpuInfo]
readsPrec :: Int -> ReadS VCpuInfo
$creadsPrec :: Int -> ReadS VCpuInfo
Prelude.Read, Int -> VCpuInfo -> ShowS
[VCpuInfo] -> ShowS
VCpuInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VCpuInfo] -> ShowS
$cshowList :: [VCpuInfo] -> ShowS
show :: VCpuInfo -> String
$cshow :: VCpuInfo -> String
showsPrec :: Int -> VCpuInfo -> ShowS
$cshowsPrec :: Int -> VCpuInfo -> ShowS
Prelude.Show, forall x. Rep VCpuInfo x -> VCpuInfo
forall x. VCpuInfo -> Rep VCpuInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VCpuInfo x -> VCpuInfo
$cfrom :: forall x. VCpuInfo -> Rep VCpuInfo x
Prelude.Generic)

-- |
-- Create a value of 'VCpuInfo' 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:
--
-- 'defaultCores', 'vCpuInfo_defaultCores' - The default number of cores for the instance type.
--
-- 'defaultThreadsPerCore', 'vCpuInfo_defaultThreadsPerCore' - The default number of threads per core for the instance type.
--
-- 'defaultVCpus', 'vCpuInfo_defaultVCpus' - The default number of vCPUs for the instance type.
--
-- 'validCores', 'vCpuInfo_validCores' - The valid number of cores that can be configured for the instance type.
--
-- 'validThreadsPerCore', 'vCpuInfo_validThreadsPerCore' - The valid number of threads per core that can be configured for the
-- instance type.
newVCpuInfo ::
  VCpuInfo
newVCpuInfo :: VCpuInfo
newVCpuInfo =
  VCpuInfo'
    { $sel:defaultCores:VCpuInfo' :: Maybe Int
defaultCores = forall a. Maybe a
Prelude.Nothing,
      $sel:defaultThreadsPerCore:VCpuInfo' :: Maybe Int
defaultThreadsPerCore = forall a. Maybe a
Prelude.Nothing,
      $sel:defaultVCpus:VCpuInfo' :: Maybe Int
defaultVCpus = forall a. Maybe a
Prelude.Nothing,
      $sel:validCores:VCpuInfo' :: Maybe [Int]
validCores = forall a. Maybe a
Prelude.Nothing,
      $sel:validThreadsPerCore:VCpuInfo' :: Maybe [Int]
validThreadsPerCore = forall a. Maybe a
Prelude.Nothing
    }

-- | The default number of cores for the instance type.
vCpuInfo_defaultCores :: Lens.Lens' VCpuInfo (Prelude.Maybe Prelude.Int)
vCpuInfo_defaultCores :: Lens' VCpuInfo (Maybe Int)
vCpuInfo_defaultCores = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VCpuInfo' {Maybe Int
defaultCores :: Maybe Int
$sel:defaultCores:VCpuInfo' :: VCpuInfo -> Maybe Int
defaultCores} -> Maybe Int
defaultCores) (\s :: VCpuInfo
s@VCpuInfo' {} Maybe Int
a -> VCpuInfo
s {$sel:defaultCores:VCpuInfo' :: Maybe Int
defaultCores = Maybe Int
a} :: VCpuInfo)

-- | The default number of threads per core for the instance type.
vCpuInfo_defaultThreadsPerCore :: Lens.Lens' VCpuInfo (Prelude.Maybe Prelude.Int)
vCpuInfo_defaultThreadsPerCore :: Lens' VCpuInfo (Maybe Int)
vCpuInfo_defaultThreadsPerCore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VCpuInfo' {Maybe Int
defaultThreadsPerCore :: Maybe Int
$sel:defaultThreadsPerCore:VCpuInfo' :: VCpuInfo -> Maybe Int
defaultThreadsPerCore} -> Maybe Int
defaultThreadsPerCore) (\s :: VCpuInfo
s@VCpuInfo' {} Maybe Int
a -> VCpuInfo
s {$sel:defaultThreadsPerCore:VCpuInfo' :: Maybe Int
defaultThreadsPerCore = Maybe Int
a} :: VCpuInfo)

-- | The default number of vCPUs for the instance type.
vCpuInfo_defaultVCpus :: Lens.Lens' VCpuInfo (Prelude.Maybe Prelude.Int)
vCpuInfo_defaultVCpus :: Lens' VCpuInfo (Maybe Int)
vCpuInfo_defaultVCpus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VCpuInfo' {Maybe Int
defaultVCpus :: Maybe Int
$sel:defaultVCpus:VCpuInfo' :: VCpuInfo -> Maybe Int
defaultVCpus} -> Maybe Int
defaultVCpus) (\s :: VCpuInfo
s@VCpuInfo' {} Maybe Int
a -> VCpuInfo
s {$sel:defaultVCpus:VCpuInfo' :: Maybe Int
defaultVCpus = Maybe Int
a} :: VCpuInfo)

-- | The valid number of cores that can be configured for the instance type.
vCpuInfo_validCores :: Lens.Lens' VCpuInfo (Prelude.Maybe [Prelude.Int])
vCpuInfo_validCores :: Lens' VCpuInfo (Maybe [Int])
vCpuInfo_validCores = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VCpuInfo' {Maybe [Int]
validCores :: Maybe [Int]
$sel:validCores:VCpuInfo' :: VCpuInfo -> Maybe [Int]
validCores} -> Maybe [Int]
validCores) (\s :: VCpuInfo
s@VCpuInfo' {} Maybe [Int]
a -> VCpuInfo
s {$sel:validCores:VCpuInfo' :: Maybe [Int]
validCores = Maybe [Int]
a} :: VCpuInfo) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The valid number of threads per core that can be configured for the
-- instance type.
vCpuInfo_validThreadsPerCore :: Lens.Lens' VCpuInfo (Prelude.Maybe [Prelude.Int])
vCpuInfo_validThreadsPerCore :: Lens' VCpuInfo (Maybe [Int])
vCpuInfo_validThreadsPerCore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VCpuInfo' {Maybe [Int]
validThreadsPerCore :: Maybe [Int]
$sel:validThreadsPerCore:VCpuInfo' :: VCpuInfo -> Maybe [Int]
validThreadsPerCore} -> Maybe [Int]
validThreadsPerCore) (\s :: VCpuInfo
s@VCpuInfo' {} Maybe [Int]
a -> VCpuInfo
s {$sel:validThreadsPerCore:VCpuInfo' :: Maybe [Int]
validThreadsPerCore = Maybe [Int]
a} :: VCpuInfo) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML VCpuInfo where
  parseXML :: [Node] -> Either String VCpuInfo
parseXML [Node]
x =
    Maybe Int
-> Maybe Int -> Maybe Int -> Maybe [Int] -> Maybe [Int] -> VCpuInfo
VCpuInfo'
      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
"defaultCores")
      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
"defaultThreadsPerCore")
      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
"defaultVCpus")
      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
"validCores"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      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
"validThreadsPerCore"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )

instance Prelude.Hashable VCpuInfo where
  hashWithSalt :: Int -> VCpuInfo -> Int
hashWithSalt Int
_salt VCpuInfo' {Maybe Int
Maybe [Int]
validThreadsPerCore :: Maybe [Int]
validCores :: Maybe [Int]
defaultVCpus :: Maybe Int
defaultThreadsPerCore :: Maybe Int
defaultCores :: Maybe Int
$sel:validThreadsPerCore:VCpuInfo' :: VCpuInfo -> Maybe [Int]
$sel:validCores:VCpuInfo' :: VCpuInfo -> Maybe [Int]
$sel:defaultVCpus:VCpuInfo' :: VCpuInfo -> Maybe Int
$sel:defaultThreadsPerCore:VCpuInfo' :: VCpuInfo -> Maybe Int
$sel:defaultCores:VCpuInfo' :: VCpuInfo -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
defaultCores
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
defaultThreadsPerCore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
defaultVCpus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Int]
validCores
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Int]
validThreadsPerCore

instance Prelude.NFData VCpuInfo where
  rnf :: VCpuInfo -> ()
rnf VCpuInfo' {Maybe Int
Maybe [Int]
validThreadsPerCore :: Maybe [Int]
validCores :: Maybe [Int]
defaultVCpus :: Maybe Int
defaultThreadsPerCore :: Maybe Int
defaultCores :: Maybe Int
$sel:validThreadsPerCore:VCpuInfo' :: VCpuInfo -> Maybe [Int]
$sel:validCores:VCpuInfo' :: VCpuInfo -> Maybe [Int]
$sel:defaultVCpus:VCpuInfo' :: VCpuInfo -> Maybe Int
$sel:defaultThreadsPerCore:VCpuInfo' :: VCpuInfo -> Maybe Int
$sel:defaultCores:VCpuInfo' :: VCpuInfo -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
defaultCores
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
defaultThreadsPerCore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
defaultVCpus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Int]
validCores
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Int]
validThreadsPerCore