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

-- | Source server CPU information.
--
-- /See:/ 'newCPU' smart constructor.
data CPU = CPU'
  { -- | The number of CPU cores on the source server.
    CPU -> Maybe Natural
cores :: Prelude.Maybe Prelude.Natural,
    -- | The source server\'s CPU model name.
    CPU -> Maybe Text
modelName :: 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:
--
-- 'cores', 'cpu_cores' - The number of CPU cores on the source server.
--
-- 'modelName', 'cpu_modelName' - The source server\'s CPU model name.
newCPU ::
  CPU
newCPU :: CPU
newCPU =
  CPU'
    { $sel:cores:CPU' :: Maybe Natural
cores = forall a. Maybe a
Prelude.Nothing,
      $sel:modelName:CPU' :: Maybe Text
modelName = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of CPU cores on the source server.
cpu_cores :: Lens.Lens' CPU (Prelude.Maybe Prelude.Natural)
cpu_cores :: Lens' CPU (Maybe Natural)
cpu_cores = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPU' {Maybe Natural
cores :: Maybe Natural
$sel:cores:CPU' :: CPU -> Maybe Natural
cores} -> Maybe Natural
cores) (\s :: CPU
s@CPU' {} Maybe Natural
a -> CPU
s {$sel:cores:CPU' :: Maybe Natural
cores = Maybe Natural
a} :: CPU)

-- | The source server\'s CPU model name.
cpu_modelName :: Lens.Lens' CPU (Prelude.Maybe Prelude.Text)
cpu_modelName :: Lens' CPU (Maybe Text)
cpu_modelName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPU' {Maybe Text
modelName :: Maybe Text
$sel:modelName:CPU' :: CPU -> Maybe Text
modelName} -> Maybe Text
modelName) (\s :: CPU
s@CPU' {} Maybe Text
a -> CPU
s {$sel:modelName:CPU' :: Maybe Text
modelName = 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 Natural -> 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
"cores")
            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
"modelName")
      )

instance Prelude.Hashable CPU where
  hashWithSalt :: Int -> CPU -> Int
hashWithSalt Int
_salt CPU' {Maybe Natural
Maybe Text
modelName :: Maybe Text
cores :: Maybe Natural
$sel:modelName:CPU' :: CPU -> Maybe Text
$sel:cores:CPU' :: CPU -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
cores
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
modelName

instance Prelude.NFData CPU where
  rnf :: CPU -> ()
rnf CPU' {Maybe Natural
Maybe Text
modelName :: Maybe Text
cores :: Maybe Natural
$sel:modelName:CPU' :: CPU -> Maybe Text
$sel:cores:CPU' :: CPU -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
cores
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
modelName