{-# 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.FpgaInfo
-- 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.FpgaInfo 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.FpgaDeviceInfo
import qualified Amazonka.Prelude as Prelude

-- | Describes the FPGAs for the instance type.
--
-- /See:/ 'newFpgaInfo' smart constructor.
data FpgaInfo = FpgaInfo'
  { -- | Describes the FPGAs for the instance type.
    FpgaInfo -> Maybe [FpgaDeviceInfo]
fpgas :: Prelude.Maybe [FpgaDeviceInfo],
    -- | The total memory of all FPGA accelerators for the instance type.
    FpgaInfo -> Maybe Int
totalFpgaMemoryInMiB :: Prelude.Maybe Prelude.Int
  }
  deriving (FpgaInfo -> FpgaInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FpgaInfo -> FpgaInfo -> Bool
$c/= :: FpgaInfo -> FpgaInfo -> Bool
== :: FpgaInfo -> FpgaInfo -> Bool
$c== :: FpgaInfo -> FpgaInfo -> Bool
Prelude.Eq, ReadPrec [FpgaInfo]
ReadPrec FpgaInfo
Int -> ReadS FpgaInfo
ReadS [FpgaInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FpgaInfo]
$creadListPrec :: ReadPrec [FpgaInfo]
readPrec :: ReadPrec FpgaInfo
$creadPrec :: ReadPrec FpgaInfo
readList :: ReadS [FpgaInfo]
$creadList :: ReadS [FpgaInfo]
readsPrec :: Int -> ReadS FpgaInfo
$creadsPrec :: Int -> ReadS FpgaInfo
Prelude.Read, Int -> FpgaInfo -> ShowS
[FpgaInfo] -> ShowS
FpgaInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FpgaInfo] -> ShowS
$cshowList :: [FpgaInfo] -> ShowS
show :: FpgaInfo -> String
$cshow :: FpgaInfo -> String
showsPrec :: Int -> FpgaInfo -> ShowS
$cshowsPrec :: Int -> FpgaInfo -> ShowS
Prelude.Show, forall x. Rep FpgaInfo x -> FpgaInfo
forall x. FpgaInfo -> Rep FpgaInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FpgaInfo x -> FpgaInfo
$cfrom :: forall x. FpgaInfo -> Rep FpgaInfo x
Prelude.Generic)

-- |
-- Create a value of 'FpgaInfo' 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:
--
-- 'fpgas', 'fpgaInfo_fpgas' - Describes the FPGAs for the instance type.
--
-- 'totalFpgaMemoryInMiB', 'fpgaInfo_totalFpgaMemoryInMiB' - The total memory of all FPGA accelerators for the instance type.
newFpgaInfo ::
  FpgaInfo
newFpgaInfo :: FpgaInfo
newFpgaInfo =
  FpgaInfo'
    { $sel:fpgas:FpgaInfo' :: Maybe [FpgaDeviceInfo]
fpgas = forall a. Maybe a
Prelude.Nothing,
      $sel:totalFpgaMemoryInMiB:FpgaInfo' :: Maybe Int
totalFpgaMemoryInMiB = forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the FPGAs for the instance type.
fpgaInfo_fpgas :: Lens.Lens' FpgaInfo (Prelude.Maybe [FpgaDeviceInfo])
fpgaInfo_fpgas :: Lens' FpgaInfo (Maybe [FpgaDeviceInfo])
fpgaInfo_fpgas = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FpgaInfo' {Maybe [FpgaDeviceInfo]
fpgas :: Maybe [FpgaDeviceInfo]
$sel:fpgas:FpgaInfo' :: FpgaInfo -> Maybe [FpgaDeviceInfo]
fpgas} -> Maybe [FpgaDeviceInfo]
fpgas) (\s :: FpgaInfo
s@FpgaInfo' {} Maybe [FpgaDeviceInfo]
a -> FpgaInfo
s {$sel:fpgas:FpgaInfo' :: Maybe [FpgaDeviceInfo]
fpgas = Maybe [FpgaDeviceInfo]
a} :: FpgaInfo) 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 memory of all FPGA accelerators for the instance type.
fpgaInfo_totalFpgaMemoryInMiB :: Lens.Lens' FpgaInfo (Prelude.Maybe Prelude.Int)
fpgaInfo_totalFpgaMemoryInMiB :: Lens' FpgaInfo (Maybe Int)
fpgaInfo_totalFpgaMemoryInMiB = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FpgaInfo' {Maybe Int
totalFpgaMemoryInMiB :: Maybe Int
$sel:totalFpgaMemoryInMiB:FpgaInfo' :: FpgaInfo -> Maybe Int
totalFpgaMemoryInMiB} -> Maybe Int
totalFpgaMemoryInMiB) (\s :: FpgaInfo
s@FpgaInfo' {} Maybe Int
a -> FpgaInfo
s {$sel:totalFpgaMemoryInMiB:FpgaInfo' :: Maybe Int
totalFpgaMemoryInMiB = Maybe Int
a} :: FpgaInfo)

instance Data.FromXML FpgaInfo where
  parseXML :: [Node] -> Either String FpgaInfo
parseXML [Node]
x =
    Maybe [FpgaDeviceInfo] -> Maybe Int -> FpgaInfo
FpgaInfo'
      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
"fpgas"
                      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
"totalFpgaMemoryInMiB")

instance Prelude.Hashable FpgaInfo where
  hashWithSalt :: Int -> FpgaInfo -> Int
hashWithSalt Int
_salt FpgaInfo' {Maybe Int
Maybe [FpgaDeviceInfo]
totalFpgaMemoryInMiB :: Maybe Int
fpgas :: Maybe [FpgaDeviceInfo]
$sel:totalFpgaMemoryInMiB:FpgaInfo' :: FpgaInfo -> Maybe Int
$sel:fpgas:FpgaInfo' :: FpgaInfo -> Maybe [FpgaDeviceInfo]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [FpgaDeviceInfo]
fpgas
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
totalFpgaMemoryInMiB

instance Prelude.NFData FpgaInfo where
  rnf :: FpgaInfo -> ()
rnf FpgaInfo' {Maybe Int
Maybe [FpgaDeviceInfo]
totalFpgaMemoryInMiB :: Maybe Int
fpgas :: Maybe [FpgaDeviceInfo]
$sel:totalFpgaMemoryInMiB:FpgaInfo' :: FpgaInfo -> Maybe Int
$sel:fpgas:FpgaInfo' :: FpgaInfo -> Maybe [FpgaDeviceInfo]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FpgaDeviceInfo]
fpgas
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
totalFpgaMemoryInMiB