{-# 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.InferenceAccelerator
-- 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.InferenceAccelerator where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details on a Elastic Inference accelerator. For more information, see
-- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-inference.html Working with Amazon Elastic Inference on Amazon ECS>
-- in the /Amazon Elastic Container Service Developer Guide/.
--
-- /See:/ 'newInferenceAccelerator' smart constructor.
data InferenceAccelerator = InferenceAccelerator'
  { -- | The Elastic Inference accelerator device name. The @deviceName@ must
    -- also be referenced in a container definition as a ResourceRequirement.
    InferenceAccelerator -> Text
deviceName :: Prelude.Text,
    -- | The Elastic Inference accelerator type to use.
    InferenceAccelerator -> Text
deviceType :: Prelude.Text
  }
  deriving (InferenceAccelerator -> InferenceAccelerator -> Bool
(InferenceAccelerator -> InferenceAccelerator -> Bool)
-> (InferenceAccelerator -> InferenceAccelerator -> Bool)
-> Eq InferenceAccelerator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InferenceAccelerator -> InferenceAccelerator -> Bool
$c/= :: InferenceAccelerator -> InferenceAccelerator -> Bool
== :: InferenceAccelerator -> InferenceAccelerator -> Bool
$c== :: InferenceAccelerator -> InferenceAccelerator -> Bool
Prelude.Eq, ReadPrec [InferenceAccelerator]
ReadPrec InferenceAccelerator
Int -> ReadS InferenceAccelerator
ReadS [InferenceAccelerator]
(Int -> ReadS InferenceAccelerator)
-> ReadS [InferenceAccelerator]
-> ReadPrec InferenceAccelerator
-> ReadPrec [InferenceAccelerator]
-> Read InferenceAccelerator
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InferenceAccelerator]
$creadListPrec :: ReadPrec [InferenceAccelerator]
readPrec :: ReadPrec InferenceAccelerator
$creadPrec :: ReadPrec InferenceAccelerator
readList :: ReadS [InferenceAccelerator]
$creadList :: ReadS [InferenceAccelerator]
readsPrec :: Int -> ReadS InferenceAccelerator
$creadsPrec :: Int -> ReadS InferenceAccelerator
Prelude.Read, Int -> InferenceAccelerator -> ShowS
[InferenceAccelerator] -> ShowS
InferenceAccelerator -> String
(Int -> InferenceAccelerator -> ShowS)
-> (InferenceAccelerator -> String)
-> ([InferenceAccelerator] -> ShowS)
-> Show InferenceAccelerator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InferenceAccelerator] -> ShowS
$cshowList :: [InferenceAccelerator] -> ShowS
show :: InferenceAccelerator -> String
$cshow :: InferenceAccelerator -> String
showsPrec :: Int -> InferenceAccelerator -> ShowS
$cshowsPrec :: Int -> InferenceAccelerator -> ShowS
Prelude.Show, (forall x. InferenceAccelerator -> Rep InferenceAccelerator x)
-> (forall x. Rep InferenceAccelerator x -> InferenceAccelerator)
-> Generic InferenceAccelerator
forall x. Rep InferenceAccelerator x -> InferenceAccelerator
forall x. InferenceAccelerator -> Rep InferenceAccelerator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InferenceAccelerator x -> InferenceAccelerator
$cfrom :: forall x. InferenceAccelerator -> Rep InferenceAccelerator x
Prelude.Generic)

-- |
-- Create a value of 'InferenceAccelerator' 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:
--
-- 'deviceName', 'inferenceAccelerator_deviceName' - The Elastic Inference accelerator device name. The @deviceName@ must
-- also be referenced in a container definition as a ResourceRequirement.
--
-- 'deviceType', 'inferenceAccelerator_deviceType' - The Elastic Inference accelerator type to use.
newInferenceAccelerator ::
  -- | 'deviceName'
  Prelude.Text ->
  -- | 'deviceType'
  Prelude.Text ->
  InferenceAccelerator
newInferenceAccelerator :: Text -> Text -> InferenceAccelerator
newInferenceAccelerator Text
pDeviceName_ Text
pDeviceType_ =
  InferenceAccelerator' :: Text -> Text -> InferenceAccelerator
InferenceAccelerator'
    { $sel:deviceName:InferenceAccelerator' :: Text
deviceName = Text
pDeviceName_,
      $sel:deviceType:InferenceAccelerator' :: Text
deviceType = Text
pDeviceType_
    }

-- | The Elastic Inference accelerator device name. The @deviceName@ must
-- also be referenced in a container definition as a ResourceRequirement.
inferenceAccelerator_deviceName :: Lens.Lens' InferenceAccelerator Prelude.Text
inferenceAccelerator_deviceName :: (Text -> f Text) -> InferenceAccelerator -> f InferenceAccelerator
inferenceAccelerator_deviceName = (InferenceAccelerator -> Text)
-> (InferenceAccelerator -> Text -> InferenceAccelerator)
-> Lens InferenceAccelerator InferenceAccelerator Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InferenceAccelerator' {Text
deviceName :: Text
$sel:deviceName:InferenceAccelerator' :: InferenceAccelerator -> Text
deviceName} -> Text
deviceName) (\s :: InferenceAccelerator
s@InferenceAccelerator' {} Text
a -> InferenceAccelerator
s {$sel:deviceName:InferenceAccelerator' :: Text
deviceName = Text
a} :: InferenceAccelerator)

-- | The Elastic Inference accelerator type to use.
inferenceAccelerator_deviceType :: Lens.Lens' InferenceAccelerator Prelude.Text
inferenceAccelerator_deviceType :: (Text -> f Text) -> InferenceAccelerator -> f InferenceAccelerator
inferenceAccelerator_deviceType = (InferenceAccelerator -> Text)
-> (InferenceAccelerator -> Text -> InferenceAccelerator)
-> Lens InferenceAccelerator InferenceAccelerator Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InferenceAccelerator' {Text
deviceType :: Text
$sel:deviceType:InferenceAccelerator' :: InferenceAccelerator -> Text
deviceType} -> Text
deviceType) (\s :: InferenceAccelerator
s@InferenceAccelerator' {} Text
a -> InferenceAccelerator
s {$sel:deviceType:InferenceAccelerator' :: Text
deviceType = Text
a} :: InferenceAccelerator)

instance Core.FromJSON InferenceAccelerator where
  parseJSON :: Value -> Parser InferenceAccelerator
parseJSON =
    String
-> (Object -> Parser InferenceAccelerator)
-> Value
-> Parser InferenceAccelerator
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InferenceAccelerator"
      ( \Object
x ->
          Text -> Text -> InferenceAccelerator
InferenceAccelerator'
            (Text -> Text -> InferenceAccelerator)
-> Parser Text -> Parser (Text -> InferenceAccelerator)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"deviceName")
            Parser (Text -> InferenceAccelerator)
-> Parser Text -> Parser InferenceAccelerator
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"deviceType")
      )

instance Prelude.Hashable InferenceAccelerator

instance Prelude.NFData InferenceAccelerator

instance Core.ToJSON InferenceAccelerator where
  toJSON :: InferenceAccelerator -> Value
toJSON InferenceAccelerator' {Text
deviceType :: Text
deviceName :: Text
$sel:deviceType:InferenceAccelerator' :: InferenceAccelerator -> Text
$sel:deviceName:InferenceAccelerator' :: InferenceAccelerator -> 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
"deviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deviceName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"deviceType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deviceType)
          ]
      )