{-# 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.GpuInfo
-- 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.GpuInfo 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 Amazonka.EC2.Types.GpuDeviceInfo
import qualified Amazonka.Prelude as Prelude

-- | Describes the GPU accelerators for the instance type.
--
-- /See:/ 'newGpuInfo' smart constructor.
data GpuInfo = GpuInfo'
  { -- | Describes the GPU accelerators for the instance type.
    GpuInfo -> Maybe [GpuDeviceInfo]
gpus :: Prelude.Maybe [GpuDeviceInfo],
    -- | The total size of the memory for the GPU accelerators for the instance
    -- type, in MiB.
    GpuInfo -> Maybe Int
totalGpuMemoryInMiB :: Prelude.Maybe Prelude.Int
  }
  deriving (GpuInfo -> GpuInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GpuInfo -> GpuInfo -> Bool
$c/= :: GpuInfo -> GpuInfo -> Bool
== :: GpuInfo -> GpuInfo -> Bool
$c== :: GpuInfo -> GpuInfo -> Bool
Prelude.Eq, ReadPrec [GpuInfo]
ReadPrec GpuInfo
Int -> ReadS GpuInfo
ReadS [GpuInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GpuInfo]
$creadListPrec :: ReadPrec [GpuInfo]
readPrec :: ReadPrec GpuInfo
$creadPrec :: ReadPrec GpuInfo
readList :: ReadS [GpuInfo]
$creadList :: ReadS [GpuInfo]
readsPrec :: Int -> ReadS GpuInfo
$creadsPrec :: Int -> ReadS GpuInfo
Prelude.Read, Int -> GpuInfo -> ShowS
[GpuInfo] -> ShowS
GpuInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GpuInfo] -> ShowS
$cshowList :: [GpuInfo] -> ShowS
show :: GpuInfo -> String
$cshow :: GpuInfo -> String
showsPrec :: Int -> GpuInfo -> ShowS
$cshowsPrec :: Int -> GpuInfo -> ShowS
Prelude.Show, forall x. Rep GpuInfo x -> GpuInfo
forall x. GpuInfo -> Rep GpuInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GpuInfo x -> GpuInfo
$cfrom :: forall x. GpuInfo -> Rep GpuInfo x
Prelude.Generic)

-- |
-- Create a value of 'GpuInfo' 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:
--
-- 'gpus', 'gpuInfo_gpus' - Describes the GPU accelerators for the instance type.
--
-- 'totalGpuMemoryInMiB', 'gpuInfo_totalGpuMemoryInMiB' - The total size of the memory for the GPU accelerators for the instance
-- type, in MiB.
newGpuInfo ::
  GpuInfo
newGpuInfo :: GpuInfo
newGpuInfo =
  GpuInfo'
    { $sel:gpus:GpuInfo' :: Maybe [GpuDeviceInfo]
gpus = forall a. Maybe a
Prelude.Nothing,
      $sel:totalGpuMemoryInMiB:GpuInfo' :: Maybe Int
totalGpuMemoryInMiB = forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the GPU accelerators for the instance type.
gpuInfo_gpus :: Lens.Lens' GpuInfo (Prelude.Maybe [GpuDeviceInfo])
gpuInfo_gpus :: Lens' GpuInfo (Maybe [GpuDeviceInfo])
gpuInfo_gpus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GpuInfo' {Maybe [GpuDeviceInfo]
gpus :: Maybe [GpuDeviceInfo]
$sel:gpus:GpuInfo' :: GpuInfo -> Maybe [GpuDeviceInfo]
gpus} -> Maybe [GpuDeviceInfo]
gpus) (\s :: GpuInfo
s@GpuInfo' {} Maybe [GpuDeviceInfo]
a -> GpuInfo
s {$sel:gpus:GpuInfo' :: Maybe [GpuDeviceInfo]
gpus = Maybe [GpuDeviceInfo]
a} :: GpuInfo) 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 total size of the memory for the GPU accelerators for the instance
-- type, in MiB.
gpuInfo_totalGpuMemoryInMiB :: Lens.Lens' GpuInfo (Prelude.Maybe Prelude.Int)
gpuInfo_totalGpuMemoryInMiB :: Lens' GpuInfo (Maybe Int)
gpuInfo_totalGpuMemoryInMiB = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GpuInfo' {Maybe Int
totalGpuMemoryInMiB :: Maybe Int
$sel:totalGpuMemoryInMiB:GpuInfo' :: GpuInfo -> Maybe Int
totalGpuMemoryInMiB} -> Maybe Int
totalGpuMemoryInMiB) (\s :: GpuInfo
s@GpuInfo' {} Maybe Int
a -> GpuInfo
s {$sel:totalGpuMemoryInMiB:GpuInfo' :: Maybe Int
totalGpuMemoryInMiB = Maybe Int
a} :: GpuInfo)

instance Data.FromXML GpuInfo where
  parseXML :: [Node] -> Either String GpuInfo
parseXML [Node]
x =
    Maybe [GpuDeviceInfo] -> Maybe Int -> GpuInfo
GpuInfo'
      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
"gpus"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      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
"totalGpuMemoryInMiB")

instance Prelude.Hashable GpuInfo where
  hashWithSalt :: Int -> GpuInfo -> Int
hashWithSalt Int
_salt GpuInfo' {Maybe Int
Maybe [GpuDeviceInfo]
totalGpuMemoryInMiB :: Maybe Int
gpus :: Maybe [GpuDeviceInfo]
$sel:totalGpuMemoryInMiB:GpuInfo' :: GpuInfo -> Maybe Int
$sel:gpus:GpuInfo' :: GpuInfo -> Maybe [GpuDeviceInfo]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [GpuDeviceInfo]
gpus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
totalGpuMemoryInMiB

instance Prelude.NFData GpuInfo where
  rnf :: GpuInfo -> ()
rnf GpuInfo' {Maybe Int
Maybe [GpuDeviceInfo]
totalGpuMemoryInMiB :: Maybe Int
gpus :: Maybe [GpuDeviceInfo]
$sel:totalGpuMemoryInMiB:GpuInfo' :: GpuInfo -> Maybe Int
$sel:gpus:GpuInfo' :: GpuInfo -> Maybe [GpuDeviceInfo]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [GpuDeviceInfo]
gpus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
totalGpuMemoryInMiB