{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.MultiModelConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:modelCacheSetting:MultiModelConfig' :: Maybe ModelCacheSetting
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 :: Lens' MultiModelConfig (Maybe ModelCacheSetting)
multiModelConfig_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 Data.FromJSON MultiModelConfig where
  parseJSON :: Value -> Parser MultiModelConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MultiModelConfig"
      ( \Object
x ->
          Maybe ModelCacheSetting -> MultiModelConfig
MultiModelConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ModelCacheSetting")
      )

instance Prelude.Hashable MultiModelConfig where
  hashWithSalt :: Int -> MultiModelConfig -> Int
hashWithSalt Int
_salt MultiModelConfig' {Maybe ModelCacheSetting
modelCacheSetting :: Maybe ModelCacheSetting
$sel:modelCacheSetting:MultiModelConfig' :: MultiModelConfig -> Maybe ModelCacheSetting
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ModelCacheSetting
modelCacheSetting

instance Prelude.NFData MultiModelConfig where
  rnf :: MultiModelConfig -> ()
rnf MultiModelConfig' {Maybe ModelCacheSetting
modelCacheSetting :: Maybe ModelCacheSetting
$sel:modelCacheSetting:MultiModelConfig' :: MultiModelConfig -> Maybe ModelCacheSetting
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ModelCacheSetting
modelCacheSetting

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