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

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

-- | Configures the behavior of the client used by Amazon 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, Amazon SageMaker will
    -- choose an optimal value for you.
    AsyncInferenceClientConfig -> Maybe Natural
maxConcurrentInvocationsPerInstance :: Prelude.Maybe Prelude.Natural
  }
  deriving (AsyncInferenceClientConfig -> AsyncInferenceClientConfig -> Bool
(AsyncInferenceClientConfig -> AsyncInferenceClientConfig -> Bool)
-> (AsyncInferenceClientConfig
    -> AsyncInferenceClientConfig -> Bool)
-> Eq AsyncInferenceClientConfig
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]
(Int -> ReadS AsyncInferenceClientConfig)
-> ReadS [AsyncInferenceClientConfig]
-> ReadPrec AsyncInferenceClientConfig
-> ReadPrec [AsyncInferenceClientConfig]
-> Read 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
(Int -> AsyncInferenceClientConfig -> ShowS)
-> (AsyncInferenceClientConfig -> String)
-> ([AsyncInferenceClientConfig] -> ShowS)
-> Show AsyncInferenceClientConfig
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.
 AsyncInferenceClientConfig -> Rep AsyncInferenceClientConfig x)
-> (forall x.
    Rep AsyncInferenceClientConfig x -> AsyncInferenceClientConfig)
-> Generic AsyncInferenceClientConfig
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, Amazon SageMaker will
-- choose an optimal value for you.
newAsyncInferenceClientConfig ::
  AsyncInferenceClientConfig
newAsyncInferenceClientConfig :: AsyncInferenceClientConfig
newAsyncInferenceClientConfig =
  AsyncInferenceClientConfig' :: Maybe Natural -> AsyncInferenceClientConfig
AsyncInferenceClientConfig'
    { $sel:maxConcurrentInvocationsPerInstance:AsyncInferenceClientConfig' :: Maybe Natural
maxConcurrentInvocationsPerInstance =
        Maybe Natural
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, Amazon SageMaker will
-- choose an optimal value for you.
asyncInferenceClientConfig_maxConcurrentInvocationsPerInstance :: Lens.Lens' AsyncInferenceClientConfig (Prelude.Maybe Prelude.Natural)
asyncInferenceClientConfig_maxConcurrentInvocationsPerInstance :: (Maybe Natural -> f (Maybe Natural))
-> AsyncInferenceClientConfig -> f AsyncInferenceClientConfig
asyncInferenceClientConfig_maxConcurrentInvocationsPerInstance = (AsyncInferenceClientConfig -> Maybe Natural)
-> (AsyncInferenceClientConfig
    -> Maybe Natural -> AsyncInferenceClientConfig)
-> Lens
     AsyncInferenceClientConfig
     AsyncInferenceClientConfig
     (Maybe Natural)
     (Maybe Natural)
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 Core.FromJSON AsyncInferenceClientConfig where
  parseJSON :: Value -> Parser AsyncInferenceClientConfig
parseJSON =
    String
-> (Object -> Parser AsyncInferenceClientConfig)
-> Value
-> Parser AsyncInferenceClientConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AsyncInferenceClientConfig"
      ( \Object
x ->
          Maybe Natural -> AsyncInferenceClientConfig
AsyncInferenceClientConfig'
            (Maybe Natural -> AsyncInferenceClientConfig)
-> Parser (Maybe Natural) -> Parser AsyncInferenceClientConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxConcurrentInvocationsPerInstance")
      )

instance Prelude.Hashable AsyncInferenceClientConfig

instance Prelude.NFData AsyncInferenceClientConfig

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