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

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

-- | Details on an Elastic Inference accelerator task override. This
-- parameter is used to override the Elastic Inference accelerator
-- specified in the task definition. 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:/ 'newInferenceAcceleratorOverride' smart constructor.
data InferenceAcceleratorOverride = InferenceAcceleratorOverride'
  { -- | The Elastic Inference accelerator device name to override for the task.
    -- This parameter must match a @deviceName@ specified in the task
    -- definition.
    InferenceAcceleratorOverride -> Maybe Text
deviceName :: Prelude.Maybe Prelude.Text,
    -- | The Elastic Inference accelerator type to use.
    InferenceAcceleratorOverride -> Maybe Text
deviceType :: Prelude.Maybe Prelude.Text
  }
  deriving (InferenceAcceleratorOverride
-> InferenceAcceleratorOverride -> Bool
(InferenceAcceleratorOverride
 -> InferenceAcceleratorOverride -> Bool)
-> (InferenceAcceleratorOverride
    -> InferenceAcceleratorOverride -> Bool)
-> Eq InferenceAcceleratorOverride
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InferenceAcceleratorOverride
-> InferenceAcceleratorOverride -> Bool
$c/= :: InferenceAcceleratorOverride
-> InferenceAcceleratorOverride -> Bool
== :: InferenceAcceleratorOverride
-> InferenceAcceleratorOverride -> Bool
$c== :: InferenceAcceleratorOverride
-> InferenceAcceleratorOverride -> Bool
Prelude.Eq, ReadPrec [InferenceAcceleratorOverride]
ReadPrec InferenceAcceleratorOverride
Int -> ReadS InferenceAcceleratorOverride
ReadS [InferenceAcceleratorOverride]
(Int -> ReadS InferenceAcceleratorOverride)
-> ReadS [InferenceAcceleratorOverride]
-> ReadPrec InferenceAcceleratorOverride
-> ReadPrec [InferenceAcceleratorOverride]
-> Read InferenceAcceleratorOverride
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InferenceAcceleratorOverride]
$creadListPrec :: ReadPrec [InferenceAcceleratorOverride]
readPrec :: ReadPrec InferenceAcceleratorOverride
$creadPrec :: ReadPrec InferenceAcceleratorOverride
readList :: ReadS [InferenceAcceleratorOverride]
$creadList :: ReadS [InferenceAcceleratorOverride]
readsPrec :: Int -> ReadS InferenceAcceleratorOverride
$creadsPrec :: Int -> ReadS InferenceAcceleratorOverride
Prelude.Read, Int -> InferenceAcceleratorOverride -> ShowS
[InferenceAcceleratorOverride] -> ShowS
InferenceAcceleratorOverride -> String
(Int -> InferenceAcceleratorOverride -> ShowS)
-> (InferenceAcceleratorOverride -> String)
-> ([InferenceAcceleratorOverride] -> ShowS)
-> Show InferenceAcceleratorOverride
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InferenceAcceleratorOverride] -> ShowS
$cshowList :: [InferenceAcceleratorOverride] -> ShowS
show :: InferenceAcceleratorOverride -> String
$cshow :: InferenceAcceleratorOverride -> String
showsPrec :: Int -> InferenceAcceleratorOverride -> ShowS
$cshowsPrec :: Int -> InferenceAcceleratorOverride -> ShowS
Prelude.Show, (forall x.
 InferenceAcceleratorOverride -> Rep InferenceAcceleratorOverride x)
-> (forall x.
    Rep InferenceAcceleratorOverride x -> InferenceAcceleratorOverride)
-> Generic InferenceAcceleratorOverride
forall x.
Rep InferenceAcceleratorOverride x -> InferenceAcceleratorOverride
forall x.
InferenceAcceleratorOverride -> Rep InferenceAcceleratorOverride x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InferenceAcceleratorOverride x -> InferenceAcceleratorOverride
$cfrom :: forall x.
InferenceAcceleratorOverride -> Rep InferenceAcceleratorOverride x
Prelude.Generic)

-- |
-- Create a value of 'InferenceAcceleratorOverride' 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', 'inferenceAcceleratorOverride_deviceName' - The Elastic Inference accelerator device name to override for the task.
-- This parameter must match a @deviceName@ specified in the task
-- definition.
--
-- 'deviceType', 'inferenceAcceleratorOverride_deviceType' - The Elastic Inference accelerator type to use.
newInferenceAcceleratorOverride ::
  InferenceAcceleratorOverride
newInferenceAcceleratorOverride :: InferenceAcceleratorOverride
newInferenceAcceleratorOverride =
  InferenceAcceleratorOverride' :: Maybe Text -> Maybe Text -> InferenceAcceleratorOverride
InferenceAcceleratorOverride'
    { $sel:deviceName:InferenceAcceleratorOverride' :: Maybe Text
deviceName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceType:InferenceAcceleratorOverride' :: Maybe Text
deviceType = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Elastic Inference accelerator device name to override for the task.
-- This parameter must match a @deviceName@ specified in the task
-- definition.
inferenceAcceleratorOverride_deviceName :: Lens.Lens' InferenceAcceleratorOverride (Prelude.Maybe Prelude.Text)
inferenceAcceleratorOverride_deviceName :: (Maybe Text -> f (Maybe Text))
-> InferenceAcceleratorOverride -> f InferenceAcceleratorOverride
inferenceAcceleratorOverride_deviceName = (InferenceAcceleratorOverride -> Maybe Text)
-> (InferenceAcceleratorOverride
    -> Maybe Text -> InferenceAcceleratorOverride)
-> Lens
     InferenceAcceleratorOverride
     InferenceAcceleratorOverride
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InferenceAcceleratorOverride' {Maybe Text
deviceName :: Maybe Text
$sel:deviceName:InferenceAcceleratorOverride' :: InferenceAcceleratorOverride -> Maybe Text
deviceName} -> Maybe Text
deviceName) (\s :: InferenceAcceleratorOverride
s@InferenceAcceleratorOverride' {} Maybe Text
a -> InferenceAcceleratorOverride
s {$sel:deviceName:InferenceAcceleratorOverride' :: Maybe Text
deviceName = Maybe Text
a} :: InferenceAcceleratorOverride)

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

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

instance
  Prelude.Hashable
    InferenceAcceleratorOverride

instance Prelude.NFData InferenceAcceleratorOverride

instance Core.ToJSON InferenceAcceleratorOverride where
  toJSON :: InferenceAcceleratorOverride -> Value
toJSON InferenceAcceleratorOverride' {Maybe Text
deviceType :: Maybe Text
deviceName :: Maybe Text
$sel:deviceType:InferenceAcceleratorOverride' :: InferenceAcceleratorOverride -> Maybe Text
$sel:deviceName:InferenceAcceleratorOverride' :: InferenceAcceleratorOverride -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"deviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
deviceName,
            (Text
"deviceType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
deviceType
          ]
      )