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

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

-- | Source server CPU information.
--
-- /See:/ 'newCPU' smart constructor.
data CPU = CPU'
  { -- | The source server\'s CPU model name.
    CPU -> Maybe Text
modelName :: Prelude.Maybe Prelude.Text,
    -- | The number of CPU cores on the source server.
    CPU -> Maybe Natural
cores :: Prelude.Maybe Prelude.Natural
  }
  deriving (CPU -> CPU -> Bool
(CPU -> CPU -> Bool) -> (CPU -> CPU -> Bool) -> Eq CPU
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]
(Int -> ReadS CPU)
-> ReadS [CPU] -> ReadPrec CPU -> ReadPrec [CPU] -> Read 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
(Int -> CPU -> ShowS)
-> (CPU -> String) -> ([CPU] -> ShowS) -> Show CPU
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. CPU -> Rep CPU x)
-> (forall x. Rep CPU x -> CPU) -> Generic CPU
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:
--
-- 'modelName', 'cpu_modelName' - The source server\'s CPU model name.
--
-- 'cores', 'cpu_cores' - The number of CPU cores on the source server.
newCPU ::
  CPU
newCPU :: CPU
newCPU =
  CPU' :: Maybe Text -> Maybe Natural -> CPU
CPU'
    { $sel:modelName:CPU' :: Maybe Text
modelName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:cores:CPU' :: Maybe Natural
cores = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The source server\'s CPU model name.
cpu_modelName :: Lens.Lens' CPU (Prelude.Maybe Prelude.Text)
cpu_modelName :: (Maybe Text -> f (Maybe Text)) -> CPU -> f CPU
cpu_modelName = (CPU -> Maybe Text)
-> (CPU -> Maybe Text -> CPU)
-> Lens CPU CPU (Maybe Text) (Maybe Text)
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)

-- | The number of CPU cores on the source server.
cpu_cores :: Lens.Lens' CPU (Prelude.Maybe Prelude.Natural)
cpu_cores :: (Maybe Natural -> f (Maybe Natural)) -> CPU -> f CPU
cpu_cores = (CPU -> Maybe Natural)
-> (CPU -> Maybe Natural -> CPU)
-> Lens CPU CPU (Maybe Natural) (Maybe Natural)
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)

instance Core.FromJSON CPU where
  parseJSON :: Value -> Parser CPU
parseJSON =
    String -> (Object -> Parser CPU) -> Value -> Parser CPU
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CPU"
      ( \Object
x ->
          Maybe Text -> Maybe Natural -> CPU
CPU'
            (Maybe Text -> Maybe Natural -> CPU)
-> Parser (Maybe Text) -> Parser (Maybe Natural -> CPU)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"modelName")
            Parser (Maybe Natural -> CPU)
-> Parser (Maybe Natural) -> Parser CPU
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cores")
      )

instance Prelude.Hashable CPU

instance Prelude.NFData CPU