{-# 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.AsyncInferenceClientConfig
-- 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.AsyncInferenceClientConfig 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

-- | Configures the behavior of the client used by SageMaker to interact with
-- the model container during asynchronous inference.
--
-- /See:/ 'newAsyncInferenceClientConfig' smart constructor.
data AsyncInferenceClientConfig = AsyncInferenceClientConfig'
  { -- | The maximum number of concurrent requests sent by the SageMaker client
    -- to the model container. If no value is provided, SageMaker chooses an
    -- optimal value.
    AsyncInferenceClientConfig -> Maybe Natural
maxConcurrentInvocationsPerInstance :: Prelude.Maybe Prelude.Natural
  }
  deriving (AsyncInferenceClientConfig -> AsyncInferenceClientConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AsyncInferenceClientConfig -> AsyncInferenceClientConfig -> Bool
$c/= :: AsyncInferenceClientConfig -> AsyncInferenceClientConfig -> Bool
== :: AsyncInferenceClientConfig -> AsyncInferenceClientConfig -> Bool
$c== :: AsyncInferenceClientConfig -> AsyncInferenceClientConfig -> Bool
Prelude.Eq, ReadPrec [AsyncInferenceClientConfig]
ReadPrec AsyncInferenceClientConfig
Int -> ReadS AsyncInferenceClientConfig
ReadS [AsyncInferenceClientConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AsyncInferenceClientConfig]
$creadListPrec :: ReadPrec [AsyncInferenceClientConfig]
readPrec :: ReadPrec AsyncInferenceClientConfig
$creadPrec :: ReadPrec AsyncInferenceClientConfig
readList :: ReadS [AsyncInferenceClientConfig]
$creadList :: ReadS [AsyncInferenceClientConfig]
readsPrec :: Int -> ReadS AsyncInferenceClientConfig
$creadsPrec :: Int -> ReadS AsyncInferenceClientConfig
Prelude.Read, Int -> AsyncInferenceClientConfig -> ShowS
[AsyncInferenceClientConfig] -> ShowS
AsyncInferenceClientConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AsyncInferenceClientConfig] -> ShowS
$cshowList :: [AsyncInferenceClientConfig] -> ShowS
show :: AsyncInferenceClientConfig -> String
$cshow :: AsyncInferenceClientConfig -> String
showsPrec :: Int -> AsyncInferenceClientConfig -> ShowS
$cshowsPrec :: Int -> AsyncInferenceClientConfig -> ShowS
Prelude.Show, forall x.
Rep AsyncInferenceClientConfig x -> AsyncInferenceClientConfig
forall x.
AsyncInferenceClientConfig -> Rep AsyncInferenceClientConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AsyncInferenceClientConfig x -> AsyncInferenceClientConfig
$cfrom :: forall x.
AsyncInferenceClientConfig -> Rep AsyncInferenceClientConfig x
Prelude.Generic)

-- |
-- Create a value of 'AsyncInferenceClientConfig' 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:
--
-- 'maxConcurrentInvocationsPerInstance', 'asyncInferenceClientConfig_maxConcurrentInvocationsPerInstance' - The maximum number of concurrent requests sent by the SageMaker client
-- to the model container. If no value is provided, SageMaker chooses an
-- optimal value.
newAsyncInferenceClientConfig ::
  AsyncInferenceClientConfig
newAsyncInferenceClientConfig :: AsyncInferenceClientConfig
newAsyncInferenceClientConfig =
  AsyncInferenceClientConfig'
    { $sel:maxConcurrentInvocationsPerInstance:AsyncInferenceClientConfig' :: Maybe Natural
maxConcurrentInvocationsPerInstance =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of concurrent requests sent by the SageMaker client
-- to the model container. If no value is provided, SageMaker chooses an
-- optimal value.
asyncInferenceClientConfig_maxConcurrentInvocationsPerInstance :: Lens.Lens' AsyncInferenceClientConfig (Prelude.Maybe Prelude.Natural)
asyncInferenceClientConfig_maxConcurrentInvocationsPerInstance :: Lens' AsyncInferenceClientConfig (Maybe Natural)
asyncInferenceClientConfig_maxConcurrentInvocationsPerInstance = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AsyncInferenceClientConfig' {Maybe Natural
maxConcurrentInvocationsPerInstance :: Maybe Natural
$sel:maxConcurrentInvocationsPerInstance:AsyncInferenceClientConfig' :: AsyncInferenceClientConfig -> Maybe Natural
maxConcurrentInvocationsPerInstance} -> Maybe Natural
maxConcurrentInvocationsPerInstance) (\s :: AsyncInferenceClientConfig
s@AsyncInferenceClientConfig' {} Maybe Natural
a -> AsyncInferenceClientConfig
s {$sel:maxConcurrentInvocationsPerInstance:AsyncInferenceClientConfig' :: Maybe Natural
maxConcurrentInvocationsPerInstance = Maybe Natural
a} :: AsyncInferenceClientConfig)

instance Data.FromJSON AsyncInferenceClientConfig where
  parseJSON :: Value -> Parser AsyncInferenceClientConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AsyncInferenceClientConfig"
      ( \Object
x ->
          Maybe Natural -> AsyncInferenceClientConfig
AsyncInferenceClientConfig'
            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
"MaxConcurrentInvocationsPerInstance")
      )

instance Prelude.Hashable AsyncInferenceClientConfig where
  hashWithSalt :: Int -> AsyncInferenceClientConfig -> Int
hashWithSalt Int
_salt AsyncInferenceClientConfig' {Maybe Natural
maxConcurrentInvocationsPerInstance :: Maybe Natural
$sel:maxConcurrentInvocationsPerInstance:AsyncInferenceClientConfig' :: AsyncInferenceClientConfig -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxConcurrentInvocationsPerInstance

instance Prelude.NFData AsyncInferenceClientConfig where
  rnf :: AsyncInferenceClientConfig -> ()
rnf AsyncInferenceClientConfig' {Maybe Natural
maxConcurrentInvocationsPerInstance :: Maybe Natural
$sel:maxConcurrentInvocationsPerInstance:AsyncInferenceClientConfig' :: AsyncInferenceClientConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxConcurrentInvocationsPerInstance

instance Data.ToJSON AsyncInferenceClientConfig where
  toJSON :: AsyncInferenceClientConfig -> Value
toJSON AsyncInferenceClientConfig' {Maybe Natural
maxConcurrentInvocationsPerInstance :: Maybe Natural
$sel:maxConcurrentInvocationsPerInstance:AsyncInferenceClientConfig' :: AsyncInferenceClientConfig -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxConcurrentInvocationsPerInstance" 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 Natural
maxConcurrentInvocationsPerInstance
          ]
      )