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

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

-- | Specifies additional configuration for hosting multi-model endpoints.
--
-- /See:/ 'newMultiModelConfig' smart constructor.
data MultiModelConfig = MultiModelConfig'
  { -- | Whether to cache models for a multi-model endpoint. By default,
    -- multi-model endpoints cache models so that a model does not have to be
    -- loaded into memory each time it is invoked. Some use cases do not
    -- benefit from model caching. For example, if an endpoint hosts a large
    -- number of models that are each invoked infrequently, the endpoint might
    -- perform better if you disable model caching. To disable model caching,
    -- set the value of this parameter to @Disabled@.
    MultiModelConfig -> Maybe ModelCacheSetting
modelCacheSetting :: Prelude.Maybe ModelCacheSetting
  }
  deriving (MultiModelConfig -> MultiModelConfig -> Bool
(MultiModelConfig -> MultiModelConfig -> Bool)
-> (MultiModelConfig -> MultiModelConfig -> Bool)
-> Eq MultiModelConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MultiModelConfig -> MultiModelConfig -> Bool
$c/= :: MultiModelConfig -> MultiModelConfig -> Bool
== :: MultiModelConfig -> MultiModelConfig -> Bool
$c== :: MultiModelConfig -> MultiModelConfig -> Bool
Prelude.Eq, ReadPrec [MultiModelConfig]
ReadPrec MultiModelConfig
Int -> ReadS MultiModelConfig
ReadS [MultiModelConfig]
(Int -> ReadS MultiModelConfig)
-> ReadS [MultiModelConfig]
-> ReadPrec MultiModelConfig
-> ReadPrec [MultiModelConfig]
-> Read MultiModelConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MultiModelConfig]
$creadListPrec :: ReadPrec [MultiModelConfig]
readPrec :: ReadPrec MultiModelConfig
$creadPrec :: ReadPrec MultiModelConfig
readList :: ReadS [MultiModelConfig]
$creadList :: ReadS [MultiModelConfig]
readsPrec :: Int -> ReadS MultiModelConfig
$creadsPrec :: Int -> ReadS MultiModelConfig
Prelude.Read, Int -> MultiModelConfig -> ShowS
[MultiModelConfig] -> ShowS
MultiModelConfig -> String
(Int -> MultiModelConfig -> ShowS)
-> (MultiModelConfig -> String)
-> ([MultiModelConfig] -> ShowS)
-> Show MultiModelConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MultiModelConfig] -> ShowS
$cshowList :: [MultiModelConfig] -> ShowS
show :: MultiModelConfig -> String
$cshow :: MultiModelConfig -> String
showsPrec :: Int -> MultiModelConfig -> ShowS
$cshowsPrec :: Int -> MultiModelConfig -> ShowS
Prelude.Show, (forall x. MultiModelConfig -> Rep MultiModelConfig x)
-> (forall x. Rep MultiModelConfig x -> MultiModelConfig)
-> Generic MultiModelConfig
forall x. Rep MultiModelConfig x -> MultiModelConfig
forall x. MultiModelConfig -> Rep MultiModelConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MultiModelConfig x -> MultiModelConfig
$cfrom :: forall x. MultiModelConfig -> Rep MultiModelConfig x
Prelude.Generic)

-- |
-- Create a value of 'MultiModelConfig' 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:
--
-- 'modelCacheSetting', 'multiModelConfig_modelCacheSetting' - Whether to cache models for a multi-model endpoint. By default,
-- multi-model endpoints cache models so that a model does not have to be
-- loaded into memory each time it is invoked. Some use cases do not
-- benefit from model caching. For example, if an endpoint hosts a large
-- number of models that are each invoked infrequently, the endpoint might
-- perform better if you disable model caching. To disable model caching,
-- set the value of this parameter to @Disabled@.
newMultiModelConfig ::
  MultiModelConfig
newMultiModelConfig :: MultiModelConfig
newMultiModelConfig =
  MultiModelConfig' :: Maybe ModelCacheSetting -> MultiModelConfig
MultiModelConfig'
    { $sel:modelCacheSetting:MultiModelConfig' :: Maybe ModelCacheSetting
modelCacheSetting =
        Maybe ModelCacheSetting
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether to cache models for a multi-model endpoint. By default,
-- multi-model endpoints cache models so that a model does not have to be
-- loaded into memory each time it is invoked. Some use cases do not
-- benefit from model caching. For example, if an endpoint hosts a large
-- number of models that are each invoked infrequently, the endpoint might
-- perform better if you disable model caching. To disable model caching,
-- set the value of this parameter to @Disabled@.
multiModelConfig_modelCacheSetting :: Lens.Lens' MultiModelConfig (Prelude.Maybe ModelCacheSetting)
multiModelConfig_modelCacheSetting :: (Maybe ModelCacheSetting -> f (Maybe ModelCacheSetting))
-> MultiModelConfig -> f MultiModelConfig
multiModelConfig_modelCacheSetting = (MultiModelConfig -> Maybe ModelCacheSetting)
-> (MultiModelConfig
    -> Maybe ModelCacheSetting -> MultiModelConfig)
-> Lens
     MultiModelConfig
     MultiModelConfig
     (Maybe ModelCacheSetting)
     (Maybe ModelCacheSetting)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultiModelConfig' {Maybe ModelCacheSetting
modelCacheSetting :: Maybe ModelCacheSetting
$sel:modelCacheSetting:MultiModelConfig' :: MultiModelConfig -> Maybe ModelCacheSetting
modelCacheSetting} -> Maybe ModelCacheSetting
modelCacheSetting) (\s :: MultiModelConfig
s@MultiModelConfig' {} Maybe ModelCacheSetting
a -> MultiModelConfig
s {$sel:modelCacheSetting:MultiModelConfig' :: Maybe ModelCacheSetting
modelCacheSetting = Maybe ModelCacheSetting
a} :: MultiModelConfig)

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

instance Prelude.Hashable MultiModelConfig

instance Prelude.NFData MultiModelConfig

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