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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(InstanceHardware -> InstanceHardware -> Bool)
-> (InstanceHardware -> InstanceHardware -> Bool)
-> Eq InstanceHardware
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]
(Int -> ReadS InstanceHardware)
-> ReadS [InstanceHardware]
-> ReadPrec InstanceHardware
-> ReadPrec [InstanceHardware]
-> Read 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
(Int -> InstanceHardware -> ShowS)
-> (InstanceHardware -> String)
-> ([InstanceHardware] -> ShowS)
-> Show InstanceHardware
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. InstanceHardware -> Rep InstanceHardware x)
-> (forall x. Rep InstanceHardware x -> InstanceHardware)
-> Generic InstanceHardware
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' :: Maybe Int -> Maybe [Disk] -> Maybe Double -> InstanceHardware
InstanceHardware'
    { $sel:cpuCount:InstanceHardware' :: Maybe Int
cpuCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:disks:InstanceHardware' :: Maybe [Disk]
disks = Maybe [Disk]
forall a. Maybe a
Prelude.Nothing,
      $sel:ramSizeInGb:InstanceHardware' :: Maybe Double
ramSizeInGb = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of vCPUs the instance has.
instanceHardware_cpuCount :: Lens.Lens' InstanceHardware (Prelude.Maybe Prelude.Int)
instanceHardware_cpuCount :: (Maybe Int -> f (Maybe Int))
-> InstanceHardware -> f InstanceHardware
instanceHardware_cpuCount = (InstanceHardware -> Maybe Int)
-> (InstanceHardware -> Maybe Int -> InstanceHardware)
-> Lens InstanceHardware InstanceHardware (Maybe Int) (Maybe Int)
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 :: (Maybe [Disk] -> f (Maybe [Disk]))
-> InstanceHardware -> f InstanceHardware
instanceHardware_disks = (InstanceHardware -> Maybe [Disk])
-> (InstanceHardware -> Maybe [Disk] -> InstanceHardware)
-> Lens
     InstanceHardware InstanceHardware (Maybe [Disk]) (Maybe [Disk])
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) ((Maybe [Disk] -> f (Maybe [Disk]))
 -> InstanceHardware -> f InstanceHardware)
-> ((Maybe [Disk] -> f (Maybe [Disk]))
    -> Maybe [Disk] -> f (Maybe [Disk]))
-> (Maybe [Disk] -> f (Maybe [Disk]))
-> InstanceHardware
-> f InstanceHardware
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Disk] [Disk] [Disk] [Disk]
-> Iso (Maybe [Disk]) (Maybe [Disk]) (Maybe [Disk]) (Maybe [Disk])
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 AnIso [Disk] [Disk] [Disk] [Disk]
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 :: (Maybe Double -> f (Maybe Double))
-> InstanceHardware -> f InstanceHardware
instanceHardware_ramSizeInGb = (InstanceHardware -> Maybe Double)
-> (InstanceHardware -> Maybe Double -> InstanceHardware)
-> Lens
     InstanceHardware InstanceHardware (Maybe Double) (Maybe Double)
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 Core.FromJSON InstanceHardware where
  parseJSON :: Value -> Parser InstanceHardware
parseJSON =
    String
-> (Object -> Parser InstanceHardware)
-> Value
-> Parser InstanceHardware
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceHardware"
      ( \Object
x ->
          Maybe Int -> Maybe [Disk] -> Maybe Double -> InstanceHardware
InstanceHardware'
            (Maybe Int -> Maybe [Disk] -> Maybe Double -> InstanceHardware)
-> Parser (Maybe Int)
-> Parser (Maybe [Disk] -> Maybe Double -> InstanceHardware)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cpuCount")
            Parser (Maybe [Disk] -> Maybe Double -> InstanceHardware)
-> Parser (Maybe [Disk])
-> Parser (Maybe Double -> InstanceHardware)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Disk]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"disks" Parser (Maybe (Maybe [Disk]))
-> Maybe [Disk] -> Parser (Maybe [Disk])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Disk]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Double -> InstanceHardware)
-> Parser (Maybe Double) -> Parser InstanceHardware
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ramSizeInGb")
      )

instance Prelude.Hashable InstanceHardware

instance Prelude.NFData InstanceHardware