{-# 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.AcceleratorCount
-- 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.AcceleratorCount 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 number of accelerators (GPUs, FPGAs, or Amazon
-- Web Services Inferentia chips) on an instance.
--
-- /See:/ 'newAcceleratorCount' smart constructor.
data AcceleratorCount = AcceleratorCount'
  { -- | The maximum number of accelerators. If this parameter is not specified,
    -- there is no maximum limit.
    AcceleratorCount -> Maybe Int
max :: Prelude.Maybe Prelude.Int,
    -- | The minimum number of accelerators. If this parameter is not specified,
    -- there is no minimum limit.
    AcceleratorCount -> Maybe Int
min :: Prelude.Maybe Prelude.Int
  }
  deriving (AcceleratorCount -> AcceleratorCount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceleratorCount -> AcceleratorCount -> Bool
$c/= :: AcceleratorCount -> AcceleratorCount -> Bool
== :: AcceleratorCount -> AcceleratorCount -> Bool
$c== :: AcceleratorCount -> AcceleratorCount -> Bool
Prelude.Eq, ReadPrec [AcceleratorCount]
ReadPrec AcceleratorCount
Int -> ReadS AcceleratorCount
ReadS [AcceleratorCount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcceleratorCount]
$creadListPrec :: ReadPrec [AcceleratorCount]
readPrec :: ReadPrec AcceleratorCount
$creadPrec :: ReadPrec AcceleratorCount
readList :: ReadS [AcceleratorCount]
$creadList :: ReadS [AcceleratorCount]
readsPrec :: Int -> ReadS AcceleratorCount
$creadsPrec :: Int -> ReadS AcceleratorCount
Prelude.Read, Int -> AcceleratorCount -> ShowS
[AcceleratorCount] -> ShowS
AcceleratorCount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceleratorCount] -> ShowS
$cshowList :: [AcceleratorCount] -> ShowS
show :: AcceleratorCount -> String
$cshow :: AcceleratorCount -> String
showsPrec :: Int -> AcceleratorCount -> ShowS
$cshowsPrec :: Int -> AcceleratorCount -> ShowS
Prelude.Show, forall x. Rep AcceleratorCount x -> AcceleratorCount
forall x. AcceleratorCount -> Rep AcceleratorCount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AcceleratorCount x -> AcceleratorCount
$cfrom :: forall x. AcceleratorCount -> Rep AcceleratorCount x
Prelude.Generic)

-- |
-- Create a value of 'AcceleratorCount' 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', 'acceleratorCount_max' - The maximum number of accelerators. If this parameter is not specified,
-- there is no maximum limit.
--
-- 'min', 'acceleratorCount_min' - The minimum number of accelerators. If this parameter is not specified,
-- there is no minimum limit.
newAcceleratorCount ::
  AcceleratorCount
newAcceleratorCount :: AcceleratorCount
newAcceleratorCount =
  AcceleratorCount'
    { $sel:max:AcceleratorCount' :: Maybe Int
max = forall a. Maybe a
Prelude.Nothing,
      $sel:min:AcceleratorCount' :: Maybe Int
min = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of accelerators. If this parameter is not specified,
-- there is no maximum limit.
acceleratorCount_max :: Lens.Lens' AcceleratorCount (Prelude.Maybe Prelude.Int)
acceleratorCount_max :: Lens' AcceleratorCount (Maybe Int)
acceleratorCount_max = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceleratorCount' {Maybe Int
max :: Maybe Int
$sel:max:AcceleratorCount' :: AcceleratorCount -> Maybe Int
max} -> Maybe Int
max) (\s :: AcceleratorCount
s@AcceleratorCount' {} Maybe Int
a -> AcceleratorCount
s {$sel:max:AcceleratorCount' :: Maybe Int
max = Maybe Int
a} :: AcceleratorCount)

-- | The minimum number of accelerators. If this parameter is not specified,
-- there is no minimum limit.
acceleratorCount_min :: Lens.Lens' AcceleratorCount (Prelude.Maybe Prelude.Int)
acceleratorCount_min :: Lens' AcceleratorCount (Maybe Int)
acceleratorCount_min = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceleratorCount' {Maybe Int
min :: Maybe Int
$sel:min:AcceleratorCount' :: AcceleratorCount -> Maybe Int
min} -> Maybe Int
min) (\s :: AcceleratorCount
s@AcceleratorCount' {} Maybe Int
a -> AcceleratorCount
s {$sel:min:AcceleratorCount' :: Maybe Int
min = Maybe Int
a} :: AcceleratorCount)

instance Data.FromXML AcceleratorCount where
  parseXML :: [Node] -> Either String AcceleratorCount
parseXML [Node]
x =
    Maybe Int -> Maybe Int -> AcceleratorCount
AcceleratorCount'
      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 AcceleratorCount where
  hashWithSalt :: Int -> AcceleratorCount -> Int
hashWithSalt Int
_salt AcceleratorCount' {Maybe Int
min :: Maybe Int
max :: Maybe Int
$sel:min:AcceleratorCount' :: AcceleratorCount -> Maybe Int
$sel:max:AcceleratorCount' :: AcceleratorCount -> 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 AcceleratorCount where
  rnf :: AcceleratorCount -> ()
rnf AcceleratorCount' {Maybe Int
min :: Maybe Int
max :: Maybe Int
$sel:min:AcceleratorCount' :: AcceleratorCount -> Maybe Int
$sel:max:AcceleratorCount' :: AcceleratorCount -> 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 AcceleratorCount where
  toQuery :: AcceleratorCount -> QueryString
toQuery AcceleratorCount' {Maybe Int
min :: Maybe Int
max :: Maybe Int
$sel:min:AcceleratorCount' :: AcceleratorCount -> Maybe Int
$sel:max:AcceleratorCount' :: AcceleratorCount -> 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]