{-# 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.Lightsail.Types.InstanceHardware
-- 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.Lightsail.Types.InstanceHardware where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lightsail.Types.Disk
import qualified Amazonka.Prelude as Prelude

-- | Describes the hardware for the instance.
--
-- /See:/ 'newInstanceHardware' smart constructor.
data InstanceHardware = InstanceHardware'
  { -- | The number of vCPUs the instance has.
    InstanceHardware -> Maybe Int
cpuCount :: Prelude.Maybe Prelude.Int,
    -- | The disks attached to the instance.
    InstanceHardware -> Maybe [Disk]
disks :: Prelude.Maybe [Disk],
    -- | The amount of RAM in GB on the instance (e.g., @1.0@).
    InstanceHardware -> Maybe Double
ramSizeInGb :: Prelude.Maybe Prelude.Double
  }
  deriving (InstanceHardware -> InstanceHardware -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceHardware -> InstanceHardware -> Bool
$c/= :: InstanceHardware -> InstanceHardware -> Bool
== :: InstanceHardware -> InstanceHardware -> Bool
$c== :: InstanceHardware -> InstanceHardware -> Bool
Prelude.Eq, ReadPrec [InstanceHardware]
ReadPrec InstanceHardware
Int -> ReadS InstanceHardware
ReadS [InstanceHardware]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceHardware]
$creadListPrec :: ReadPrec [InstanceHardware]
readPrec :: ReadPrec InstanceHardware
$creadPrec :: ReadPrec InstanceHardware
readList :: ReadS [InstanceHardware]
$creadList :: ReadS [InstanceHardware]
readsPrec :: Int -> ReadS InstanceHardware
$creadsPrec :: Int -> ReadS InstanceHardware
Prelude.Read, Int -> InstanceHardware -> ShowS
[InstanceHardware] -> ShowS
InstanceHardware -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceHardware] -> ShowS
$cshowList :: [InstanceHardware] -> ShowS
show :: InstanceHardware -> String
$cshow :: InstanceHardware -> String
showsPrec :: Int -> InstanceHardware -> ShowS
$cshowsPrec :: Int -> InstanceHardware -> ShowS
Prelude.Show, forall x. Rep InstanceHardware x -> InstanceHardware
forall x. InstanceHardware -> Rep InstanceHardware x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceHardware x -> InstanceHardware
$cfrom :: forall x. InstanceHardware -> Rep InstanceHardware x
Prelude.Generic)

-- |
-- Create a value of 'InstanceHardware' 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:
--
-- 'cpuCount', 'instanceHardware_cpuCount' - The number of vCPUs the instance has.
--
-- 'disks', 'instanceHardware_disks' - The disks attached to the instance.
--
-- 'ramSizeInGb', 'instanceHardware_ramSizeInGb' - The amount of RAM in GB on the instance (e.g., @1.0@).
newInstanceHardware ::
  InstanceHardware
newInstanceHardware :: InstanceHardware
newInstanceHardware =
  InstanceHardware'
    { $sel:cpuCount:InstanceHardware' :: Maybe Int
cpuCount = forall a. Maybe a
Prelude.Nothing,
      $sel:disks:InstanceHardware' :: Maybe [Disk]
disks = forall a. Maybe a
Prelude.Nothing,
      $sel:ramSizeInGb:InstanceHardware' :: Maybe Double
ramSizeInGb = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of vCPUs the instance has.
instanceHardware_cpuCount :: Lens.Lens' InstanceHardware (Prelude.Maybe Prelude.Int)
instanceHardware_cpuCount :: Lens' InstanceHardware (Maybe Int)
instanceHardware_cpuCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceHardware' {Maybe Int
cpuCount :: Maybe Int
$sel:cpuCount:InstanceHardware' :: InstanceHardware -> Maybe Int
cpuCount} -> Maybe Int
cpuCount) (\s :: InstanceHardware
s@InstanceHardware' {} Maybe Int
a -> InstanceHardware
s {$sel:cpuCount:InstanceHardware' :: Maybe Int
cpuCount = Maybe Int
a} :: InstanceHardware)

-- | The disks attached to the instance.
instanceHardware_disks :: Lens.Lens' InstanceHardware (Prelude.Maybe [Disk])
instanceHardware_disks :: Lens' InstanceHardware (Maybe [Disk])
instanceHardware_disks = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceHardware' {Maybe [Disk]
disks :: Maybe [Disk]
$sel:disks:InstanceHardware' :: InstanceHardware -> Maybe [Disk]
disks} -> Maybe [Disk]
disks) (\s :: InstanceHardware
s@InstanceHardware' {} Maybe [Disk]
a -> InstanceHardware
s {$sel:disks:InstanceHardware' :: Maybe [Disk]
disks = Maybe [Disk]
a} :: InstanceHardware) 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 amount of RAM in GB on the instance (e.g., @1.0@).
instanceHardware_ramSizeInGb :: Lens.Lens' InstanceHardware (Prelude.Maybe Prelude.Double)
instanceHardware_ramSizeInGb :: Lens' InstanceHardware (Maybe Double)
instanceHardware_ramSizeInGb = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceHardware' {Maybe Double
ramSizeInGb :: Maybe Double
$sel:ramSizeInGb:InstanceHardware' :: InstanceHardware -> Maybe Double
ramSizeInGb} -> Maybe Double
ramSizeInGb) (\s :: InstanceHardware
s@InstanceHardware' {} Maybe Double
a -> InstanceHardware
s {$sel:ramSizeInGb:InstanceHardware' :: Maybe Double
ramSizeInGb = Maybe Double
a} :: InstanceHardware)

instance Data.FromJSON InstanceHardware where
  parseJSON :: Value -> Parser InstanceHardware
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InstanceHardware"
      ( \Object
x ->
          Maybe Int -> Maybe [Disk] -> Maybe Double -> InstanceHardware
InstanceHardware'
            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
"cpuCount")
            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
"disks" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"ramSizeInGb")
      )

instance Prelude.Hashable InstanceHardware where
  hashWithSalt :: Int -> InstanceHardware -> Int
hashWithSalt Int
_salt InstanceHardware' {Maybe Double
Maybe Int
Maybe [Disk]
ramSizeInGb :: Maybe Double
disks :: Maybe [Disk]
cpuCount :: Maybe Int
$sel:ramSizeInGb:InstanceHardware' :: InstanceHardware -> Maybe Double
$sel:disks:InstanceHardware' :: InstanceHardware -> Maybe [Disk]
$sel:cpuCount:InstanceHardware' :: InstanceHardware -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
cpuCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Disk]
disks
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
ramSizeInGb

instance Prelude.NFData InstanceHardware where
  rnf :: InstanceHardware -> ()
rnf InstanceHardware' {Maybe Double
Maybe Int
Maybe [Disk]
ramSizeInGb :: Maybe Double
disks :: Maybe [Disk]
cpuCount :: Maybe Int
$sel:ramSizeInGb:InstanceHardware' :: InstanceHardware -> Maybe Double
$sel:disks:InstanceHardware' :: InstanceHardware -> Maybe [Disk]
$sel:cpuCount:InstanceHardware' :: InstanceHardware -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
cpuCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Disk]
disks
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
ramSizeInGb