{-# 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.SageMaker.Types.InferenceExecutionConfig
-- 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.SageMaker.Types.InferenceExecutionConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.InferenceExecutionMode

-- | Specifies details about how containers in a multi-container endpoint are
-- run.
--
-- /See:/ 'newInferenceExecutionConfig' smart constructor.
data InferenceExecutionConfig = InferenceExecutionConfig'
  { -- | How containers in a multi-container are run. The following values are
    -- valid.
    --
    -- -   @SERIAL@ - Containers run as a serial pipeline.
    --
    -- -   @DIRECT@ - Only the individual container that you specify is run.
    InferenceExecutionConfig -> InferenceExecutionMode
mode :: InferenceExecutionMode
  }
  deriving (InferenceExecutionConfig -> InferenceExecutionConfig -> Bool
(InferenceExecutionConfig -> InferenceExecutionConfig -> Bool)
-> (InferenceExecutionConfig -> InferenceExecutionConfig -> Bool)
-> Eq InferenceExecutionConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InferenceExecutionConfig -> InferenceExecutionConfig -> Bool
$c/= :: InferenceExecutionConfig -> InferenceExecutionConfig -> Bool
== :: InferenceExecutionConfig -> InferenceExecutionConfig -> Bool
$c== :: InferenceExecutionConfig -> InferenceExecutionConfig -> Bool
Prelude.Eq, ReadPrec [InferenceExecutionConfig]
ReadPrec InferenceExecutionConfig
Int -> ReadS InferenceExecutionConfig
ReadS [InferenceExecutionConfig]
(Int -> ReadS InferenceExecutionConfig)
-> ReadS [InferenceExecutionConfig]
-> ReadPrec InferenceExecutionConfig
-> ReadPrec [InferenceExecutionConfig]
-> Read InferenceExecutionConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InferenceExecutionConfig]
$creadListPrec :: ReadPrec [InferenceExecutionConfig]
readPrec :: ReadPrec InferenceExecutionConfig
$creadPrec :: ReadPrec InferenceExecutionConfig
readList :: ReadS [InferenceExecutionConfig]
$creadList :: ReadS [InferenceExecutionConfig]
readsPrec :: Int -> ReadS InferenceExecutionConfig
$creadsPrec :: Int -> ReadS InferenceExecutionConfig
Prelude.Read, Int -> InferenceExecutionConfig -> ShowS
[InferenceExecutionConfig] -> ShowS
InferenceExecutionConfig -> String
(Int -> InferenceExecutionConfig -> ShowS)
-> (InferenceExecutionConfig -> String)
-> ([InferenceExecutionConfig] -> ShowS)
-> Show InferenceExecutionConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InferenceExecutionConfig] -> ShowS
$cshowList :: [InferenceExecutionConfig] -> ShowS
show :: InferenceExecutionConfig -> String
$cshow :: InferenceExecutionConfig -> String
showsPrec :: Int -> InferenceExecutionConfig -> ShowS
$cshowsPrec :: Int -> InferenceExecutionConfig -> ShowS
Prelude.Show, (forall x.
 InferenceExecutionConfig -> Rep InferenceExecutionConfig x)
-> (forall x.
    Rep InferenceExecutionConfig x -> InferenceExecutionConfig)
-> Generic InferenceExecutionConfig
forall x.
Rep InferenceExecutionConfig x -> InferenceExecutionConfig
forall x.
InferenceExecutionConfig -> Rep InferenceExecutionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InferenceExecutionConfig x -> InferenceExecutionConfig
$cfrom :: forall x.
InferenceExecutionConfig -> Rep InferenceExecutionConfig x
Prelude.Generic)

-- |
-- Create a value of 'InferenceExecutionConfig' 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:
--
-- 'mode', 'inferenceExecutionConfig_mode' - How containers in a multi-container are run. The following values are
-- valid.
--
-- -   @SERIAL@ - Containers run as a serial pipeline.
--
-- -   @DIRECT@ - Only the individual container that you specify is run.
newInferenceExecutionConfig ::
  -- | 'mode'
  InferenceExecutionMode ->
  InferenceExecutionConfig
newInferenceExecutionConfig :: InferenceExecutionMode -> InferenceExecutionConfig
newInferenceExecutionConfig InferenceExecutionMode
pMode_ =
  InferenceExecutionConfig' :: InferenceExecutionMode -> InferenceExecutionConfig
InferenceExecutionConfig' {$sel:mode:InferenceExecutionConfig' :: InferenceExecutionMode
mode = InferenceExecutionMode
pMode_}

-- | How containers in a multi-container are run. The following values are
-- valid.
--
-- -   @SERIAL@ - Containers run as a serial pipeline.
--
-- -   @DIRECT@ - Only the individual container that you specify is run.
inferenceExecutionConfig_mode :: Lens.Lens' InferenceExecutionConfig InferenceExecutionMode
inferenceExecutionConfig_mode :: (InferenceExecutionMode -> f InferenceExecutionMode)
-> InferenceExecutionConfig -> f InferenceExecutionConfig
inferenceExecutionConfig_mode = (InferenceExecutionConfig -> InferenceExecutionMode)
-> (InferenceExecutionConfig
    -> InferenceExecutionMode -> InferenceExecutionConfig)
-> Lens
     InferenceExecutionConfig
     InferenceExecutionConfig
     InferenceExecutionMode
     InferenceExecutionMode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InferenceExecutionConfig' {InferenceExecutionMode
mode :: InferenceExecutionMode
$sel:mode:InferenceExecutionConfig' :: InferenceExecutionConfig -> InferenceExecutionMode
mode} -> InferenceExecutionMode
mode) (\s :: InferenceExecutionConfig
s@InferenceExecutionConfig' {} InferenceExecutionMode
a -> InferenceExecutionConfig
s {$sel:mode:InferenceExecutionConfig' :: InferenceExecutionMode
mode = InferenceExecutionMode
a} :: InferenceExecutionConfig)

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

instance Prelude.Hashable InferenceExecutionConfig

instance Prelude.NFData InferenceExecutionConfig

instance Core.ToJSON InferenceExecutionConfig where
  toJSON :: InferenceExecutionConfig -> Value
toJSON InferenceExecutionConfig' {InferenceExecutionMode
mode :: InferenceExecutionMode
$sel:mode:InferenceExecutionConfig' :: InferenceExecutionConfig -> InferenceExecutionMode
..} =
    [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
"Mode" Text -> InferenceExecutionMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InferenceExecutionMode
mode)]
      )