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

-- |
-- Create a value of 'MemoryMiB' 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', 'memoryMiB_max' - The maximum amount of memory, in MiB. If this parameter is not
-- specified, there is no maximum limit.
--
-- 'min', 'memoryMiB_min' - The minimum amount of memory, in MiB. If this parameter is not
-- specified, there is no minimum limit.
newMemoryMiB ::
  MemoryMiB
newMemoryMiB :: MemoryMiB
newMemoryMiB =
  MemoryMiB'
    { $sel:max:MemoryMiB' :: Maybe Int
max = forall a. Maybe a
Prelude.Nothing,
      $sel:min:MemoryMiB' :: Maybe Int
min = forall a. Maybe a
Prelude.Nothing
    }

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

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

instance Data.FromXML MemoryMiB where
  parseXML :: [Node] -> Either String MemoryMiB
parseXML [Node]
x =
    Maybe Int -> Maybe Int -> MemoryMiB
MemoryMiB'
      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 MemoryMiB where
  hashWithSalt :: Int -> MemoryMiB -> Int
hashWithSalt Int
_salt MemoryMiB' {Maybe Int
min :: Maybe Int
max :: Maybe Int
$sel:min:MemoryMiB' :: MemoryMiB -> Maybe Int
$sel:max:MemoryMiB' :: MemoryMiB -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
max
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
min

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

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