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

-- | The minimum and maximum amount of memory per vCPU, in GiB.
--
-- /See:/ 'newMemoryGiBPerVCpu' smart constructor.
data MemoryGiBPerVCpu = MemoryGiBPerVCpu'
  { -- | The maximum amount of memory per vCPU, in GiB. If this parameter is not
    -- specified, there is no maximum limit.
    MemoryGiBPerVCpu -> Maybe Double
max :: Prelude.Maybe Prelude.Double,
    -- | The minimum amount of memory per vCPU, in GiB. If this parameter is not
    -- specified, there is no minimum limit.
    MemoryGiBPerVCpu -> Maybe Double
min :: Prelude.Maybe Prelude.Double
  }
  deriving (MemoryGiBPerVCpu -> MemoryGiBPerVCpu -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemoryGiBPerVCpu -> MemoryGiBPerVCpu -> Bool
$c/= :: MemoryGiBPerVCpu -> MemoryGiBPerVCpu -> Bool
== :: MemoryGiBPerVCpu -> MemoryGiBPerVCpu -> Bool
$c== :: MemoryGiBPerVCpu -> MemoryGiBPerVCpu -> Bool
Prelude.Eq, ReadPrec [MemoryGiBPerVCpu]
ReadPrec MemoryGiBPerVCpu
Int -> ReadS MemoryGiBPerVCpu
ReadS [MemoryGiBPerVCpu]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MemoryGiBPerVCpu]
$creadListPrec :: ReadPrec [MemoryGiBPerVCpu]
readPrec :: ReadPrec MemoryGiBPerVCpu
$creadPrec :: ReadPrec MemoryGiBPerVCpu
readList :: ReadS [MemoryGiBPerVCpu]
$creadList :: ReadS [MemoryGiBPerVCpu]
readsPrec :: Int -> ReadS MemoryGiBPerVCpu
$creadsPrec :: Int -> ReadS MemoryGiBPerVCpu
Prelude.Read, Int -> MemoryGiBPerVCpu -> ShowS
[MemoryGiBPerVCpu] -> ShowS
MemoryGiBPerVCpu -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MemoryGiBPerVCpu] -> ShowS
$cshowList :: [MemoryGiBPerVCpu] -> ShowS
show :: MemoryGiBPerVCpu -> String
$cshow :: MemoryGiBPerVCpu -> String
showsPrec :: Int -> MemoryGiBPerVCpu -> ShowS
$cshowsPrec :: Int -> MemoryGiBPerVCpu -> ShowS
Prelude.Show, forall x. Rep MemoryGiBPerVCpu x -> MemoryGiBPerVCpu
forall x. MemoryGiBPerVCpu -> Rep MemoryGiBPerVCpu x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MemoryGiBPerVCpu x -> MemoryGiBPerVCpu
$cfrom :: forall x. MemoryGiBPerVCpu -> Rep MemoryGiBPerVCpu x
Prelude.Generic)

-- |
-- Create a value of 'MemoryGiBPerVCpu' 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:
--
-- 'max', 'memoryGiBPerVCpu_max' - The maximum amount of memory per vCPU, in GiB. If this parameter is not
-- specified, there is no maximum limit.
--
-- 'min', 'memoryGiBPerVCpu_min' - The minimum amount of memory per vCPU, in GiB. If this parameter is not
-- specified, there is no minimum limit.
newMemoryGiBPerVCpu ::
  MemoryGiBPerVCpu
newMemoryGiBPerVCpu :: MemoryGiBPerVCpu
newMemoryGiBPerVCpu =
  MemoryGiBPerVCpu'
    { $sel:max:MemoryGiBPerVCpu' :: Maybe Double
max = forall a. Maybe a
Prelude.Nothing,
      $sel:min:MemoryGiBPerVCpu' :: Maybe Double
min = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum amount of memory per vCPU, in GiB. If this parameter is not
-- specified, there is no maximum limit.
memoryGiBPerVCpu_max :: Lens.Lens' MemoryGiBPerVCpu (Prelude.Maybe Prelude.Double)
memoryGiBPerVCpu_max :: Lens' MemoryGiBPerVCpu (Maybe Double)
memoryGiBPerVCpu_max = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemoryGiBPerVCpu' {Maybe Double
max :: Maybe Double
$sel:max:MemoryGiBPerVCpu' :: MemoryGiBPerVCpu -> Maybe Double
max} -> Maybe Double
max) (\s :: MemoryGiBPerVCpu
s@MemoryGiBPerVCpu' {} Maybe Double
a -> MemoryGiBPerVCpu
s {$sel:max:MemoryGiBPerVCpu' :: Maybe Double
max = Maybe Double
a} :: MemoryGiBPerVCpu)

-- | The minimum amount of memory per vCPU, in GiB. If this parameter is not
-- specified, there is no minimum limit.
memoryGiBPerVCpu_min :: Lens.Lens' MemoryGiBPerVCpu (Prelude.Maybe Prelude.Double)
memoryGiBPerVCpu_min :: Lens' MemoryGiBPerVCpu (Maybe Double)
memoryGiBPerVCpu_min = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemoryGiBPerVCpu' {Maybe Double
min :: Maybe Double
$sel:min:MemoryGiBPerVCpu' :: MemoryGiBPerVCpu -> Maybe Double
min} -> Maybe Double
min) (\s :: MemoryGiBPerVCpu
s@MemoryGiBPerVCpu' {} Maybe Double
a -> MemoryGiBPerVCpu
s {$sel:min:MemoryGiBPerVCpu' :: Maybe Double
min = Maybe Double
a} :: MemoryGiBPerVCpu)

instance Data.FromXML MemoryGiBPerVCpu where
  parseXML :: [Node] -> Either String MemoryGiBPerVCpu
parseXML [Node]
x =
    Maybe Double -> Maybe Double -> MemoryGiBPerVCpu
MemoryGiBPerVCpu'
      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
"max")
      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
"min")

instance Prelude.Hashable MemoryGiBPerVCpu where
  hashWithSalt :: Int -> MemoryGiBPerVCpu -> Int
hashWithSalt Int
_salt MemoryGiBPerVCpu' {Maybe Double
min :: Maybe Double
max :: Maybe Double
$sel:min:MemoryGiBPerVCpu' :: MemoryGiBPerVCpu -> Maybe Double
$sel:max:MemoryGiBPerVCpu' :: MemoryGiBPerVCpu -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
max
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
min

instance Prelude.NFData MemoryGiBPerVCpu where
  rnf :: MemoryGiBPerVCpu -> ()
rnf MemoryGiBPerVCpu' {Maybe Double
min :: Maybe Double
max :: Maybe Double
$sel:min:MemoryGiBPerVCpu' :: MemoryGiBPerVCpu -> Maybe Double
$sel:max:MemoryGiBPerVCpu' :: MemoryGiBPerVCpu -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
max seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
min

instance Data.ToQuery MemoryGiBPerVCpu where
  toQuery :: MemoryGiBPerVCpu -> QueryString
toQuery MemoryGiBPerVCpu' {Maybe Double
min :: Maybe Double
max :: Maybe Double
$sel:min:MemoryGiBPerVCpu' :: MemoryGiBPerVCpu -> Maybe Double
$sel:max:MemoryGiBPerVCpu' :: MemoryGiBPerVCpu -> Maybe Double
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Max" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Double
max, ByteString
"Min" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Double
min]