{-# 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.ECS.Types.PlatformDevice
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECS.Types.PlatformDevice where

import qualified Amazonka.Core as Core
import Amazonka.ECS.Types.PlatformDeviceType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The devices that are available on the container instance. The only
-- supported device type is a GPU.
--
-- /See:/ 'newPlatformDevice' smart constructor.
data PlatformDevice = PlatformDevice'
  { -- | The ID for the GPU(s) on the container instance. The available GPU IDs
    -- can also be obtained on the container instance in the
    -- @\/var\/lib\/ecs\/gpu\/nvidia_gpu_info.json@ file.
    PlatformDevice -> Text
id :: Prelude.Text,
    -- | The type of device that is available on the container instance. The only
    -- supported value is @GPU@.
    PlatformDevice -> PlatformDeviceType
type' :: PlatformDeviceType
  }
  deriving (PlatformDevice -> PlatformDevice -> Bool
(PlatformDevice -> PlatformDevice -> Bool)
-> (PlatformDevice -> PlatformDevice -> Bool) -> Eq PlatformDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlatformDevice -> PlatformDevice -> Bool
$c/= :: PlatformDevice -> PlatformDevice -> Bool
== :: PlatformDevice -> PlatformDevice -> Bool
$c== :: PlatformDevice -> PlatformDevice -> Bool
Prelude.Eq, ReadPrec [PlatformDevice]
ReadPrec PlatformDevice
Int -> ReadS PlatformDevice
ReadS [PlatformDevice]
(Int -> ReadS PlatformDevice)
-> ReadS [PlatformDevice]
-> ReadPrec PlatformDevice
-> ReadPrec [PlatformDevice]
-> Read PlatformDevice
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PlatformDevice]
$creadListPrec :: ReadPrec [PlatformDevice]
readPrec :: ReadPrec PlatformDevice
$creadPrec :: ReadPrec PlatformDevice
readList :: ReadS [PlatformDevice]
$creadList :: ReadS [PlatformDevice]
readsPrec :: Int -> ReadS PlatformDevice
$creadsPrec :: Int -> ReadS PlatformDevice
Prelude.Read, Int -> PlatformDevice -> ShowS
[PlatformDevice] -> ShowS
PlatformDevice -> String
(Int -> PlatformDevice -> ShowS)
-> (PlatformDevice -> String)
-> ([PlatformDevice] -> ShowS)
-> Show PlatformDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlatformDevice] -> ShowS
$cshowList :: [PlatformDevice] -> ShowS
show :: PlatformDevice -> String
$cshow :: PlatformDevice -> String
showsPrec :: Int -> PlatformDevice -> ShowS
$cshowsPrec :: Int -> PlatformDevice -> ShowS
Prelude.Show, (forall x. PlatformDevice -> Rep PlatformDevice x)
-> (forall x. Rep PlatformDevice x -> PlatformDevice)
-> Generic PlatformDevice
forall x. Rep PlatformDevice x -> PlatformDevice
forall x. PlatformDevice -> Rep PlatformDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PlatformDevice x -> PlatformDevice
$cfrom :: forall x. PlatformDevice -> Rep PlatformDevice x
Prelude.Generic)

-- |
-- Create a value of 'PlatformDevice' 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:
--
-- 'id', 'platformDevice_id' - The ID for the GPU(s) on the container instance. The available GPU IDs
-- can also be obtained on the container instance in the
-- @\/var\/lib\/ecs\/gpu\/nvidia_gpu_info.json@ file.
--
-- 'type'', 'platformDevice_type' - The type of device that is available on the container instance. The only
-- supported value is @GPU@.
newPlatformDevice ::
  -- | 'id'
  Prelude.Text ->
  -- | 'type''
  PlatformDeviceType ->
  PlatformDevice
newPlatformDevice :: Text -> PlatformDeviceType -> PlatformDevice
newPlatformDevice Text
pId_ PlatformDeviceType
pType_ =
  PlatformDevice' :: Text -> PlatformDeviceType -> PlatformDevice
PlatformDevice' {$sel:id:PlatformDevice' :: Text
id = Text
pId_, $sel:type':PlatformDevice' :: PlatformDeviceType
type' = PlatformDeviceType
pType_}

-- | The ID for the GPU(s) on the container instance. The available GPU IDs
-- can also be obtained on the container instance in the
-- @\/var\/lib\/ecs\/gpu\/nvidia_gpu_info.json@ file.
platformDevice_id :: Lens.Lens' PlatformDevice Prelude.Text
platformDevice_id :: (Text -> f Text) -> PlatformDevice -> f PlatformDevice
platformDevice_id = (PlatformDevice -> Text)
-> (PlatformDevice -> Text -> PlatformDevice)
-> Lens PlatformDevice PlatformDevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlatformDevice' {Text
id :: Text
$sel:id:PlatformDevice' :: PlatformDevice -> Text
id} -> Text
id) (\s :: PlatformDevice
s@PlatformDevice' {} Text
a -> PlatformDevice
s {$sel:id:PlatformDevice' :: Text
id = Text
a} :: PlatformDevice)

-- | The type of device that is available on the container instance. The only
-- supported value is @GPU@.
platformDevice_type :: Lens.Lens' PlatformDevice PlatformDeviceType
platformDevice_type :: (PlatformDeviceType -> f PlatformDeviceType)
-> PlatformDevice -> f PlatformDevice
platformDevice_type = (PlatformDevice -> PlatformDeviceType)
-> (PlatformDevice -> PlatformDeviceType -> PlatformDevice)
-> Lens
     PlatformDevice PlatformDevice PlatformDeviceType PlatformDeviceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlatformDevice' {PlatformDeviceType
type' :: PlatformDeviceType
$sel:type':PlatformDevice' :: PlatformDevice -> PlatformDeviceType
type'} -> PlatformDeviceType
type') (\s :: PlatformDevice
s@PlatformDevice' {} PlatformDeviceType
a -> PlatformDevice
s {$sel:type':PlatformDevice' :: PlatformDeviceType
type' = PlatformDeviceType
a} :: PlatformDevice)

instance Prelude.Hashable PlatformDevice

instance Prelude.NFData PlatformDevice

instance Core.ToJSON PlatformDevice where
  toJSON :: PlatformDevice -> Value
toJSON PlatformDevice' {Text
PlatformDeviceType
type' :: PlatformDeviceType
id :: Text
$sel:type':PlatformDevice' :: PlatformDevice -> PlatformDeviceType
$sel:id:PlatformDevice' :: PlatformDevice -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> PlatformDeviceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PlatformDeviceType
type')
          ]
      )